/* ═══════════════════════════════════════════════════════════════
   VESNA OMNIDB — Tinkoff × Apple Liquid Glass Dark
   Yellow-on-black, deep frosted glass, specular highlights
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --header-h: 60px;

  /* ── Tinkoff Yellow accent ── */
  --accent: #FFDD2D;
  --accent-dark: #E8C900;
  --accent-hover: #FFE54D;
  --accent-muted: rgba(var(--accent-rgb), 0.10);
  --accent-subtle: rgba(var(--accent-rgb), 0.06);
  --accent-ring: rgba(var(--accent-rgb), 0.30);
  --accent-glow: rgba(var(--accent-rgb), 0.28);
  --accent-glow-sm: rgba(var(--accent-rgb), 0.16);
  --accent-aura: rgba(var(--accent-rgb), 0.07);
  /* page-corner ambient glow */
  --accent-aura-2: rgba(var(--accent-rgb), 0.04);
  --accent-text: var(--accent);
  /* accent used as TEXT; auto-darkened in light theme by JS */
  --accent-rgb: 255, 221, 45;
  /* accent as an R,G,B triplet for rgba(); set by JS picker */
  --thead-bg: rgba(20, 20, 28, 0.92);
  /* sticky table header bg (themed) */

  /* ── Surfaces (dark glass) ── */
  --bg: #0D0D11;
  --bg-mid: #111116;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-solid: #1A1A22;
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-elevated: rgba(255, 255, 255, 0.08);
  --bg-secondary: var(--surface-solid);
  /* opaque pop/menu surface */
  --hover: var(--surface-elevated);
  /* generic hover background */

  /* ── Borders ── */
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* ── Text ── */
  --text: #F0F0F5;
  --text-muted: rgba(240, 240, 245, 0.50);
  --text-light: rgba(240, 240, 245, 0.28);

  /* ── Primary (alias of accent) ── */
  --primary: var(--accent);
  --primary-hover: var(--accent-hover);
  --primary-text: #0D0D11;
  --primary-light: var(--accent-muted);
  --primary-glow: var(--accent-glow);

  /* ── Semantic colors ── */
  --danger: #FF453A;
  --danger-light: rgba(255, 69, 58, 0.12);
  --success: #32D74B;
  --success-light: rgba(50, 215, 75, 0.12);
  --warning: #FFD60A;
  --warning-light: rgba(255, 214, 10, 0.12);

  /* ── Glass system ── */
  --glass-blur: blur(36px) saturate(180%);
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(22, 22, 30, 0.90);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  --glass-edge: inset 0 -1px 0 rgba(0, 0, 0, 0.30);
  --glass-specular: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%, rgba(var(--accent-rgb), 0.04) 100%);

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.50), 0 2px 8px rgba(0, 0, 0, 0.30);
  --shadow-glass: var(--glass-highlight), var(--glass-edge), 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-premium: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.60);
  --shadow-yellow: 0 4px 24px var(--accent-glow), 0 0 48px rgba(var(--accent-rgb), 0.08);

  /* ── Selection (on-palette, replaces stray Google-blue) ── */
  --selected: rgba(var(--accent-rgb), 0.12);
  --selected-border: rgba(var(--accent-rgb), 0.34);

  /* ── Shape: radius scale ── */
  --radius-xs: 6px;
  /* chips, small inputs, mini-badges */
  --radius-sm: 12px;
  /* buttons, fields */
  --radius-md: 10px;
  /* compact panels / list items */
  --radius: 20px;
  /* cards, panels */
  --radius-lg: 16px;
  /* large surfaces */
  --radius-pill: 999px;
  /* fully rounded pills */

  /* ── Typography scale ── */
  --text-2xs: 10px;
  /* uppercase table heads, micro-labels */
  --text-xs: 11px;
  --text-sm: 12px;
  /* secondary / table body */
  --text-base: 13px;
  /* default control text */
  --text-md: 14px;
  /* body */
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  /* headings / logo */
  --text-3xl: 28px;

  /* Font weights */
  --fw-regular: 500;
  --fw-medium: 600;
  --fw-bold: 700;
  --fw-heavy: 800;

  /* ── Spacing scale (8-pt grid) ── */
  --space-0_5: 2px;
  --space-1: 4px;
  --space-1_5: 6px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ── Motion ── */
  --dur-fast: 0.12s;
  --dur: 0.2s;
  --dur-slow: 0.32s;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* standard */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* decelerate / entrances */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* subtle overshoot */

  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME — token remap (accent stays driven by the picker)
   Activated via <html data-theme="light">. Most components are
   token-based, so remapping surfaces/text/borders/glass flips them.
   ═══════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  color-scheme: light;

  /* ── Surfaces (soft Apple light) ── */
  --bg: #F4F4F7;
  --bg-mid: #FAFAFB;
  --surface: rgba(20, 22, 40, 0.030);
  --surface-solid: #FFFFFF;
  --surface-2: rgba(20, 22, 40, 0.045);
  --surface-elevated: rgba(20, 22, 40, 0.065);
  --bg-secondary: #FFFFFF;
  --hover: rgba(20, 22, 40, 0.05);

  /* ── Borders ── */
  --border: rgba(20, 22, 40, 0.10);
  --border-subtle: rgba(20, 22, 40, 0.06);
  --border-strong: rgba(20, 22, 40, 0.17);

  /* ── Text ── */
  --text: #16181C;
  --text-muted: rgba(22, 24, 28, 0.56);
  --text-light: rgba(22, 24, 28, 0.34);

  /* ── Glass ── */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.97);
  --glass-border: rgba(20, 22, 40, 0.08);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glass-edge: inset 0 -1px 0 rgba(20, 22, 40, 0.04);
  --glass-specular: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, transparent 50%, var(--accent-subtle) 100%);

  /* ── Shadows (softer, tinted cool so they read on light) ── */
  --shadow-sm: 0 1px 2px rgba(16, 18, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 18, 40, 0.08), 0 1px 3px rgba(16, 18, 40, 0.05);
  --shadow-md: 0 8px 32px rgba(16, 18, 40, 0.12), 0 2px 8px rgba(16, 18, 40, 0.06);
  --shadow-glass: var(--glass-highlight), var(--glass-edge), 0 6px 24px rgba(16, 18, 40, 0.10);
  --shadow-premium: 0 0 0 1px rgba(16, 18, 40, 0.05), 0 24px 60px rgba(16, 18, 40, 0.16);
  --thead-bg: rgba(245, 246, 249, 0.94);
}

/* Light: page background — light wash with accent-tinted corners */
[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 80% 55% at 15% -5%, var(--accent-aura), transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 5%, var(--accent-aura-2), transparent 50%),
    radial-gradient(ellipse 100% 70% at 50% 110%, rgba(16, 18, 40, 0.025), transparent 60%),
    linear-gradient(180deg, #FBFBFD 0%, #F4F4F7 50%, #EDEDF2 100%);
}

/* Light: header — frosted white instead of frosted black */
[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.80);
  border-bottom: 1px solid rgba(20, 22, 40, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 0 rgba(20, 22, 40, 0.05),
    0 8px 40px rgba(16, 18, 40, 0.08);
}

/* Light: opaque dark surfaces → light popovers/menus */
[data-theme="light"] select option,
[data-theme="light"] .cat-ai-dropdown-menu,
[data-theme="light"] .user-dropdown {
  background: #FFFFFF;
}

/* Light: scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(20, 22, 40, 0.18);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(20, 22, 40, 0.30);
}

/* Light: badge & dtz contrast — darker backgrounds so text is readable */
[data-theme="light"] .dtz-critical,
[data-theme="light"] .health-critical,
[data-theme="light"] .margin-low {
  background: rgba(220, 38, 38, 0.20);
  color: #991b1b;
}

[data-theme="light"] .dtz-warning,
[data-theme="light"] .health-warning,
[data-theme="light"] .margin-mid {
  background: rgba(217, 119, 6, 0.20);
  color: #854d0e;
}

[data-theme="light"] .dtz-ok,
[data-theme="light"] .health-ok,
[data-theme="light"] .margin-high {
  background: rgba(22, 163, 74, 0.20);
  color: #15803d;
}

[data-theme="light"] .dtz-no-sales {
  background: rgba(20, 22, 40, 0.10);
  color: var(--text-muted);
}

[data-theme="light"] .abc-a {
  background: rgba(22, 163, 74, 0.20);
  color: #15803d;
}

[data-theme="light"] .abc-b {
  background: rgba(217, 119, 6, 0.20);
  color: #854d0e;
}

[data-theme="light"] .abc-c {
  background: rgba(20, 22, 40, 0.10);
  color: var(--text-muted);
}

/* Light: panel specular edge — soften to near-invisible on white */
[data-theme="light"] .panel::before {
  background: linear-gradient(90deg,
      transparent 0%,
      var(--accent-ring) 35%,
      rgba(255, 255, 255, 0.6) 50%,
      var(--accent-ring) 65%,
      transparent 100%);
  opacity: 0.5;
}

/* ─── Light theme: Buttons ──────────────────────────────────── */
/* Many button backgrounds use rgba(255,255,255,X%) which is
   invisible on a light/white bg. Remap to dark-tinted values. */

[data-theme="light"] .btn-outline {
  background: rgba(20, 22, 40, 0.08);
  backdrop-filter: none;
}

[data-theme="light"] .btn-outline:hover {
  background: rgba(20, 22, 40, 0.14);
  border-color: rgba(20, 22, 40, 0.28);
}

[data-theme="light"] .note-btn:hover {
  background: rgba(20, 22, 40, 0.08);
}

[data-theme="light"] .page-btns button {
  background: rgba(20, 22, 40, 0.06);
}

[data-theme="light"] .page-btns button:hover:not(:disabled) {
  background: rgba(20, 22, 40, 0.12);
}

[data-theme="light"] .flt-panel-footer button {
  background: rgba(20, 22, 40, 0.06);
}

[data-theme="light"] .flt-panel-footer button:hover {
  background: rgba(20, 22, 40, 0.12);
  color: var(--text);
}

[data-theme="light"] .flt-btn {
  background: rgba(20, 22, 40, 0.06);
}

[data-theme="light"] .flt-btn:hover {
  background: rgba(20, 22, 40, 0.12);
}

/* Light: clickable interactive containers (accordions, cards, sortable headers) */
[data-theme="light"] .catalog-card {
  background: rgba(20, 22, 40, 0.04);
  backdrop-filter: none;
}

[data-theme="light"] .catalog-card:hover {
  background: rgba(20, 22, 40, 0.08);
  border-color: rgba(20, 22, 40, 0.16);
}

[data-theme="light"] .ai-result-header {
  background: rgba(20, 22, 40, 0.04);
}

[data-theme="light"] .ai-result-header:hover {
  background: rgba(20, 22, 40, 0.08);
}

[data-theme="light"] .cat-th-sort:hover {
  background: rgba(20, 22, 40, 0.06);
}

/* Light: marketing hub — stronger surfaces for readability */
[data-theme="light"] .mkt-promo-readonly {
  background: rgba(20, 22, 40, 0.08);
}

[data-theme="light"] .mkt-promo-preview-box {
  background: rgba(20, 22, 40, 0.05);
}

[data-theme="light"] .mkt-promo-preview-text {
  color: var(--text);
}

[data-theme="light"] .mkt-tab-btn:hover {
  background: rgba(20, 22, 40, 0.08);
}

[data-theme="light"] .mkt-tab-btn.active {
  background: rgba(var(--accent-rgb), 0.15);
}

/* ─── Reset ─────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Accessibility: keyboard focus & text selection ─────────── */
/* Visible focus ring only for keyboard users (not mouse clicks). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Elements that draw their own accent ring on focus keep it; suppress the
   default UA outline for pointer interactions only. */
:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--accent-ring);
  color: var(--text);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color-scheme: dark;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  height: 100%;
  overflow: hidden;

  /* Dark base with subtle yellow aura */
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 55% at 15% -5%, var(--accent-aura), transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 5%, var(--accent-aura-2), transparent 50%),
    radial-gradient(ellipse 100% 70% at 50% 110%, var(--accent-aura-2), transparent 60%),
    linear-gradient(180deg, #111116 0%, #0D0D11 50%, #0B0B0F 100%);
  background-attachment: fixed;
}

/* App shell — flex column that fills the viewport.
   On mobile this element gets position:fixed to pin to the visual viewport,
   which is more reliable than putting it on <body> in iOS Safari. */
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ─── Global progress bar ───────────────────────────────────── */
@keyframes progress-shimmer {
  0% {
    background-position: -200% center;
  }

  100% {
    background-position: 200% center;
  }
}

#global-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10000;
  /* above header (100) and modals (9999) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#global-progress.visible {
  opacity: 1;
}

#global-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,
      var(--accent-dark) 0%,
      var(--accent) 30%,
      rgba(255, 255, 255, .7) 50%,
      var(--accent) 70%,
      var(--accent-dark) 100%);
  background-size: 200% 100%;
  animation: progress-shimmer 1.1s linear infinite;
  box-shadow: 0 0 10px var(--accent-glow), 0 0 20px rgba(var(--accent-rgb), .25);
  border-radius: 0 3px 3px 0;
  transition: width 0.22s cubic-bezier(0.1, 0.05, 0, 1);
  will-change: width;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.20);
}

/* ─── Login ──────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.login-glass-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  padding: 48px 40px 40px;
  border-radius: 28px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
}

.login-glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-specular);
  pointer-events: none;
  border-radius: inherit;
}

.login-logo {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: -0.04em;
  color: var(--text);
}

.login-logo-accent {
  color: var(--accent-text);
}

.login-logo-img {
  display: block;
  height: 110px;
  width: auto;
  margin: 0 auto 28px;
}

.app-logo-img {
  height: 34px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-input::placeholder {
  color: var(--text-light);
}

.login-input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: rgba(var(--accent-rgb), 0.05);
}

.login-submit {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
  border-radius: var(--radius-sm);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

/* ─── Header ─────────────────────────────────────────────────── */
.app-header {
  background: rgba(13, 13, 17, 0.85);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 0 rgba(0, 0, 0, 0.60),
    0 8px 40px rgba(0, 0, 0, 0.40);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: nowrap;
  /* visible (not hidden) so the active tab pill's downward glow isn't clipped
     at the header's bottom edge; the nav scrolls/masks horizontally itself */
  overflow: visible;
}

.app-logo {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  box-shadow: var(--shadow-yellow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.app-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}

.app-header nav {
  display: flex;
  align-items: center;
  /* don't stretch tabs to full height — leaves room so the
                           active/pressed pill's bottom edge isn't clipped */
  gap: 2px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Fade edges — hint that more tabs exist.
     Use a vertical hard-stop at 0% and 100% so the mask only fades the left/right
     edges without clipping the bottom box-shadow of active tabs. */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 22px, black calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 22px, black calc(100% - 22px), transparent 100%);
  /* Symmetric vertical padding gives the active tab pill's glow room to render
     in BOTH directions inside this scroll container (overflow-x:auto forces
     overflow-y to clip). Negative vertical margins offset it so the outer box
     stays symmetric (6px/6px) and layout doesn't shift. Combined with the
     header's overflow:visible, the glow spills over the content below instead
     of being clipped. The active-tab glow is tuned (below) to fit this room.
     padding-bottom is larger than the net margin offset to leave room for the
     bottom glow to render inside the clipped scroll container. */
  padding: 22px 8px 28px;
  margin-top: -16px;
  margin-bottom: -22px;
}

.app-header nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 7px 14px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
    border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border);
}

.tab-btn:active {
  transform: translateY(1px);
}

.tab-btn.active {
  background: var(--accent);
  color: var(--primary-text);
  font-weight: 700;
  border-color: transparent;
  /* Tight accent glow that fits within the nav's ~22px vertical padding so it
     isn't clipped by the horizontal scroll container; still accent-driven. */
  box-shadow: 0 2px 12px var(--accent-glow), 0 0 18px var(--accent-glow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.30);
}

/* ─── Header right ───────────────────────────────────────────── */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.store-switcher-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.store-switcher {
  min-width: 160px;
  max-width: 220px;
}

.stores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stores-table th,
.stores-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text);
}

/* Subtle themed surface (not the heavy --thead-bg slab, which reads dark in the
   dark theme); this is a small settings table that needs no sticky heavy header. */
.stores-table th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  position: static;
}

/* Extra specificity for #stores-list to fully override the generic thead th rule */
#stores-list .stores-table thead th {
  background: var(--surface-2);
}

.stores-row-active {
  background: var(--accent-muted);
}

.stores-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-block;
  transition: background .3s;
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px rgba(50, 215, 75, 0.5);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 69, 58, 0.5);
}

.status-dot.running {
  background: var(--accent);
  animation: pulse .8s ease-in-out infinite alternate;
  box-shadow: 0 0 8px var(--accent-glow);
}

@keyframes pulse {
  from {
    opacity: 1;
  }

  to {
    opacity: .4;
  }
}

.status-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 8px;
}

/* ─── Content ────────────────────────────────────────────────── */
.app-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

.mobile-nav-spacer {
  display: none; /* shown only in mobile media query */
}

.tab-panel {
  display: none;
  width: 100%;
  box-sizing: border-box;
}

.tab-panel.active {
  display: block;
}

/* ─── Panel / Card — Liquid Glass ───────────────────────────── */
.panel {
  width: 100%;
  box-sizing: border-box;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

/* Specular top edge — yellow-tinted light */
.panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(var(--accent-rgb), 0.25) 30%,
      rgba(255, 255, 255, 0.25) 50%,
      rgba(var(--accent-rgb), 0.20) 70%,
      transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Inner glass texture */
.panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-specular);
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.6;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.025);
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  z-index: 2;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  flex: 1 0 auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-text);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  letter-spacing: 0.01em;
}

.meta-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── KPI Grid ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 0;
}

.kpi-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-glass);
  transition: box-shadow 0.25s, transform 0.25s, border-color 0.25s;
  position: relative;
  overflow: hidden;
}

/* Specular line on KPI cards */
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
}

/* Inner glass texture */
.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--kpi-hover-rgb, var(--accent-rgb)), 0.12);
  transform: translateY(-2px);
  border-color: rgba(var(--kpi-hover-rgb, var(--accent-rgb)), 0.18);
}

.kpi-card-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 10px;
  display: inline-block;
}

/* ─── Иконки (inline SVG, набор Lucide; цвет = currentColor, размер = 1em) ─── */
.vic {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex-shrink: 0;
}

.vic-host {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
}

.btn>.vic-host {
  margin-right: 0;
}

/* у .btn уже есть gap */
.kpi-card-icon .vic {
  color: var(--accent-text);
}

.search-icon .vic {
  width: 15px;
  height: 15px;
}

.kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.03em;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.3;
}

.kpi-mod {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Clickable cards */
.kpi-clickable {
  cursor: pointer;
}

.kpi-clickable:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(var(--kpi-hover-rgb, var(--accent-rgb)), 0.20);
  transform: translateY(-2px);
  border-color: rgba(var(--kpi-hover-rgb, var(--accent-rgb)), 0.25);
}

.kpi-clickable.kpi-active {
  border-color: rgba(var(--accent-rgb), 0.40);
  border-left: 3px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.07);
  box-shadow: var(--shadow-glass), 0 0 20px rgba(var(--accent-rgb), 0.08);
}

.kpi-drill-hint {
  font-size: 10px;
  color: var(--accent-text);
  opacity: 0;
  margin-top: 6px;
  transition: opacity .15s;
  font-weight: 600;
}

.kpi-clickable:hover .kpi-drill-hint,
.kpi-clickable.kpi-active .kpi-drill-hint {
  opacity: 0.7;
}

/* Status variants — static colour cues (left border, tint, value colour).
   Hover glow intentionally NOT overridden here: it falls through to the base
   .kpi-card:hover / .kpi-clickable:hover rules, which use the user-chosen
   --accent-rgb. So every KPI card glows in the selected theme colour on hover,
   while status is still conveyed by the persistent border/background/value. */
.kpi-danger .kpi-val {
  color: var(--danger);
}

.kpi-danger {
  border-left: 3px solid var(--danger);
  background: var(--danger-light);
}

.kpi-warning .kpi-val {
  color: var(--warning);
}

.kpi-warning {
  border-left: 3px solid var(--warning);
  background: var(--warning-light);
}

.kpi-success .kpi-val {
  color: var(--success);
}

.kpi-success {
  border-left: 3px solid var(--success);
  background: var(--success-light);
}

.kpi-skeleton .kpi-val {
  color: var(--text-light);
}

/* ── KPI hover glow uses semantic colour, not accent ────────── */
/* Cards with no status class fall through to --kpi-hover-rgb (set per-card via
   JS) or the default var(--accent-rgb). Static CSS for inline-style cards that
   have border-left:3px solid hardcoded — we override hover via attribute match. */
.kpi-danger:hover,
.kpi-danger.kpi-clickable:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 69, 58, 0.15);
  border-color: rgba(255, 69, 58, 0.22);
}

.kpi-warning:hover,
.kpi-warning.kpi-clickable:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 214, 10, 0.15);
  border-color: rgba(255, 214, 10, 0.22);
}

.kpi-success:hover,
.kpi-success.kpi-clickable:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(50, 215, 75, 0.15);
  border-color: rgba(50, 215, 75, 0.22);
}

/* ─── Drill-down ─────────────────────────────────────────────── */
.overview-drilldown {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  margin: 14px 0;
  animation: slideDown .18s ease;
  box-shadow: var(--shadow-md);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overview-drilldown-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(var(--accent-rgb), 0.08);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: var(--radius) var(--radius) 0 0;
}

.overview-drilldown-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.drilldown-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: background .12s, color .12s;
}

.drilldown-close:hover {
  background: var(--danger);
  color: #fff;
}

.drilldown-content {
  max-height: 340px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: auto;
}

.drilldown-table {
  width: 100%;
  box-sizing: border-box;
  border-collapse: collapse;
  font-size: 12px;
}

.drilldown-table th {
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 9px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.drilldown-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.drilldown-table tr:last-child td {
  border-bottom: none;
}

.drilldown-table tr:hover td {
  background: var(--accent-muted);
}

.drilldown-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ─── Overview charts ────────────────────────────────────────── */
.overview-charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 20px;
}

.chart-canvas-wrap {
  padding: 12px 12px 16px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chart-canvas-wrap canvas {
  max-height: 200px;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alerts-list {
  padding: 8px 0;
}

.alert-item {
  padding: 11px 20px;
  font-size: 13px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-danger {
  border-color: var(--danger);
  background: var(--danger-light);
  color: #FF6B6B;
}

.alert-warning {
  border-color: var(--warning);
  background: var(--warning-light);
  color: #FFD60A;
}

.alert-info {
  border-color: var(--accent-text);
  background: var(--accent-muted);
  color: var(--accent-text);
}

.alert-ok {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--primary-text);
  border-color: transparent;
  box-shadow: 0 4px 16px var(--accent-glow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.20) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 28px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.20);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 14px;
  line-height: 1;
}

/* ─── Toggle ─────────────────────────────────────────────────── */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.toggle-label input {
  accent-color: var(--accent-text);
}

/* ─── Search & toolbar ───────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-family: var(--font);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: rgba(var(--accent-rgb), 0.04);
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - var(--header-h) - 280px);
  border-radius: 0 0 var(--radius) var(--radius);
  display: block;
}

table {
  width: 100%;
  box-sizing: border-box;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--thead-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

thead th:hover {
  color: var(--accent-text);
}

thead th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: .35;
  font-size: 10px;
}

thead th.sort-asc .sort-icon,
thead th.sort-desc .sort-icon {
  opacity: 1;
  color: var(--accent-text);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(var(--accent-rgb), 0.04);
}

tbody td {
  padding: 7px 9px;
  color: var(--text);
  vertical-align: middle;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.muted {
  color: var(--text-muted);
}

td.highlight {
  font-weight: 700;
  color: var(--text);
}

.supplier-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  font-size: 12px;
  border: 1px solid var(--border);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Ordered row ────────────────────────────────────────────── */
.row-ordered {
  opacity: .4;
}

.row-ordered td {
  text-decoration: line-through;
  text-decoration-color: var(--text-light);
}

.row-selected {
  background-color: var(--selected) !important;
  box-shadow: inset 3px 0 0 var(--selected-border);
}

/* ─── Grouped nom rows ───────────────────────────────────────── */
.nom-group-header {
  background: var(--bg-soft, rgba(255, 255, 255, .03));
}

.nom-group-header td {
  font-weight: 500;
}

.nom-char-row td {
  color: var(--text-muted);
}

.nom-char-row:hover td {
  color: var(--text);
}

.cat-char-group td {
  font-weight: 500;
}

.cat-char-child td {
  color: var(--text-muted);
}

/* ─── Note button ────────────────────────────────────────────── */
.note-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .1s, color .1s;
}

.note-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.note-btn.has-note {
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: var(--accent-muted);
}

/* ─── DTZ badge ──────────────────────────────────────────────── */
.dtz-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.dtz-critical {
  background: var(--danger-light);
  color: var(--danger);
}

.dtz-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.dtz-ok {
  background: var(--success-light);
  color: var(--success);
}

.dtz-no-sales {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
}

/* ─── Category (pooled) mode ─────────────────────────────────── */
.cat-expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  line-height: 1;
}

.cat-expand-btn:hover {
  color: var(--text);
}

.cat-min-input {
  width: 56px;
  margin-left: 6px;
  padding: 3px 5px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
}

.cat-min-input:focus {
  border-color: var(--accent-text);
  outline: none;
}

.cat-sku-detail>td {
  background: rgba(255, 255, 255, 0.02);
}

.cat-sku-table {
  width: 100%;
  border-collapse: collapse;
}

.cat-sku-table td {
  padding: 5px 10px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cat-sku-table tr:last-child td {
  border-bottom: none;
}

.cat-zero-badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-radius: var(--radius-xs);
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

/* ─── Cat table sortable headers ────────────────────────────── */
.cat-th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.cat-th-sort:hover {
  background: rgba(255, 255, 255, 0.05);
}

.cat-th-sort.th-sorted {
  color: var(--accent, #6366f1);
}

.sort-arrow {
  font-size: 10px;
  opacity: 0.8;
}

/* ─── Group tree (multi-level pooled deficit) ────────────────── */
.cat-expand-spacer {
  display: inline-block;
  width: 19px;
}

.cat-name {
  vertical-align: middle;
}

.cat-tree-table tbody tr.cat-lvl-0 .cat-name {
  font-weight: 700;
}

.cat-tree-table tbody tr.cat-lvl-1 .cat-name {
  font-weight: 600;
}

.cat-row-deficit {
  background: rgba(239, 68, 68, 0.06);
}

.cat-row-deficit:hover {
  background: rgba(239, 68, 68, 0.10);
}

.cat-deficit-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
}

.cat-subdef-badge {
  display: inline-block;
  margin-left: 8px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-radius: var(--radius-md);
  padding: 0 7px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.cov-bar {
  position: relative;
  height: 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xs);
  overflow: hidden;
  min-width: 90px;
}

.cov-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: var(--radius-xs);
  transition: width .25s;
}

.cov-crit {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

.cov-warn {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.cov-ok {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.cov-label {
  position: absolute;
  right: 6px;
  top: 0;
  line-height: 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}

/* ─── Fallback badges ────────────────────────────────────────── */
.fallback-row-badge {
  display: inline-block;
  font-size: 12px;
  opacity: 0.7;
  cursor: help;
  vertical-align: middle;
  margin-left: 2px;
}

.fallback-badge-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--warning-light);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
}

/* ─── Days badge ─────────────────────────────────────────────── */
.days-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}

.days-badge.critical {
  background: var(--danger-light);
  color: var(--danger);
}

.days-badge.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.days-badge.ok {
  background: var(--success-light);
  color: var(--success);
}

/* ─── States ─────────────────────────────────────────────────── */
.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.state-box .state-icon {
  font-size: 40px;
  opacity: .4;
}

.state-box .state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.state-box .state-sub {
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  box-shadow: 0 0 10px var(--accent-glow-sm);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 600;
  background: rgba(28, 28, 36, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  min-width: 240px;
  animation: slide-in .25s ease;
}

.toast.success {
  background: rgba(50, 215, 75, 0.15);
  border-color: rgba(50, 215, 75, 0.30);
  color: var(--success);
}

.toast.error {
  background: rgba(255, 69, 58, 0.15);
  border-color: rgba(255, 69, 58, 0.30);
  color: var(--danger);
}

.toast.info {
  background: var(--accent-muted);
  border-color: rgba(var(--accent-rgb), 0.30);
  color: var(--accent-text);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Info row ───────────────────────────────────────────────── */
.info-row {
  display: flex;
  gap: 20px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  flex-wrap: wrap;
  align-items: center;
  position: relative;
  z-index: 2;
}

.info-item {
  font-size: 12px;
  color: var(--text-muted);
}

.info-item strong {
  color: var(--text);
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.page-info {
  font-size: 12px;
  color: var(--text-muted);
}

.page-btns {
  display: flex;
  gap: 4px;
}

.page-btns button {
  padding: 5px 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all .15s;
  font-family: var(--font);
}

.page-btns button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border-color: var(--border-strong);
}

.page-btns button.active {
  background: var(--accent);
  color: var(--primary-text);
  border-color: transparent;
  box-shadow: 0 2px 8px var(--accent-glow-sm);
}

.page-btns button:disabled {
  opacity: .3;
  cursor: not-allowed;
}

/* ─── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  margin-right: 4px;
}

/* Dropdown */
.flt-dropdown {
  position: relative;
}

.flt-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  max-width: 220px;
}

.flt-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--border-strong);
}

.flt-btn.flt-active {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: var(--accent-muted);
  color: var(--accent-text);
}

.flt-btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flt-arrow {
  font-size: 10px;
  opacity: .5;
  flex-shrink: 0;
}

.flt-panel {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 240px;
  max-width: 340px;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 500;
  overflow: hidden;
}

.flt-panel.open {
  display: block;
}

.flt-panel-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.flt-panel-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.flt-panel-search input:focus {
  border-color: var(--accent-text);
}

.flt-panel-list {
  max-height: 260px;
  overflow-y: auto;
}

.flt-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background .1s;
  color: var(--text);
}

.flt-option:hover {
  background: rgba(255, 255, 255, 0.07);
}

.flt-option.checked {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.flt-option input[type=checkbox] {
  accent-color: var(--accent-text);
  flex-shrink: 0;
}

.flt-option-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flt-option-count {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.flt-panel-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}

.flt-panel-footer button {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .1s;
  font-family: var(--font);
}

.flt-panel-footer button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

.flt-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.flt-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.flt-range input[type=number] {
  width: 72px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.06);
}

.flt-range input[type=number]:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.flt-range input[type=number].flt-active {
  border-color: rgba(var(--accent-rgb), 0.40);
  background: var(--accent-muted);
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.flt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-muted);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  max-width: 200px;
  border: 1px solid rgba(var(--accent-rgb), 0.25);
}

.flt-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flt-chip-remove {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.20);
  cursor: pointer;
  font-size: 11px;
  transition: background .1s;
  color: var(--accent-text);
}

.flt-chip-remove:hover {
  background: rgba(var(--accent-rgb), 0.40);
}

.flt-clear-all {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 2px 4px;
  font-family: var(--font);
}

.flt-clear-all:hover {
  color: var(--danger);
}

/* ─── ABC Matrix ─────────────────────────────────────────────── */
.abc-matrix-wrap {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.abc-matrix {
  display: inline-block;
}

.abc-matrix-grid {
  display: grid;
  grid-template-columns: 48px repeat(3, 80px);
  gap: 4px;
}

.abc-cell {
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: opacity .15s;
  border: 2px solid transparent;
}

.abc-cell:hover {
  opacity: .80;
  border-color: rgba(255, 255, 255, 0.15);
}

.abc-header-cell {
  background: none;
  font-weight: 700;
  font-size: 13px;
  cursor: default;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.abc-cell-class {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  opacity: 0.7;
}

.abc-cell-count {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

.class-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  letter-spacing: .3px;
}

.abc-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ─── Charts ─────────────────────────────────────────────────── */
.chart-wrap {
  padding: 20px;
  min-height: 300px;
}

.chart-wrap canvas {
  width: 100% !important;
}

/* ─── Segmented control ──────────────────────────────────────── */
.seg-ctrl {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.seg-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all .15s;
}

.seg-btn:last-child {
  border-right: none;
}

.seg-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.seg-btn.active {
  background: var(--accent);
  color: var(--primary-text);
  font-weight: 700;
}

/* ─── Snapshots ──────────────────────────────────────────────── */
.snapshot-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
}

.snapshot-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 200px;
  position: relative;
}

.snapshot-card-latest {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: var(--accent-muted);
}

.snapshot-date {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.snapshot-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.snapshot-stats strong {
  color: var(--text);
}

.snapshot-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  background: var(--accent);
  color: var(--primary-text);
  border-radius: var(--radius-pill);
}

.diff-summary {
  padding: 12px 20px;
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.diff-new {
  font-weight: 700;
  color: var(--success);
  font-size: 14px;
}

.diff-removed {
  font-weight: 700;
  color: var(--danger);
  font-size: 14px;
}

.diff-section {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.diff-section:last-child {
  border-bottom: none;
}

.diff-section-title {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}

.diff-new-title {
  color: var(--success);
}

.diff-removed-title {
  color: var(--danger);
}

.diff-table {
  width: 100%;
  box-sizing: border-box;
  border-collapse: collapse;
  font-size: 13px;
}

.diff-table th {
  background: rgba(255, 255, 255, 0.05);
  padding: 7px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.diff-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.diff-table tr:last-child td {
  border-bottom: none;
}

/* ─── Settings ───────────────────────────────────────────────── */
.settings-form {
  padding: 20px 24px;
}

.settings-row {
  margin-bottom: 20px;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.settings-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.settings-input {
  width: 200px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.06);
}

.settings-input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}

/* ── Appearance controls (theme + accent picker) ───────────────── */
.theme-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.theme-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.theme-seg-btn:hover {
  color: var(--text);
}

.theme-seg-btn.active {
  color: var(--primary-text);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

.theme-seg-btn svg {
  width: 15px;
  height: 15px;
}

.accent-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.accent-swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-pill);
  background: var(--sw, #888);
  border: 2px solid var(--border-strong);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) var(--ease);
  position: relative;
}

.accent-swatch:hover {
  transform: scale(1.12);
}

.accent-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sw, var(--accent));
}

.accent-swatch.active::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.accent-custom {
  position: relative;
  overflow: hidden;
  background: conic-gradient(from 0deg,
      #FF453A, #FFD60A, #32D74B, #0A84FF, #BF5AF2, #FF453A);
  border-style: dashed;
}

.accent-custom input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.settings-status {
  font-size: 13px;
}

.settings-status.ok {
  color: var(--success);
}

.settings-status.error {
  color: var(--danger);
}

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-premium);
  width: 480px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.modal::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.30), transparent);
  pointer-events: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.comment-textarea {
  margin: 16px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  resize: vertical;
  font-family: var(--font);
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.comment-textarea:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  align-items: center;
}

.modal-wide {
  width: 660px;
  max-width: 95vw;
}

/* ─── Nomenclature modal ─────────────────────────────────────── */
.nom-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 70vh;
}

.nom-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.nom-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.nom-field-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  transition: all .15s;
}

.nom-field-input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.nom-field-input.changed {
  border-color: var(--warning);
  background: var(--warning-light);
}

.nom-field-original {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: none;
}

.nom-field-original.visible {
  display: block;
}

.nom-pending-notice {
  background: var(--warning-light);
  border: 1px solid rgba(255, 214, 10, 0.30);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Pending changes ────────────────────────────────────────── */
.pending-modal-body {
  padding: 0 20px 8px;
  overflow-y: auto;
  max-height: 70vh;
}

.pending-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 12px 0;
}

.pending-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.pending-item-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  color: var(--text);
}

.pending-item-date {
  font-size: 11px;
  color: var(--text-muted);
}

.pending-item-discard {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 2px;
  line-height: 1;
}

.pending-item-discard:hover {
  color: var(--danger);
}

.pending-changes-list {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-change-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  align-items: center;
}

.pending-change-field {
  font-weight: 600;
  color: var(--text-muted);
}

.pending-change-old {
  color: var(--danger);
  text-decoration: line-through;
}

.pending-change-new {
  color: var(--success);
  font-weight: 600;
}

.pending-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Pending button in header ───────────────────────────────── */
.pending-changes-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--warning-light);
  border: 1px solid rgba(255, 214, 10, 0.30);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
  white-space: nowrap;
  font-family: var(--font);
  transition: all .15s;
}

.pending-changes-btn:hover {
  background: rgba(255, 214, 10, 0.20);
}

.pending-icon {
  font-size: 14px;
}

.pending-changes-count {
  background: var(--warning);
  color: var(--primary-text);
  border-radius: var(--radius-md);
  padding: 0 6px;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  text-align: center;
}

/* ─── Danger outline ─────────────────────────────────────────── */
.btn-danger-outline {
  color: var(--danger);
  border-color: rgba(255, 69, 58, 0.35);
  background: var(--danger-light);
}

.btn-danger-outline:hover {
  background: rgba(255, 69, 58, 0.20);
}

/* ─── Price tables ───────────────────────────────────────────── */
.price-min {
  background: var(--success-light);
  color: var(--success);
  font-weight: 600;
}

.price-na {
  color: var(--text-light);
}

.delta-pos {
  color: var(--success);
  font-weight: 600;
}

.delta-neg {
  color: var(--danger);
  font-weight: 600;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
}

.name-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ─── 1C badges ──────────────────────────────────────────────── */
.badge-1c {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 0 5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
}

.badge-1c.ok {
  color: var(--success);
  background: var(--success-light);
}

.badge-name-changed {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  border-radius: var(--radius-sm);
  padding: 0 5px;
  margin-left: 4px;
  color: var(--warning);
  background: var(--warning-light);
  cursor: help;
}

.badge-name-pending {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  border-radius: var(--radius-sm);
  padding: 0 5px;
  margin-left: 4px;
  color: var(--accent-text);
  background: var(--accent-muted);
  cursor: help;
}

.supl-count-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  border-radius: var(--radius-pill);
  padding: 0 6px;
  margin-left: 4px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
}

/* ─── Column resize ──────────────────────────────────────────── */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 11;
  background: transparent;
}

.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  right: 3px;
  width: 2px;
  border-radius: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity .15s;
}

thead th:hover .col-resize-handle::after {
  opacity: 1;
}

.col-resize-handle:hover::after {
  opacity: 1;
  background: var(--accent);
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.col-resizing .col-resize-handle::after {
  opacity: 1;
  background: var(--accent);
}

.table-resizable {
  table-layout: fixed;
  min-width: 100%;
}

.table-resizable thead th,
.table-resizable tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Nom edit button ────────────────────────────────────────── */
.nom-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-light);
  padding: 0 2px;
  vertical-align: middle;
  opacity: .5;
  line-height: 1;
  transition: all .15s;
}

.nom-edit-btn:hover {
  opacity: 1;
  color: var(--accent-text);
}

/* ─── Catalogs grid ──────────────────────────────────────────── */
.catalogs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 4px 0 8px;
}

.catalog-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  transition: all .2s;
}

.catalog-card:hover {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: var(--shadow-sm);
  border-color: rgba(255, 255, 255, 0.14);
}

.catalog-card-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.catalog-card-body {
  flex: 1;
  min-width: 0;
}

.catalog-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.catalog-card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.catalog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.catalog-dot.ok {
  background: var(--success);
  box-shadow: 0 0 6px rgba(50, 215, 75, 0.5);
}

.catalog-dot.stale {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 214, 10, 0.4);
}

.catalog-dot.missing {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 69, 58, 0.5);
}

.catalog-sync-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  transition: all .15s;
  white-space: nowrap;
}

.catalog-sync-btn:hover {
  background: var(--accent-muted);
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.catalog-sync-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ─── Margin analysis ────────────────────────────────────────── */
.margin-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.margin-high {
  background: var(--success-light);
  color: var(--success);
}

.margin-mid {
  background: var(--warning-light);
  color: var(--warning);
}

.margin-low {
  background: var(--danger-light);
  color: var(--danger);
}

.margin-none {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
}

.margin-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.margin-high-row {
  background: rgba(50, 215, 75, 0.06);
}

.margin-low-row {
  background: rgba(255, 69, 58, 0.06);
}

/* ─── Health / Diagnostics ───────────────────────────────────── */
.health-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 24px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 700;
}

.health-critical {
  background: var(--danger-light);
  color: var(--danger);
}

.health-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.health-ok {
  background: var(--success-light);
  color: var(--success);
}

.health-reason-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin: 1px 2px;
}

.abc-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 700;
}

.abc-a {
  background: var(--success-light);
  color: var(--success);
}

.abc-b {
  background: var(--warning-light);
  color: var(--warning);
}

.abc-c {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
}

.xyz-x {
  background: rgba(96, 165, 250, 0.15);
  color: #60A5FA;
}

.xyz-y {
  background: rgba(167, 139, 250, 0.15);
  color: #A78BFA;
}

.xyz-z {
  background: var(--danger-light);
  color: var(--danger);
}

/* ─── AI Enrichment ──────────────────────────────────────────── */
.ai-problem-badge {
  display: inline-block;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: var(--radius-md);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ai-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  max-height: 420px;
  overflow-y: auto;
}

.ai-result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ai-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
  transition: background .1s;
}

.ai-result-header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ai-result-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.ai-result-badge-ok {
  background: var(--success-light);
  color: var(--success);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
}

.ai-result-badge-skip {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
}

.ai-result-badge-err {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
}

.ai-result-accept-chk {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--success);
}

.ai-result-body {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-diff-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  font-size: 12px;
  align-items: start;
}

.ai-diff-label {
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}

.ai-diff-values {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-diff-old {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 12px;
}

.ai-diff-new {
  color: var(--success);
  font-weight: 600;
  font-size: 12px;
}

/* ─── Stale data banner ──────────────────────────────────────── */
.stale-data-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: rgba(16, 16, 22, 0.90);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.20);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 90;
}

.stale-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.stale-data-banner span {
  flex: 1;
}

.stale-banner-refresh {
  background: var(--accent);
  color: var(--primary-text);
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--accent-glow-sm);
  font-family: var(--font);
}

.stale-banner-refresh:hover {
  background: var(--accent-hover);
}

.stale-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  flex-shrink: 0;
  opacity: 0.6;
}

.stale-banner-close:hover {
  opacity: 1;
}

/* ─── Header selects ─────────────────────────────────────────── */
#store-switcher,
#page-size-select,
.header-right select.search-input {
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-family: var(--font);
}

/* Native select options — force dark on supported browsers */
select option {
  background: #1A1A22;
  color: var(--text);
}

/* ─── Special: inline warning boxes from HTML ────────────────── */
/* Override hard-coded amber colors in pricing/scenario panels */
.info-row[style*="b45309"],
.info-row[style*="fffbeb"] {
  background: rgba(255, 214, 10, 0.08) !important;
  border-color: rgba(255, 214, 10, 0.20) !important;
  color: #FFD60A !important;
  border: 1px solid rgba(255, 214, 10, 0.20);
  border-radius: var(--radius-xs);
  margin: 8px 20px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .overview-charts-row {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .catalogs-grid {
    grid-template-columns: 1fr;
  }

  .app-content {
    padding: 16px 16px 32px;
  }
}

/* Real estate form fields */
.re-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.re-field>span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

/* ─── Product card modal (unified, replaces old drawer) ──────── */
.pcard-modal {
  width: 680px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pcard-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.pcard-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.pcard-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-text);
}

.pcard-tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.pcard-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}

/* Product card: 1С vs service sections */
.pcard-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 4px;
  margin-bottom: 14px;
}

.pcard-section-1c {
  background: rgba(96, 165, 250, 0.05);
  border-color: rgba(96, 165, 250, 0.25);
}

.pcard-section-svc {
  background: rgba(var(--accent-rgb), 0.04);
  border-color: rgba(var(--accent-rgb), 0.20);
}

.pcard-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pcard-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.pcard-badge-1c {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.pcard-badge-svc {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent-text);
  border: 1px solid rgba(var(--accent-rgb), 0.30);
}

.pcard-section-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Read-only imported attributes grid */
.pcard-ro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 4px;
}

.pcard-ro-field {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
}

.pcard-ro-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.pcard-ro-value {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  word-break: break-word;
}

.pcard-editable-note {
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0 8px;
}

/* Category picker */
.pcard-group-pick {
  position: relative;
}

.pcard-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color .1s;
}

.pcard-group-btn:hover {
  border-color: var(--accent-text);
}

.pcard-group-pick.changed .pcard-group-btn {
  border-color: var(--accent-text);
  background: var(--accent-muted);
}

.pcard-group-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard-group-caret {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
}

.pcard-group-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--glass-bg-strong, #1C1C26);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .7);
  z-index: 1100;
  overflow: hidden;
}

.pcard-group-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.pcard-group-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  box-sizing: border-box;
}

.pcard-group-search-input:focus {
  border-color: var(--accent-text);
}

.pcard-group-list {
  max-height: 240px;
  overflow-y: auto;
}

.pcard-group-opt {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background .1s;
}

.pcard-group-opt:hover {
  background: rgba(255, 255, 255, 0.07);
}

.pcard-group-opt.checked {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.pcard-group-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Completeness bar */
.cat-completeness-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cat-completeness-fill {
  height: 100%;
  border-radius: var(--radius-md);
  transition: width .4s ease, background-color .4s;
}

/* Stats chips */
.cat-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.cat-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* AI dropdown */
/* Fix overlap: the catalog toolbar lives inside .panel-header (z-index:2), which
   traps this menu below the sticky table header (thead th z-index:10, hoisted into
   the .panel stacking context). Lift the catalog header above the table so the
   open menu paints over the grid. Scoped to #panel-catalog to avoid touching
   other panels. */
#panel-catalog .panel-header {
  z-index: 60;
}

.cat-ai-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.cat-ai-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #1C1C26;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .7);
  z-index: 1000;
  min-width: 260px;
  overflow: hidden;
}

.cat-ai-menu-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  font-size: 13px;
  font-family: var(--font);
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.cat-ai-menu-item:last-child {
  border-bottom: none;
}

.cat-ai-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Drawer form field */
.cat-field {
  margin-bottom: 14px;
}

.cat-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cat-field input,
.cat-field textarea,
.cat-field select {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  box-sizing: border-box;
  resize: vertical;
}

.cat-field input:focus,
.cat-field textarea:focus,
.cat-field select:focus {
  outline: none;
  border-color: var(--accent-text);
  background: rgba(255, 255, 255, 0.08);
}

/* Completeness breakdown in drawer */
.cat-breakdown-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.cat-breakdown-check {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.cat-breakdown-check.filled {
  background: var(--success-light);
  color: var(--success);
}

.cat-breakdown-check.empty {
  background: var(--danger-light);
  color: var(--danger);
}

/* Inline completeness mini-bar in table */
.cat-completeness-mini {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cat-completeness-mini-bar {
  height: 4px;
  border-radius: var(--radius-xs);
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.cat-completeness-mini-fill {
  height: 100%;
  border-radius: var(--radius-xs);
}

@media (max-width: 900px) {
  .cat-product-drawer {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    height: 60vh;
    position: fixed;
    bottom: 0;
    top: auto;
  }
}

/* ─── Catalog split-view ─────────────────────────────────────── */
.cat-ai-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.cat-split {
  display: flex;
  gap: 0;
  height: calc(100vh - 260px);
  min-height: 400px;
  overflow: hidden;
}

.cat-sidebar {
  width: 220px;
  min-width: 180px;
  max-width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 4px 0;
  transition: width .18s ease;
}

.cat-sidebar.collapsed {
  width: 0 !important;
  min-width: 0;
  overflow: hidden;
  border-right: none;
  padding: 0;
}

.cat-sidebar-header {
  display: flex;
  align-items: center;
  padding: 4px 8px 6px;
}

/* Always-visible toggle tab between sidebar and main */
.cat-sidebar-toggle {
  flex-shrink: 0;
  width: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  padding: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.cat-sidebar-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.cat-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cat-filter-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  flex-wrap: wrap;
  align-items: center;
}

/* Folder tree items */
.cat-folder-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.cat-folder-item:hover {
  background: var(--hover);
}

.cat-folder-item.active {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-text);
  font-weight: 600;
}

.cat-folder-item.multi-selected {
  background: rgba(99, 102, 241, 0.18);
  outline: 1px solid rgba(99, 102, 241, 0.45);
}

.cat-folder-item .cat-folder-caret {
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 12px;
  text-align: center;
  cursor: pointer;
}

.cat-folder-item .cat-folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-folder-item .cat-folder-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cat-folder-children {
  overflow: hidden;
}

.cat-folder-children.collapsed {
  display: none;
}

.cat-folder-all-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.cat-folder-all-item:hover {
  color: var(--text);
}

.cat-folder-all-item.active {
  color: var(--accent-text);
}

/* Tag tooltip */
.tag-cell {
  position: relative;
}

.tag-cell-preview {
  display: block;
  max-width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  cursor: default;
}

.tag-popup {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 300;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  min-width: 180px;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.tag-popup .tag-row {
  font-size: 12px;
  padding: 2px 0;
  display: flex;
  gap: 6px;
}

.tag-popup .tag-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.tag-popup .tag-val {
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

.tag-cell:hover .tag-popup {
  display: block;
}

/* Product thumbnail */
.cat-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
  display: block;
  border: 1px solid var(--border);
}

.cat-thumb-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  border: 1px dashed var(--border);
}

/* Restructure plan panel */
/* cat-review-panel is always hidden — all content uses #cat-plan-modal-portal via JS */
#cat-review-panel {
  display: none !important;
}

.cat-plan-modal {
  background-color: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
  width: min(960px, 96vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
}

.cat-plan-header {
  padding: 12px 16px;
  background-color: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  color: var(--text);
}

.cat-plan-sg-new {
  font-size: 10px;
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
  border-radius: var(--radius-md);
  padding: 1px 7px;
}

/* ── scrollable resizable table inside modal ── */
.cat-plan-table-wrap {
  flex: 1;
  overflow: auto;
  background-color: var(--bg-mid);
}

.cat-plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
  background-color: var(--bg-mid);
}

.cat-plan-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bg);
  padding: 0;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: relative;
  /* for resizer handle */
}

.cat-plan-th-inner {
  padding: 9px 14px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 3;
}

.col-resizer:hover,
.col-resizer.resizing {
  background: var(--accent);
  opacity: .6;
}

.cat-plan-tbl-nom {
  padding: 7px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-plan-tbl-grp {
  padding: 7px 14px;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-plan-row-keep td {
  opacity: .45;
}

.cat-plan-table tbody tr:hover .cat-plan-tbl-nom,
.cat-plan-table tbody tr:hover .cat-plan-tbl-grp {
  background-color: var(--hover);
}

/* Audit recommendations */
.cat-audit-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cat-audit-priority {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-md);
}

.cat-audit-priority.high {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.cat-audit-priority.medium {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.cat-audit-priority.low {
  background: rgba(107, 114, 128, 0.18);
  color: #9ca3af;
}

/* Duplicate groups finder */
.dedup-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.dedup-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.dedup-name {
  font-weight: 600;
  font-size: 13px;
}

.dedup-groups-list {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dedup-group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
}

.dedup-group-row:hover {
  background: var(--hover);
}

/* ═══════════════════════════════════════════════════════════════
   USER BADGE — header top-right avatar + dropdown
   ═══════════════════════════════════════════════════════════════ */

.user-badge {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 9998;
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  letter-spacing: 0;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.20);
}

.user-avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35);
}

.user-dropdown {
  position: fixed;
  top: calc(var(--header-h) + 6px);
  right: 16px;
  min-width: 200px;
  background: #1e1e28;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(var(--accent-rgb), 0.12);
  padding: 6px;
  display: none;
  z-index: 1000;
  animation: dropdownFadeIn 0.18s ease;
}

/* dropdown visibility now controlled via inline style by JS */

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.user-dropdown-info {
  padding: 8px 10px 10px;
}

.user-dropdown-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.user-dropdown-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-xs);
  text-align: left;
  transition: background 0.12s;
}

.user-dropdown-item:hover {
  background: var(--surface-elevated);
}

.user-dropdown-item.danger {
  color: var(--danger);
}

.user-dropdown-item.danger:hover {
  background: var(--danger-light);
}

.user-dropdown-version {
  padding: 6px 14px 8px;
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  opacity: 0.5;
  user-select: text;
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════════
   ADMIN PANEL — Apple-style layout
   ═══════════════════════════════════════════════════════════════ */

#panel-admin {
  padding: 0;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100%;
}

/* ── Sidebar ── */
.admin-sidebar {
  background: var(--bg-mid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  gap: 4px;
  overflow-y: auto;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.admin-sidebar-brand svg {
  color: var(--accent-text);
  flex-shrink: 0;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-md);
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
  letter-spacing: -0.01em;
}

.admin-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.admin-nav-item:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.admin-nav-item.active {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.admin-nav-item.active svg {
  opacity: 1;
  color: var(--accent-text);
}

/* ── Main area ── */
.admin-main {
  overflow-y: auto;
  padding: 32px 36px;
}

.admin-view {
  display: block;
}

.admin-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.admin-view-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0;
}

.admin-view-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ── Users grid (card list) ── */
.admin-users-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-user-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.admin-user-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: 0;
}

.admin-user-card-info {
  min-width: 0;
}

.admin-user-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.admin-user-card-username {
  font-size: 12px;
  color: var(--text-muted);
}

.role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.role-badge.superadmin {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-text);
}

.role-badge.admin {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.role-badge.analyst {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.role-badge.viewer {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

.role-badge.custom {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.admin-user-card-inactive .admin-user-card-name {
  opacity: 0.45;
}

.admin-user-inactive-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 69, 58, 0.12);
  color: var(--danger);
  font-weight: 700;
}

.admin-user-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.admin-icon-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}

.admin-icon-btn.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(255, 69, 58, 0.25);
}

/* ── Roles configurator ── */
.admin-roles-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-role-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.admin-role-card.editing {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 1px var(--accent-ring);
}

.admin-role-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}

.admin-role-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.admin-role-card-info {
  flex: 1;
  min-width: 0;
}

.admin-role-card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-role-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-role-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.admin-role-custom-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  letter-spacing: 0.04em;
}

.admin-role-locked-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-text);
  letter-spacing: 0.04em;
}

.admin-role-modules-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 20px 16px;
}

.admin-role-module-chip {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}

.admin-role-all-chip {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.20);
  border-radius: var(--radius-xs);
  color: var(--accent-text);
  font-weight: 600;
}

/* ── Inline role editor ── */
.admin-role-editor {
  border-top: 1px solid var(--border);
  padding: 20px;
  background: rgba(255, 255, 255, 0.015);
  display: none;
}

.admin-role-card.editing .admin-role-editor {
  display: block;
}

.admin-role-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-role-editor-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  flex: 1;
}

.admin-role-editor-sel-count {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-role-editor-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  margin-bottom: 20px;
}

.admin-role-module-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}

.admin-role-module-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface-elevated);
}

.admin-role-module-toggle.checked {
  border-color: rgba(var(--accent-rgb), 0.30);
  background: var(--accent-subtle);
}

.admin-role-module-toggle-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-role-module-toggle.checked .admin-role-module-toggle-name {
  color: var(--text);
}

.admin-role-module-toggle-check {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border-strong);
  background: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
  font-size: 11px;
  color: transparent;
}

.admin-role-module-toggle.checked .admin-role-module-toggle-check {
  background: var(--accent);
  border-color: var(--accent-text);
  color: var(--primary-text);
}

.admin-role-editor-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.admin-role-editor-footer-left {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
}

.admin-role-editor-error {
  font-size: 12px;
  color: var(--danger);
}

/* ── Modal ── */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.admin-modal {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-premium);
  width: 540px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-modal-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.admin-modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.admin-modal-close:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.admin-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Form elements ── */
.admin-form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 12px;
}

.admin-form-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.admin-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-input:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.admin-input::placeholder {
  color: var(--text-light);
}

/* ── Role picker ── */
.admin-role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-role-option {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.admin-role-option:hover {
  border-color: var(--border-strong);
  background: var(--surface-elevated);
}

.admin-role-option.selected {
  border-color: var(--accent-text);
  background: var(--accent-subtle);
}

.admin-role-option-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.admin-role-option.selected .admin-role-option-name {
  color: var(--accent-text);
}

.admin-role-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Module overrides section ── */
.admin-module-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.admin-toggle-label {
  font-size: 13px;
  color: var(--text-muted);
}

.admin-toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.admin-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-elevated);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--border);
}

.admin-toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.admin-toggle-switch input:checked+.admin-toggle-slider {
  background: var(--accent);
  border-color: var(--accent-text);
}

.admin-toggle-switch input:checked+.admin-toggle-slider::after {
  transform: translateX(18px);
  background: #0D0D11;
}

.admin-modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.admin-module-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 8px;
}

.admin-module-item-name {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-module-item .admin-toggle-switch {
  width: 34px;
  height: 20px;
  flex-shrink: 0;
}

.admin-module-item .admin-toggle-slider::after {
  width: 14px;
  height: 14px;
}

.admin-module-item .admin-toggle-switch input:checked+.admin-toggle-slider::after {
  transform: translateX(14px);
}

.admin-modules-hint {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.admin-form-error {
  font-size: 12px;
  color: var(--danger);
  flex: 1;
  margin-right: auto;
}

/* ── Last login text ── */
.admin-user-last-login {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ─ 900px: планшеты / небольшие экраны
   ─ 480px: смартфоны
   ─ bottom-nav: нижняя панель навигации (только мобильные)
   ═══════════════════════════════════════════════════════════════ */

/* ─── Планшеты (≤900px) — расширяем существующие правила ─────── */
@media (max-width: 900px) {

  /* Сплит-вью «Номенклатура»: переходим в колоночный режим */
  .cat-split {
    flex-direction: column;
    height: auto;
    min-height: unset;
  }

  .cat-sidebar {
    width: 100% !important;
    max-width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .cat-sidebar.collapsed {
    max-height: 0;
    border-bottom: none;
    padding: 0;
  }

  .cat-sidebar-toggle {
    display: none;
    /* на планшете прячем вертикальный тоггл */
  }

  /* Таблицы: разрешаем горизонтальный скролл внутри контейнера */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - var(--header-h) - 200px);
  }

  /* Шапка: logo + кнопки выстраиваем в две строки при нехватке места */
  .app-header {
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 6px;
  }

  /* Хедер-правая часть: убираем лейбл магазина */
  .store-switcher-label {
    display: none;
  }

  .store-switcher {
    min-width: 120px;
    max-width: 160px;
  }

  /* Трёхколоночные графики уже сворачиваются (уже есть), добавим двухколоночные */
  .kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}

/* ─── Смартфоны (≤480px) ──────────────────────────────────────── */
@media (max-width: 480px) {

  /* Высота через % (не dvh) — стабильна, не меняется при скрытии/показе URL-бара */
  html, body {
    height: 100%;
    overflow: hidden;
  }

  /* Хедер: flex: 0 0 auto — запрещаем расти/сжиматься.
     position: relative вместо sticky — внутри fixed-контейнера sticky
     ведёт себя непредсказуемо в iOS Safari и может сдвигать layout. */
  .app-header {
    padding: 0 8px;
    gap: 4px;
    min-height: 48px;
    flex: 0 0 auto;
    position: relative;
  }

  .app-logo {
    font-size: 11px;
    padding: 6px 12px;
  }

  .app-logo-img {
    height: 28px;
  }

  /* Верхний таб-бар скрыт: все модули вынесены в выезжающий сайдбар.
     #main-nav остаётся в DOM (источник списка табов для сайдбара). */
  .app-header nav#main-nav {
    display: none;
  }

  /* Шапка-справа: оставляем переключатель магазина и юзер-бейдж доступными,
     прячем только второстепенные контролы (размер страницы, статус-индикатор). */
  .header-right {
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .header-right #page-size-select,
  .header-right #status-dot,
  .header-right #status-text {
    display: none;
  }

  /* аватарка теперь в нижней панели; !important перебивает inline display:flex,
     который проставляет _updateUserBadge */
  .header-right #user-badge {
    display: none !important;
  }

  .store-switcher {
    min-width: 96px;
    max-width: 130px;
  }

  .app-content {
    padding: 10px 8px 0;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* Spacer вместо padding-bottom — iOS Safari игнорирует padding-bottom
     в overflow:scroll контейнерах при расчёте scroll-height */
  .mobile-nav-spacer {
    display: block;
    height: calc(60px + env(safe-area-inset-bottom, 0px) + 24px);
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
  }

  /* KPI-карточки: 2 в ряд */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* ─── Шапка модуля: колоночная раскладка, контролы на всю ширину ─── */
  .panel {
    margin-bottom: 14px;
    border-radius: var(--radius-lg);
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 14px 12px;
  }

  /* Сбрасываем inline-отступы (margin-left:auto / 12px), ломающие колонку */
  .panel-header>* {
    margin-left: 0 !important;
  }

  .panel-title {
    font-size: 15.5px;
    flex: 0 0 auto;
    padding-right: 60px;
    /* место под бейдж-счётчик в углу */
    line-height: 1.25;
  }

  /* Бейдж-счётчик — в правый верхний угол шапки */
  .panel-header>.badge {
    position: absolute;
    top: 14px;
    right: 14px;
  }

  .panel-header .meta-label {
    white-space: normal;
    font-size: 11.5px;
  }

  /* Сегментированный переключатель — на всю ширину, равные доли */
  .panel-header .seg-ctrl {
    display: flex;
    width: 100%;
  }

  .panel-header .seg-ctrl .seg-btn {
    flex: 1;
    text-align: center;
    padding: 9px 8px;
  }

  /* Чекбоксы-переключатели — каждый своей строкой, крупный тап-таргет */
  .panel-header .toggle-label {
    width: 100%;
    padding: 3px 0;
    font-size: 13px;
  }

  /* Тулбар в шапке: колонка, всё на всю ширину */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 0;
    width: 100%;
  }

  .search-wrap {
    max-width: 100%;
    min-width: 0;
    flex: none;
    width: 100%;
  }

  /* Кнопки — на всю ширину, удобный тап-таргет */
  .panel-header .btn,
  .toolbar .btn {
    width: 100%;
    justify-content: center;
    padding: 11px 14px;
    font-size: 13px;
  }

  /* Инфо-строка под шапкой: компактнее */
  .info-row {
    gap: 8px 14px;
    padding: 10px 14px;
  }

  .info-item {
    font-size: 11.5px;
  }

  /* ─── Таблицы: горизонтальный скролл, компактные ячейки ─── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100dvh - 48px - 60px - 110px);
    /* header + bottom-nav + шапка */
    border-radius: 0 0 16px 16px;
  }

  table {
    font-size: 11.5px;
  }

  thead th {
    padding: 7px 8px;
    font-size: 9.5px;
    letter-spacing: .3px;
  }

  tbody td {
    padding: 8px 8px;
  }

  /* «Список на скидку»: по умолчанию её колонки сжимались под ширину экрана
     (текст переносился), и таблица не скроллилась. Заставляем её занимать
     натуральную ширину контента → выходит за экран и свайпается вбок,
     как в остальных модулях с таблицами. */
  #panel-discount .table-wrap>table {
    min-width: max-content;
  }

  /* Фильтр-бар: горизонтальный скролл, не переносить */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px;
    gap: 6px;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  /* Карточка товара: на весь экран */
  .pcard-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  /* Сплит-вью «Номенклатура»: боковая панель — выезжает снизу */
  .cat-sidebar {
    max-height: 45vh;
    overflow-y: auto;
  }

  /* Пагинация: компактнее */
  .page-btns {
    gap: 2px;
  }

  .pagination {
    padding: 8px 10px;
    gap: 6px;
  }

  /* Toast уведомления: на всю ширину снизу */
  #toast-container {
    bottom: 68px;
    /* над bottom-nav */
    right: 8px;
    left: 8px;
  }

  .toast {
    font-size: 13px;
  }

  /* Модальные окна (общие): растягиваем на почти весь экран */
  .modal-content,
  .modal-box {
    width: 96vw;
    max-width: 96vw;
    max-height: 90dvh;
    border-radius: var(--radius);
  }

  /* Обзор: drilldown в колонку */
  .overview-drilldown {
    flex-direction: column;
    gap: 8px;
  }

  /* Скрываем второстепенные колонки в таблицах (по классу) */
  .col-hide-mobile {
    display: none !important;
  }
}

/* ─── Bottom Navigation (только мобильные) ────────────────────── */
.mobile-nav {
  display: none;
  /* скрыта на десктопе */
}

@media (max-width: 480px) {
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(13, 13, 17, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: stretch;
    justify-content: stretch;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 4px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.02em;
  }

  .mobile-nav-item:active {
    background: rgba(255, 255, 255, 0.05);
  }

  .mobile-nav-item.active {
    color: var(--accent-text);
  }

  .mobile-nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 9.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 56px;
  }

  /* Аватарка в нижней панели (инициалы + цвет проставляются из JS) */
  .mobile-nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    background: var(--accent);
    color: #000;
  }

  /* Дропдаун пользователя: над нижней панелью, ближе к аватарке справа */
  .user-dropdown {
    top: auto !important;
    bottom: 72px !important;
    right: 8px !important;
    left: auto !important;
  }
}

/* ─── Mobile Sidebar (выезжающее меню всех модулей) ───────────── */
.mobile-sidebar,
.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 480px) {
  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .mobile-sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 78vw;
    max-width: 320px;
    z-index: 260;
    background: rgba(18, 18, 24, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-sidebar.open {
    transform: translateX(0);
  }

  .mobile-sidebar-header {
    padding: 18px 18px 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
  }

  .mobile-sidebar-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s;
  }

  .mobile-sidebar-item:active {
    background: rgba(255, 255, 255, 0.06);
  }

  .mobile-sidebar-item.active {
    background: var(--accent-muted);
    color: var(--accent-text);
  }

  .mobile-sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
  }

  .mobile-sidebar-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── Campaign Badges & Nom-Camp Panel ── */
.nom-camp-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  line-height: 1.6;
  vertical-align: middle;
  margin-left: 4px;
  transition: opacity .15s;
}

.nom-camp-badge:hover {
  opacity: .8;
}

.nom-camp-badge.has-camps {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.nom-camp-badge.no-camps {
  background: transparent;
  border-color: #d1d5db;
  color: #6b7280;
}

.nom-camp-badge.no-camps:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.nom-camp-panel {
  position: absolute;
  z-index: 2000;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .6);
  min-width: 260px;
  max-width: 320px;
}

.nom-camp-panel-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}

.nom-camp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.nom-camp-row:last-of-type {
  border-bottom: none;
}

.nom-camp-row-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nom-camp-row-disc {
  color: #f87171;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.nom-camp-row-status {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.nom-camp-row-status.active {
  background: rgba(34, 197, 94, .15);
  color: #4ade80;
}

.nom-camp-row-status.draft {
  background: var(--surface-2);
  color: var(--text-muted);
}

.nom-camp-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: #ef4444;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

.nom-camp-remove:hover {
  color: #f87171;
}

.nom-camp-panel-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Campaign item editor */
#cie-items-tbody tr {
  border-bottom: 1px solid var(--border);
}

#cie-items-tbody tr:hover {
  background: var(--surface-elevated);
}

#cie-items-tbody td {
  padding: 6px 4px;
  vertical-align: middle;
}

.cie-disc-input {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  text-align: center;
  background: var(--surface-2);
  color: var(--text);
}

.cie-remove-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: #ef4444;
  font-size: 16px;
  padding: 0 4px;
}

.cie-remove-btn:hover {
  color: #f87171;
}

.cie-search-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.cie-search-item:hover {
  background: var(--surface-elevated);
}

.cie-search-item:last-child {
  border-bottom: none;
}

/* Journal overlay */
.journal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(0, 0, 0, .6);
  align-items: center;
  justify-content: center;
}

.journal-panel {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: min(780px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .7);
}

.journal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.journal-title {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}

.journal-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.journal-tab {
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-xs);
}

.journal-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.journal-tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.journal-close-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.journal-close-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.journal-body {
  overflow-y: auto;
  padding: 10px 0;
  flex: 1;
}

.journal-loading,
.journal-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 18px;
  text-align: center;
}

.journal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.journal-row:hover {
  background: var(--surface-2);
}

.journal-row-critical {
  background: rgba(239, 68, 68, .10);
  border-left: 3px solid #ef4444;
  padding-left: 15px;
}

.journal-row-critical:hover {
  background: rgba(239, 68, 68, .16);
}

.journal-row-critical .journal-act {
  color: #f87171;
}

.journal-ts {
  color: var(--text-muted);
  white-space: nowrap;
  font-family: monospace;
  flex-shrink: 0;
}

.journal-mod {
  background: rgba(99, 102, 241, .2);
  color: #818cf8;
  border-radius: var(--radius-xs);
  padding: 1px 6px;
  font-size: 11px;
  flex-shrink: 0;
}

.journal-act {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.journal-det {
  color: var(--text-muted);
  font-size: 11px;
  font-family: monospace;
}

.journal-change {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 11px;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
}

.journal-change b {
  color: var(--text);
  font-weight: 600;
}

.journal-from {
  color: #f87171;
  text-decoration: line-through;
  opacity: .85;
}

.journal-to {
  color: #4ade80;
}

.journal-arrow {
  color: var(--text-muted);
}

.journal-empty-val {
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Accessibility: respect reduced-motion preference ───────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Stop the global progress shimmer and spinner from looping. */
  #global-progress-bar {
    animation: none !important;
  }
}

/* ─── Dropdown item icons (Настройки / Администрирование / Выйти) ─── */
.user-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.85;
}

/* ─── Admin panel: адаптив для планшетов и телефонов ─── */
@media (max-width: 760px) {

  /* Сайдбар администрирования становится горизонтальной полосой сверху */
  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  .admin-sidebar {
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 8px;
    overflow-x: auto;
  }

  .admin-sidebar-brand {
    display: none;
    /* экономим место — заголовок повторяется в шапке вида */
  }

  .admin-sidebar-nav {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
  }

  .admin-nav-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .admin-main {
    padding: 18px 14px;
  }

  .admin-view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }

  .admin-view-title {
    font-size: 18px;
  }

  .admin-view-header .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {

  /* Карточка пользователя: действия переносятся под информацию */
  .admin-user-card {
    grid-template-columns: 40px 1fr;
    grid-template-areas: "avatar info" "actions actions";
    gap: 10px 12px;
    padding: 12px 14px;
  }

  .admin-user-card-avatar {
    grid-area: avatar;
  }

  .admin-user-card-info {
    grid-area: info;
    min-width: 0;
  }

  .admin-user-card-actions {
    grid-area: actions;
    justify-content: flex-end;
  }

  /* Модалки занимают почти весь экран, выше нижней панели */
  .admin-modal {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 80px);
    margin: 0 8px;
  }

  .admin-modal-overlay {
    align-items: flex-end;
    padding-bottom: 70px;
  }

  .admin-modules-grid,
  #admin-role-modules-grid {
    grid-template-columns: 1fr;
  }

  .admin-role-editor-modules {
    grid-template-columns: 1fr 1fr;
  }

  .admin-role-card-actions {
    flex-wrap: wrap;
  }
}

/* ─── Sync indicator button ──────────────────────────────────────────── */
.sync-indicator-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-ring);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.sync-indicator-btn:hover {
  background: var(--accent-subtle);
}

/* ─── Sync log modal ─────────────────────────────────────────────────── */
.sync-log-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9010;
}

.sync-log-modal {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(740px, 96vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.sync-log-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sync-log-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.sync-log-close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sync-log-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

.sync-log-section {
  margin-bottom: 18px;
}

.sync-log-section-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}

.sync-log-key {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.sync-log-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.sync-log-badge-ok {
  background: rgba(34, 197, 94, .12);
  color: #22c55e;
}

.sync-log-badge-error {
  background: rgba(239, 68, 68, .12);
  color: #ef4444;
}

.sync-log-badge-running {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.sync-log-time {
  color: var(--text-muted);
  font-size: 11px;
}

.sync-log-pre {
  background: var(--surface-2, rgba(0, 0, 0, .18));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.55;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
  margin: 0;
}

.sync-log-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 0;
  text-align: center;
}

/* ── Marketing Hub ──────────────────────────────────────────────────── */
.mkt-nav-bar {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4) 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.mkt-tab-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px 8px 0 0;
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}

.mkt-tab-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.mkt-tab-btn.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  background: var(--accent-muted);
}

.mkt-sub {
  padding: var(--space-4);
}

/* Promo plates: Скидка дня / Другая акция (OMN-14) */
.mkt-promo-plates {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mkt-promo-plate {
  flex: 1 1 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.mkt-promo-plate:hover { background: var(--surface-2); color: var(--text); }
.mkt-promo-plate.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent-text);
}
.mkt-promo-plate .vic { width: 22px; height: 22px; }
.mkt-promo-plate-text { display: flex; flex-direction: column; line-height: 1.25; }
.mkt-promo-plate-title { font-weight: var(--fw-semibold, 600); font-size: var(--text-base); }
.mkt-promo-plate-sub { font-size: 11px; opacity: 0.8; }

/* Promo sub-panel: allow scroll when content (e.g. channel settings) overflows */
#panel-marketing.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.mkt-nav-bar {
  flex-shrink: 0;
}

/* All marketing sub-panels fill remaining space and scroll independently */
.mkt-sub {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ── Marketing KPI grid: consistent margins ── */
.mkt-kpi-grid.kpi-grid {
  margin: var(--space-3) 0 var(--space-4);
}

/* ── Module cards ── */
.mkt-module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.mkt-card {
  padding: var(--space-4);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow var(--dur), transform var(--dur-fast);
  border: 1px solid var(--border);
}

.mkt-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.mkt-card-icon {
  font-size: 28px;
  margin-bottom: var(--space-2);
  display: block;
}

.mkt-card-title {
  font-size: 15px;
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-1);
}

.mkt-card-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.4;
}

.mkt-card-accent {
  border: 1.5px solid var(--accent);
}

/* ── Promo: two-column layout ── */
.mkt-promo-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  padding: var(--space-4) 0;
}

.mkt-promo-field {
  margin-bottom: var(--space-4);
}

.mkt-promo-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  display: block;
}

.mkt-promo-input {
  width: 100%;
}

.mkt-promo-price-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2-5, 10px);
}

.mkt-promo-readonly {
  background: var(--surface-2);
}

/* ── Promo photo drop ── */
.promo-photo-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm, 10px);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-photo-drop:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.promo-photo-drop.has-photo {
  border-style: solid;
  padding: var(--space-2);
}

/* ── Promo channel list ── */
.mkt-promo-channels {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.mkt-promo-channel {
  display: flex;
  align-items: center;
  gap: var(--space-1-5, 6px);
  cursor: pointer;
  font-size: var(--text-base);
}

.mkt-promo-channel-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Promo channel settings grid ── */
.promo-ch-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2, 8px);
}

.promo-ch-settings-block {
  padding: var(--space-2, 8px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.promo-ch-settings-header {
  margin-bottom: var(--space-1-5, 6px);
  padding-bottom: var(--space-1, 4px);
  border-bottom: 1px solid var(--border);
}

.promo-ch-settings-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: block;
}

/* ── Promo preview box ── */
.mkt-promo-preview-box {
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  padding: var(--space-3);
  background: var(--surface-2);
}

.mkt-promo-preview-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1-5, 6px);
}

.mkt-promo-preview-text {
  font-size: var(--text-base);
  line-height: 1.6;
  white-space: pre-line;
}

/* ── Promo publish button ── */
.mkt-promo-publish-btn {
  width: 100%;
  justify-content: center;
}

/* ── Promo publish status ── */
.mkt-promo-status {
  margin-top: var(--space-2);
  font-size: var(--text-base);
}

/* ── Promo selected product card ── */
.mkt-promo-selected {
  margin-top: var(--space-2);
  display: none;
}

.mkt-promo-selected .kpi-card {
  padding: 10px 14px;
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.mkt-promo-selected-name {
  flex: 1;
}

.mkt-promo-selected-name>div:first-child {
  font-weight: var(--fw-bold);
  font-size: var(--text-md);
}

.mkt-promo-selected-name>div:last-child {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── Marketing Discount table head ── */
.mkt-table-th {
  padding: 6px 8px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.mkt-table-th-left {
  text-align: left;
}

.mkt-table-th-right {
  text-align: right;
}

.mkt-table-th-center {
  text-align: center;
}

/* ── Marketing Hub — Desktop table-wrap (removed; discount now uses .table-wrap) ── */

/* ── Marketing Hub — Mobile (≤480px) ────────────────────────────── */
@media (max-width: 480px) {

  /* Sub-tab nav: nowrap + horizontal scroll */
  .mkt-nav-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    gap: 0;
    border-bottom: 2px solid var(--border);
  }

  .mkt-nav-bar::-webkit-scrollbar {
    display: none;
  }

  .mkt-tab-btn {
    flex-shrink: 0;
    padding: 12px 16px;
    font-size: 12px;
    min-height: 44px;
    /* iOS tap target */
    border-radius: 0;
    white-space: nowrap;
    touch-action: manipulation;
  }

  /* Panels outside <main> (sentiment, weather, realestate, admin, marketing) are
     direct flex children of #app-shell competing with main. When active, position
     them absolutely so they overlay main without collapsing it to ~0px. */
  #panel-sentiment.active,
  #panel-weather.active,
  #panel-realestate.active,
  #panel-admin.active,
  #panel-marketing.active {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    overflow: hidden;
    background: var(--bg);
  }

  .mkt-sub {
    padding: var(--space-2) var(--space-2) calc(60px + env(safe-area-inset-bottom, 0px) + 24px);
  }

  /* Module cards: single column on phone */
  .mkt-module-cards {
    grid-template-columns: 1fr !important;
    gap: var(--space-2-5, 10px) !important;
  }

  .mkt-card {
    padding: var(--space-3);
    touch-action: manipulation;
  }

  .mkt-card-icon {
    font-size: 22px;
    margin-bottom: var(--space-1);
  }

  .mkt-card-title {
    font-size: 14px;
  }

  /* KPI grid inside marketing: 2 cols */
  #mkt-kpi,
  #mkt-camp-kpi,
  #mkt-md-kpi {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-2) !important;
  }

  /* Discount table: no nested scroll — let app-content scroll */
  .mkt-disc-wrap {
    max-height: none !important;
    overflow-y: visible !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mkt-disc-wrap>table {
    min-width: max-content;
  }

  /* Campaigns list cards */
  #mkt-camp-list .panel {
    margin-bottom: var(--space-2);
  }

  #mkt-camp-list .panel>div {
    font-size: 12px;
  }

  /* Promo: single column layout */
  .mkt-promo-cols {
    grid-template-columns: 1fr !important;
    gap: var(--space-3) !important;
    padding: var(--space-2) 0 !important;
  }

  /* Channel settings: single column on mobile */
  .promo-ch-settings-grid {
    grid-template-columns: 1fr !important;
  }

  /* Promo price row: keep side by side */
  .mkt-promo-price-row {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-2) !important;
  }

  /* Photo drop zone: smaller on mobile */
  .promo-photo-drop {
    min-height: 90px;
    padding: var(--space-4);
  }

  /* Channels checkboxes: bigger tap area */
  .mkt-promo-channel {
    padding: var(--space-2) 0;
    font-size: var(--text-md);
  }

  #mkt-sub-promo input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  /* Desktop dropdown hidden on mobile — use bottom-sheet picker instead */
  #promo-nom-dropdown { display: none !important; }
  .promo-nom-desktop-only { display: none !important; }
  .promo-nom-mobile-only  { display: flex !important; }
}

/* ── Nom picker trigger button (mobile) ─────────────────────── */
.promo-nom-trigger-btn {
  display: none; /* hidden on desktop */
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--surface-2, rgba(255,255,255,.06));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.promo-nom-trigger-btn:active {
  background: var(--accent-muted);
  border-color: var(--accent);
}
.promo-nom-trigger-btn span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Bottom-sheet picker modal ───────────────────────────────── */
.promo-picker-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.55);
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.promo-picker-modal.open .promo-picker-sheet {
  transform: translateY(0);
}

.promo-picker-sheet {
  width: 100%;
  max-height: 88dvh;
  background: var(--surface, #18181c);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,1,.58,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
}

.promo-picker-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,.2);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.promo-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.promo-picker-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.promo-picker-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.promo-picker-search-wrap {
  position: relative;
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.promo-picker-search-icon {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.promo-picker-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px 10px 38px;
  background: var(--surface-2, rgba(255,255,255,.07));
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.promo-picker-search-input:focus {
  border-color: var(--accent);
}
.promo-picker-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.promo-picker-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.promo-picker-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.promo-picker-item:active {
  background: var(--accent-muted);
}

.promo-picker-item-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.promo-picker-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.promo-picker-empty {
  padding: 40px 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Marketing Hub — Tablet (480–900px) ─────────────────────── */
@media (min-width: 481px) and (max-width: 900px) {
  .mkt-nav-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: var(--space-2) var(--space-3) 0;
  }

  .mkt-nav-bar::-webkit-scrollbar {
    display: none;
  }

  .mkt-tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .mkt-promo-cols {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
  }
}

/* ── Price type selector row ─────────────────────────────────── */
.price-type-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
}

.price-type-wrap .price-type-select {
  flex: 1;
  min-width: 0;
}

.price-type-wrap .price-type-reload {
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 16px;
  line-height: 1;
}