/* ==========================================================================
   Material Design 3 — Design Tokens (CattleSales)
   ========================================================================== */

:root {
  /* === Primary === */
  --md-sys-color-primary: #1B743E;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #A4F4C0;
  --md-sys-color-on-primary-container: #00210E;

  /* === Secondary (CattleSales olive) === */
  --md-sys-color-secondary: #C2BF6C;
  --md-sys-color-secondary-container: rgba(194, 191, 108, 0.14);
  --md-sys-color-secondary-container-solid: #EBEACF;
  --md-sys-color-on-secondary: #2B2A1A;
  --md-sys-color-on-secondary-container: #1A1A0A;

  /* === Surface (warm cream-green, tonal-tinted от primary #1B743E) === */
  --md-sys-color-surface: #FBFCF6;
  --md-sys-color-on-surface: #1A1C18;
  --md-sys-color-surface-dim: #DADDD4;
  --md-sys-color-surface-bright: #FBFCF6;
  --md-sys-color-surface-variant: #E4E8DC;
  --md-sys-color-on-surface-variant: #3F4A3F;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #F5F8EF;
  --md-sys-color-surface-container: #EFF2E9;
  --md-sys-color-surface-container-high: #E9ECE3;
  --md-sys-color-surface-container-highest: #E4E7DE;
  --md-sys-color-surface-tint: #1B743E;

  /* === Outline (tinted greenish-neutral) === */
  --md-sys-color-outline: #707867;
  --md-sys-color-outline-variant: #C0C8B8;

  /* === Error === */
  --md-sys-color-error: #B3261E;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #F9DEDC;

  /* === Background (cream) === */
  --md-sys-color-background: #FFFBEE;
  --md-sys-color-on-background: #1A1C18;

  /* === Brand (CattleSales) === */
  --brand-ink: #1A1C18;
  --brand-muted: #5E6157;
  --brand-cream: #FFFBEE;
  --brand-olive: #C2BF6C;
  --brand-green: #1B743E;

  /* === Elevation shadows (soft & diffused) === */
  --md-sys-elevation-0: none;
  --md-sys-elevation-1: 0px 2px 8px rgba(0,0,0,0.08), 0px 1px 4px rgba(0,0,0,0.06);
  --md-sys-elevation-2: 0px 4px 16px rgba(0,0,0,0.10), 0px 2px 6px rgba(0,0,0,0.06);
  --md-sys-elevation-3: 0px 8px 24px rgba(0,0,0,0.12), 0px 2px 8px rgba(0,0,0,0.08);

  /* === Typography · Roboto Flex (variable font, opsz+wght) === */
  --font-sans: 'Roboto Flex', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  --md-sys-typescale-display-large: 800 57px/60px var(--font-sans);
  --md-sys-typescale-headline-large: 800 36px/42px var(--font-sans);
  --md-sys-typescale-headline-medium: 700 28px/34px var(--font-sans);
  --md-sys-typescale-title-large: 700 22px/28px var(--font-sans);
  --md-sys-typescale-title-medium: 600 16px/22px var(--font-sans);
  --md-sys-typescale-body-large: 400 16px/24px var(--font-sans);
  --md-sys-typescale-body-medium: 400 14px/20px var(--font-sans);
  --md-sys-typescale-body-small: 400 12px/16px var(--font-sans);
  --md-sys-typescale-label-large: 600 14px/20px var(--font-sans);
  --md-sys-typescale-label-medium: 500 12px/16px var(--font-sans);
  --md-sys-typescale-label-small: 500 11px/16px var(--font-sans);
  /* Optical sizing + weight axis — M3 Expressive */
  --typo-headline-variation: "opsz" 32, "wght" 800, "GRAD" 0;
  --typo-title-variation: "opsz" 22, "wght" 700, "GRAD" 0;
  --typo-body-variation: "opsz" 16, "wght" 400, "GRAD" 0;

  /* === Shape (friendly rounded — from Figma) === */
  --md-sys-shape-corner-none: 0px;
  --md-sys-shape-corner-extra-small: 12px;
  --md-sys-shape-corner-small: 16px;
  --md-sys-shape-corner-medium: 24px;
  --md-sys-shape-corner-large: 31px;
  --md-sys-shape-corner-extra-large: 31px;
  --md-sys-shape-corner-full: 100px;

  /* === Spacing === */
  --md-sys-spacing-xs: 4px;
  --md-sys-spacing-sm: 8px;
  --md-sys-spacing-md: 16px;
  --md-sys-spacing-lg: 24px;
  --md-sys-spacing-xl: 32px;
  --md-sys-spacing-xxl: 48px;

  /* === Layout === */
  --header-height: 60px;
  --sidebar-width: 240px;
  --bottom-nav-height: 56px;
  --content-max-width: 1200px;

  /* === Motion · M3 Expressive curves === */
  --md-sys-motion-duration-short: 150ms;
  --md-sys-motion-duration-medium: 300ms;
  --md-sys-motion-duration-long: 500ms;
  --md-sys-motion-duration-spring: 650ms;
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-decelerate: cubic-bezier(0, 0, 0, 1);
  /* Expressive spring — overshoot bounce (для hover/focus/page transitions) */
  --md-sys-motion-easing-expressive: cubic-bezier(0.34, 1.56, 0.64, 1);
  --md-sys-motion-easing-emphasized-in: cubic-bezier(0.3, 0, 0.8, 0.15);
  --md-sys-motion-easing-emphasized-out: cubic-bezier(0.05, 0.7, 0.1, 1);

  /* === Success === */
  --md-sys-color-success: #2E7D32;
  --md-sys-color-success-container: #C8E6C9;

  /* === Warning === */
  --md-sys-color-warning: #F57F17;
  --md-sys-color-warning-container: #FFF9C4;

  /* === Glass / acrylic (light default) === */
  --glass-bg: rgba(255, 251, 238, 0.72);
  --glass-border: rgba(194, 191, 108, 0.35);
  --glass-blur: blur(18px) saturate(160%);
  --glass-rim: 0 1px 0 rgba(255,255,255,0.2);
}

/* Dark theme удалена (2026-05-12) — поддерживаем только light, чтобы не
   множить mismatch'ы между темами. color-scheme: light явно, чтобы браузер
   не подкидывал свои dark-style scrollbar/form controls. */
:root { color-scheme: light; }
/* ==========================================================================
   Base Layout — CattleSales M3
   ========================================================================== */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-background);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  font-variation-settings: var(--typo-body-variation);
}

/* Bug fix: атрибут [hidden] перебивается любым `display: ...` правилом более
   высокой специфичности (.chat-composer__attach-menu, .chat-rec и пр. имеют
   display: flex без `:not([hidden])`). Глобально форсим — чтобы любой
   `[hidden]` действительно скрывал элемент. */
[hidden] { display: none !important; }

html { max-width: 100vw; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100vw;
  /* Tonal gradient — через bg/surface токены, работает в обеих темах */
  background:
    radial-gradient(ellipse 1200px 600px at top,
      color-mix(in srgb, var(--md-sys-color-primary) 5%, transparent),
      transparent 60%),
    linear-gradient(180deg,
      var(--md-sys-color-background) 0%,
      var(--md-sys-color-surface) 100%);
  background-attachment: fixed;
  color: var(--md-sys-color-on-background);
}

/* Detail-page · фон = цвет карточки (surfaceContainerLow). При переходе
   из списка (карточка на тёмном фоне) в детальную страницу визуальная
   непрерывность сохраняется — фон становится цветом карточки. */
body.page-detail {
  background: var(--md-sys-color-surface-container-low);
}

/* page-chat — chat-detail full-screen без рамок, без bottom-nav, без page scroll.
   Лечит mobile vertical scroll: .app имел min-height: 100vh, при свёрнутой адресной
   строке 100vh > 100dvh → page растягивается ниже viewport. Принудительно фиксируем
   высоту контейнера на 100dvh и блокируем overflow на body. */
body.page-chat { overflow: hidden; }
body.page-chat .app { min-height: 0; height: 100vh; height: 100dvh; }
body.page-chat .app__content { padding: 0; padding-bottom: 0; min-height: 0; overflow: hidden; }
body.page-chat .bottom-nav { display: none; }

/* --- View Transitions API (Chrome/Edge/Safari 18+) --- */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: var(--md-sys-motion-easing-emphasized-out, cubic-bezier(0.05,0.7,0.1,1));
}

/* Reduce motion — a11y */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  @view-transition { navigation: none; }
}

/* Headings — Roboto Flex с opsz */
h1, h2, h3, .page-title, .listing-detail__section-title {
  font-variation-settings: var(--typo-headline-variation);
  letter-spacing: -0.5px;
}
h1, .page-title { font: var(--md-sys-typescale-headline-large); }
h2, .listing-detail__section-title { font: var(--md-sys-typescale-headline-medium); }
h3 { font: var(--md-sys-typescale-title-large); }

a { color: var(--md-sys-color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* --- SVG icons --- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon svg {
  fill: currentColor;
  width: 1em;
  height: 1em;
}

ul, ol { list-style: none; }

/* --- App Layout --- */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.app__body {
  display: flex;
  flex: 1;
  padding-top: var(--header-height);
}

.app__content {
  flex: 1;
  min-width: 0;
  padding: var(--md-sys-spacing-sm);
  padding-bottom: calc(var(--bottom-nav-height) + var(--md-sys-spacing-lg));
}

@media (min-width: 600px) {
  .app__content { padding: var(--md-sys-spacing-md); }
}

/* --- Header (Top App Bar) --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  background: var(--md-sys-color-surface);
  background-image: linear-gradient(90deg, rgba(164, 161, 80, 0.08) 0%, rgba(164, 161, 80, 0.08) 100%);
  box-shadow: 0px 1px 2px rgba(0,0,0,0.2), 0px 2px 6px rgba(0,0,0,0.15);
}

.header__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
  font-size: 24px;
}

.header__menu-btn:hover { background: var(--md-sys-color-secondary-container); }

.header__logo {
  /* CattleSales wordmark: ink-чёрный base, зелёная pivot-S — inline в _header.html */
  font: 900 22px/28px 'Roboto', sans-serif;
  letter-spacing: -0.5px;
  color: #1A1C18;
  white-space: nowrap;
  margin-right: auto;
  text-decoration: none;
}
.header__logo:hover { text-decoration: none; }

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (min-width: 840px) {
  .header__actions { gap: 24px; }
}

.header__flag {
  width: 24px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
  overflow: hidden;
  flex-shrink: 0;
}

@media (min-width: 840px) {
  .header__flag { width: 36px; height: 22px; border-radius: 6px; }
}

/* 🌐 эмодзи вместо флага на главном домене (request.is_main_domain).
   line-height фиксированный — иначе эмодзи выпрыгивает вверх. */
.header__flag--globe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  background: transparent;
}
@media (min-width: 840px) {
  .header__flag--globe { font-size: 22px; }
}

.header__currency {
  font: 500 16px/24px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  white-space: nowrap;
  display: none;
}

@media (min-width: 840px) {
  .header__currency { display: inline-flex; align-items: center; }
}

.header__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
  font-size: 24px;
}

.header__icon-btn:hover { background: var(--md-sys-color-secondary-container); }

/* Theme switcher удалён (dark theme removed 2026-05-12). */

/* --- Account dropdown (user menu) --- */
.header__account {
  position: relative;
}
.header__account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-2);
  display: none;
  z-index: 110;
}
.header__account-dropdown.is-open { display: block; }
.header__account-name {
  padding: 8px 14px 10px;
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  margin-bottom: 4px;
}
.header__account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-corner-small);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-label-large);
  text-decoration: none;
  transition: background var(--md-sys-motion-duration-short);
}
.header__account-item:hover {
  background: var(--md-sys-color-secondary-container);
  text-decoration: none;
}
.header__account-item--danger { color: var(--md-sys-color-error); }
.header__account-item svg { flex-shrink: 0; }

/* --- Header search bar (desktop) --- */
.header__search {
  display: none;
  align-items: center;
  flex: 1;
  max-width: 480px;
  margin: 0 16px;
  position: relative;
}

.header__search-input {
  width: 100%;
  padding: 10px 18px 10px 42px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container);
  min-height: 44px;
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: background var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.header__search-input:focus {
  background: var(--md-sys-color-surface);
  box-shadow: var(--md-sys-elevation-2);
}

.header__search-input::placeholder { color: var(--md-sys-color-on-surface-variant); }

.header__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
}

@media (min-width: 840px) {
  .header__search { display: flex; }
  .header__search-mobile { display: none; }
}

/* --- Language switcher --- */
.header__lang { position: relative; }

.header__lang-select {
  appearance: none;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 2px 16px 2px 6px;
  font: 500 11px/14px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2349454F' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") right 2px center no-repeat;
  cursor: pointer;
  outline: none;
  width: 42px;
}

.header__lang-select:focus {
  border-color: var(--md-sys-color-primary);
}

/* --- Country switcher dropdown --- */
.header__country {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__country-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  font: 500 12px/16px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  padding: 4px 6px;
  border-radius: var(--md-sys-shape-corner-full);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__country-btn:hover { background: var(--md-sys-color-surface-container); }

.header__country-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 200;
  background: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-3);
  max-height: 400px;
  overflow-y: auto;
  min-width: 220px;
  padding: 8px 0;
}

.header__country-dropdown.is-open { display: block; }

.header__country-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font: 400 13px/18px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  white-space: nowrap;
}

.header__country-item:hover {
  background: var(--md-sys-color-surface-container);
  text-decoration: none;
}

.header__country-item img {
  border-radius: 2px;
  flex-shrink: 0;
}

/* «Global»-пункт: синий глобус 🌐 размером с флаги + active-подсветка на
   главном домене. */
.header__country-item--global .header__flag--globe {
  width: 20px;
  font-size: 18px;
  line-height: 14px;
  text-align: center;
  flex-shrink: 0;
}

.header__country-item--active {
  background: var(--md-sys-color-primary-container);
  font-weight: 600;
}

/* --- Language switcher dropdown --- */
.header__lang {
  position: relative;
}

.header__lang-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  font: 500 12px/16px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  padding: 4px 6px;
  border-radius: var(--md-sys-shape-corner-full);
}

.header__lang-btn:hover { background: var(--md-sys-color-surface-container); }

.header__lang-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 200;
  background: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-3);
  min-width: 60px;
  padding: 8px 0;
  /* На main domain в dropdown'е все 43 языка — не влезут в экран. */
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.header__lang-dropdown.is-open { display: block; }

.header__lang-item {
  display: block;
  padding: 6px 16px;
  font: 400 13px/18px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  text-align: center;
}

.header__lang-item:hover {
  background: var(--md-sys-color-surface-container);
  text-decoration: none;
}

.header__lang-item--active {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

/* --- Sidebar (desktop) --- */
.sidebar {
  display: none;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--md-sys-color-surface);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  overflow-y: auto;
  padding: var(--md-sys-spacing-sm) 0
    calc(env(safe-area-inset-bottom, 0px) + var(--md-sys-spacing-md)) 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px var(--md-sys-spacing-lg) 12px;
  color: #1A1C18;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: -0.5px;
}
.sidebar__logo:hover { text-decoration: none; }
.sidebar__logo-icon { font-size: 28px; line-height: 1; }
.sidebar__logo-text { font-size: 22px; line-height: 1; }
.sidebar__logo-pivot {
  color: var(--md-sys-color-primary, #1B743E);
  font-size: 1.18em;
  font-weight: 900;
  -webkit-text-stroke: 0.5px var(--md-sys-color-primary, #1B743E);
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-md);
  padding: 14px var(--md-sys-spacing-lg);
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-large);
  font-size: 15px;
  letter-spacing: 0.1px;
  transition: background 0.15s;
  margin: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
}

.sidebar__item:hover {
  background: var(--md-sys-color-secondary-container);
  text-decoration: none;
}

.sidebar__item:active {
  background: var(--md-sys-color-surface-container-high);
}

.sidebar__item--disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.sidebar__item--active {
  color: var(--md-sys-color-primary);
  background: var(--md-sys-color-secondary-container);
  font-weight: 600;
}

.sidebar__item .material-icons { font-size: 24px; }

.sidebar__divider {
  height: 1px;
  background: var(--md-sys-color-outline-variant);
  margin: var(--md-sys-spacing-sm) 0;
}

/* --- Sidebar theme toggle: один пункт меню, циклический переключатель --- */
.sidebar__item--button {
  width: calc(100% - 16px);
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
/* --- Bottom Navigation (mobile) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  /* Высота + safe-area-inset-bottom (iPhone home indicator) — иначе bnav
     обрезается снизу и нижний ряд иконок недоступен. */
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--md-sys-color-surface);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0;
  /* Гарантируем что bottom-nav поверх любых z-index-overlay (gallery, modals)
     и контента, иначе на скролле длинных страниц теряется. */
  transform: translateZ(0);
}

/* На mobile main-контент должен иметь padding-bottom = высота bnav (иначе
   последние карточки/кнопки уезжают под bnav и невидимы). */
@media (max-width: 839px) {
  .app__content {
    padding-bottom: calc(
      var(--bottom-nav-height) +
      env(safe-area-inset-bottom, 0px) +
      var(--md-sys-spacing-md)
    );
  }
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-label-small);
  padding: var(--md-sys-spacing-xs) var(--md-sys-spacing-md);
  border-radius: var(--md-sys-shape-corner-medium);
  transition: background 0.15s;
}

.bottom-nav__item:hover {
  background: var(--md-sys-color-secondary-container);
  text-decoration: none;
}

.bottom-nav__item--active,
.bottom-nav__item.is-active { color: var(--md-sys-color-primary); }

.bottom-nav__item--messages { position: relative; }
.bottom-nav__badge {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--md-sys-color-error, #BA1A1A);
  color: var(--md-sys-color-on-error, white);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 1.5px solid var(--md-sys-color-surface);
  box-sizing: border-box;
}

/* === Header — Сообщения с бейджем === */
.header__chat-link {
  position: relative;
  /* Bug 27: chat-icon ОБЯЗАН помещаться в header — не сжимаем под flex. */
  flex-shrink: 0;
}
/* Bug 23: Messages теперь видна и на mobile (в bottom-nav вместо «Сообщения»
   стоит «Личный кабинет» как в Flutter app). На узком header кнопка чата
   получает уменьшенный padding чтобы поместиться рядом с лого/account. */
@media (max-width: 599px) {
  .header__chat-link { padding: 4px 6px; }
  .header__chat-link svg { width: 22px; height: 22px; }

  /* Bug 27: на узких экранах country-btn показывает только флаг (текст
     «Global»/«Россия» скрыт). На > 600px → текст возвращается. caret тоже
     скрыт чтобы не есть ещё 14px. */
  .header__country-btn > span:first-child,
  .header__country-btn > .icon { display: none; }
  .header__country-btn { padding: 4px; max-width: 40px; }

  /* Уменьшаем gap между header-actions чтобы 4 элемента (country/lang/chat/
     account) гарантированно влезли. */
  .header__actions { gap: 4px; }
}

/* === Header — Avatar (Google sociallogin / fallback initial) === */
.header__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  border: 1.5px solid var(--md-sys-color-outline-variant);
  text-transform: uppercase;
  user-select: none;
}
.header__avatar--initial {
  font-family: var(--md-ref-typeface-plain, system-ui, sans-serif);
}
.header__account-btn { padding: 4px; }
@media (min-width: 840px) {
  .header__avatar { width: 36px; height: 36px; font-size: 15px; }
}
.header__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--md-sys-color-error, #BA1A1A);
  color: var(--md-sys-color-on-error, white);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 1.5px solid var(--md-sys-color-surface);
  box-sizing: border-box;
  pointer-events: none;
}

/* === Sidebar — Сообщения с бейджем === */
.sidebar__item { position: relative; }
.sidebar__badge {
  margin-left: auto;
  background: var(--md-sys-color-error, #BA1A1A);
  color: var(--md-sys-color-on-error, white);
  border-radius: 11px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  line-height: 1.3;
}

/* === Dropdown account — Сообщения с бейджем === */
.header__account-item { position: relative; display: flex; align-items: center; gap: 8px; }
.header__account-badge {
  margin-left: auto;
  background: var(--md-sys-color-error, #BA1A1A);
  color: var(--md-sys-color-on-error, white);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.bottom-nav__item .material-icons { font-size: 24px; }

/* Bottom nav FAB (center circle) */
.bottom-nav__fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -28px;
  box-shadow: var(--md-sys-elevation-3);
  text-decoration: none;
}
.bottom-nav__fab .material-icons { font-size: 28px; }
.bottom-nav__fab:hover { text-decoration: none; filter: brightness(1.1); }

/* --- FAB (desktop, bottom-right) --- */
.fab {
  position: fixed;
  bottom: var(--md-sys-spacing-lg);
  right: var(--md-sys-spacing-lg);
  z-index: 99;
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-large);
  border: none;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-3);
  display: none;
  align-items: center;
  justify-content: center;
}

.fab:hover { filter: brightness(1.1); }

/* (sidebar overlay styles moved to sidebar mobile slide-in section) */

/* --- Sidebar mobile slide-in --- */
@media (max-width: 839px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
    box-shadow: none;
    /* Нижний отступ = высота BottomNav + safe-area (iOS home indicator),
       чтобы последние пункты меню («Тема») не уезжали под bottom-nav. */
    padding-bottom: calc(
      var(--bottom-nav-height) +
      env(safe-area-inset-bottom, 0px) +
      var(--md-sys-spacing-md)
    );
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--md-sys-elevation-3);
  }
}

.sidebar-overlay {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 149;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.sidebar-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* --- Desktop breakpoint --- */
@media (min-width: 840px) {
  .sidebar { display: flex; flex-direction: column; position: sticky; top: var(--header-height); height: calc(100vh - var(--header-height)); }
  .bottom-nav { display: none; }
  .fab { display: none; }      /* desktop CTA — в header (.header__post-cta), FAB не нужен */
  .app__content { padding-bottom: var(--md-sys-spacing-lg); }
  .header__menu-btn { display: none; }
  /* В sidebar logo дублируется с header__logo — спрятать на desktop */
  .sidebar__logo { display: none; }
}

/* --- Header CTA — «+ Подать объявление» (desktop) --- */
.header__post-cta {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  height: 36px;
  border-radius: 18px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font: 500 14px/1 'Roboto', sans-serif;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: filter 0.15s, transform 0.1s;
}
.header__post-cta:hover { filter: brightness(1.08); text-decoration: none; }
.header__post-cta:active { transform: scale(0.97); }
@media (min-width: 840px) {
  .header__post-cta { display: inline-flex; }
}

@media (min-width: 1200px) {
  .app__content { max-width: var(--content-max-width); }
}

/* --- Snackbar messages --- */
.snackbar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 80px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: var(--md-sys-spacing-md) var(--md-sys-spacing-lg);
  background: #323232;
  color: #fff;
  border-radius: var(--md-sys-shape-corner-medium);
  font: var(--md-sys-typescale-body-medium);
  box-shadow: var(--md-sys-elevation-3);
  animation: snackbar-in 0.3s ease;
}

@keyframes snackbar-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 840px) {
  .snackbar { bottom: var(--md-sys-spacing-lg); }
}

/* --- Ripple effect --- */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%) scale(0);
}

.ripple:active::after {
  opacity: 0.12;
  transform: translate(-50%, -50%) scale(4);
  transition: transform 0.4s var(--md-sys-motion-easing-standard),
              opacity 0.1s;
}

/* --- Scroll reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-decelerate),
              transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-decelerate);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Skeleton loading --- */
.skeleton {
  background: linear-gradient(90deg,
    var(--md-sys-color-surface-variant) 25%,
    var(--md-sys-color-surface-container-high) 50%,
    var(--md-sys-color-surface-variant) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--md-sys-shape-corner-small);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--text { height: 16px; margin-bottom: 8px; }
.skeleton--title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton--image { aspect-ratio: 4/3; border-radius: var(--md-sys-shape-corner-medium); }
.skeleton--card { height: 140px; border-radius: var(--md-sys-shape-corner-medium); }

/* --- Page title --- */
.page-title {
  font: var(--md-sys-typescale-headline-medium);
  color: var(--md-sys-color-on-surface);
  margin-bottom: var(--md-sys-spacing-lg);
}

/* --- Section --- */
.section {
  margin-bottom: var(--md-sys-spacing-xl);
}

/* --- Container with filters layout --- */
.layout-with-filters {
  display: flex;
  gap: var(--md-sys-spacing-lg);
}

.layout-with-filters__filters { display: none; }
.layout-with-filters__content { flex: 1; min-width: 0; }

/* --- Bottom sheet (mobile filters) --- */
.bottom-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
  box-shadow: var(--md-sys-elevation-3);
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

.bottom-sheet.is-open {
  display: block;
  transform: translateY(0);
}

@media (min-width: 840px) {
  .bottom-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    width: 480px;
    max-height: 80vh;
    border-radius: var(--md-sys-shape-corner-extra-large);
  }
  .bottom-sheet.is-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.bottom-sheet__handle {
  width: 32px;
  height: 4px;
  background: var(--md-sys-color-outline-variant);
  border-radius: 2px;
  margin: 12px auto 8px;
}

.bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 16px;
}

.bottom-sheet__title {
  font: var(--md-sys-typescale-title-medium);
  color: var(--md-sys-color-on-surface);
}

.bottom-sheet__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
}

.bottom-sheet__body {
  padding: 0 16px 24px;
  /* Защита от horizontal overflow внутреннего контента (select 230 стран) */
  overflow-x: hidden;
  box-sizing: border-box;
}

.bottom-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.bottom-sheet-overlay.is-open {
  display: block;
  opacity: 1;
}

/* --- Results counter --- */
.results-counter {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: var(--md-sys-spacing-md);
}

.results-counter strong {
  color: var(--md-sys-color-on-surface);
}

/* --- Active filter chips --- */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--md-sys-spacing-sm);
  margin-bottom: var(--md-sys-spacing-md);
}

.active-filters:empty { display: none; }

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: var(--md-sys-color-primary-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short);
}

.active-filter:hover { background: var(--md-sys-color-surface-container-high); }

/* Крестик — зелёная круглая кнопка с белым ✕ (единый дизайн). */
.active-filter svg {
  width: 20px;
  height: 20px;
  padding: 3px;
  box-sizing: border-box;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  flex-shrink: 0;
}

@media (min-width: 840px) {
  .layout-with-filters__filters {
    display: block;
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-height) + var(--md-sys-spacing-md));
    max-height: calc(100vh - var(--header-height) - var(--md-sys-spacing-xl));
    overflow-y: auto;
  }
}
/* ==========================================================================
   M3 Components — CattleSales
   ========================================================================== */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-sm);
  padding: 12px 28px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  font-size: 15px;
  letter-spacing: 0.1px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}

.btn--filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.btn--filled:hover { filter: brightness(1.08); box-shadow: var(--md-sys-elevation-1); text-decoration: none; }

.btn--outlined {
  background-image: linear-gradient(rgba(194,191,108,0.08), rgba(194,191,108,0.08)),
                     linear-gradient(var(--md-sys-color-surface), var(--md-sys-color-surface));
  color: var(--md-sys-color-primary);
  border: 1px solid #c2bf6c;
}
.btn--outlined:hover { background-image: linear-gradient(rgba(194,191,108,0.15), rgba(194,191,108,0.15)), linear-gradient(var(--md-sys-color-surface), var(--md-sys-color-surface)); text-decoration: none; }

.btn--elevated {
  background: var(--md-sys-color-surface);
  background-image: linear-gradient(rgba(164,161,80,0.05), rgba(164,161,80,0.05));
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
}
.btn--elevated:hover { box-shadow: var(--md-sys-elevation-2); text-decoration: none; }

.btn--text {
  background: none;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}
.btn--text:hover { background: var(--md-sys-color-secondary-container); text-decoration: none; }

.btn--sm { padding: 8px 20px; font: var(--md-sys-typescale-label-medium); min-height: 36px; }
.btn--lg { padding: 16px 36px; font-size: 16px; min-height: 52px; }

.btn .material-icons { font-size: 18px; }

/* --- Cards --- */
.card {
  background-image: linear-gradient(rgba(164,161,80,0.06), rgba(164,161,80,0.06)),
                     linear-gradient(var(--md-sys-color-surface), var(--md-sys-color-surface));
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: 0px 2px 12px rgba(0,0,0,0.10), 0px 4px 20px rgba(0,0,0,0.06);
  overflow: hidden;
  transition: box-shadow 0.25s, transform 0.25s;
}

.card:hover {
  box-shadow: 0px 4px 20px rgba(0,0,0,0.14), 0px 8px 32px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.card:active { box-shadow: 0px 2px 8px rgba(0,0,0,0.12); transform: translateY(0); }

.card__media {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--md-sys-color-surface-variant);
  display: block;
}

.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__media > div { position: absolute; inset: 0; }

.card__media-badge {
  position: absolute;
  bottom: var(--md-sys-spacing-sm);
  right: var(--md-sys-spacing-sm);
}

.card__body { padding: var(--md-sys-spacing-md); }

.card__title {
  font: var(--md-sys-typescale-title-medium);
  color: var(--md-sys-color-on-surface);
  margin-bottom: var(--md-sys-spacing-xs);
}

.card__subtitle {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: var(--md-sys-spacing-sm);
}

.card__text {
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
}

.card__actions {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md) var(--md-sys-spacing-md);
}

.card__footer {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-md);
  padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md) var(--md-sys-spacing-md);
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

.card__footer .material-icons { font-size: 16px; }

/* --- Card grid --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--md-sys-spacing-md);
}

@media (min-width: 600px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

/* --- Inputs --- */
.input-group {
  margin-bottom: var(--md-sys-spacing-md);
}

.input-group__label {
  display: block;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: var(--md-sys-spacing-xs);
}

.input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  outline: none;
  transition: border-color 0.15s;
  min-height: 48px;
}

.input:focus { border-color: var(--md-sys-color-primary); border-width: 2px; padding: 11px 15px; }

.input--error { border-color: var(--md-sys-color-error); }

.input-group__error {
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-error);
  margin-top: var(--md-sys-spacing-xs);
}

/* --- Select --- */
.select {
  width: 100%;
  padding: 14px 40px 14px 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  min-height: 48px;
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%2349454F' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") right 8px center no-repeat;
  appearance: none;
  cursor: pointer;
  outline: none;
}

.select:focus { border-color: var(--md-sys-color-primary); border-width: 2px; }

/* --- Textarea --- */
.textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font: var(--md-sys-typescale-body-large);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
  resize: vertical;
  outline: none;
}

.textarea:focus { border-color: var(--md-sys-color-primary); border-width: 2px; }

/* --- Radio --- */
.radio-list { display: flex; flex-direction: column; }

.radio-item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--md-sys-shape-corner-small);
}

.radio-item:hover { background: var(--md-sys-color-secondary-container); }

.radio-item input[type="radio"] { display: none; }

.radio-item__indicator {
  width: 20px;
  height: 20px;
  border: 2px solid var(--md-sys-color-on-surface-variant);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.radio-item input[type="radio"]:checked + .radio-item__indicator {
  border-color: var(--md-sys-color-primary);
}

.radio-item input[type="radio"]:checked + .radio-item__indicator::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--md-sys-color-primary);
  border-radius: 50%;
}

.radio-item--selected,
.radio-item:has(input[type="radio"]:checked) {
  background: var(--md-sys-color-secondary-container);
}

.radio-item__label {
  font: var(--md-sys-typescale-body-large);
  letter-spacing: 0.5px;
}

/* --- Checkbox --- */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-md);
  padding: 12px 16px;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

/* --- Chips --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-xs);
  padding: 8px 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-medium);
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface);
  white-space: nowrap;
  min-height: 36px;
}

.chip--filled {
  background-image: linear-gradient(rgba(194,191,108,0.3), rgba(194,191,108,0.3)),
                     linear-gradient(var(--md-sys-color-surface), var(--md-sys-color-surface));
  border-color: transparent;
  color: var(--md-sys-color-on-surface);
}

.chip--primary {
  background: var(--md-sys-color-primary);
  border-color: transparent;
  color: var(--md-sys-color-on-primary);
}

/* --- Flag badge --- */
.flag-badge {
  width: 36px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* --- Characteristics list --- */
.char-list { display: flex; flex-direction: column; gap: var(--md-sys-spacing-sm); }

.char-item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  font: var(--md-sys-typescale-body-medium);
  color: var(--md-sys-color-on-surface-variant);
}

.char-item .material-icons { font-size: 20px; color: var(--md-sys-color-primary); }

/* --- Price tag --- */
.price {
  font: var(--md-sys-typescale-title-medium);
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

.price--lg { font-size: 22px; }

/* --- Stats (views, likes) --- */
.stats {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-md);
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-on-surface-variant);
}

.stats__item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats__item .material-icons { font-size: 16px; }

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--md-sys-color-outline-variant);
  margin: var(--md-sys-spacing-md) 0;
}

.divider--primary { background: var(--md-sys-color-primary); }

/* --- Range slider --- */
.range-slider { width: 100%; margin: var(--md-sys-spacing-sm) 0; }

.range-slider input[type="range"] {
  width: 100%;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.range-slider__values {
  display: flex;
  justify-content: space-between;
  font: var(--md-sys-typescale-body-small);
  color: var(--md-sys-color-primary);
  margin-top: var(--md-sys-spacing-xs);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-xs);
  padding: var(--md-sys-spacing-lg) 0;
}

.pagination__item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
  transition: background 0.15s;
}

.pagination__item:hover { background: var(--md-sys-color-secondary-container); text-decoration: none; }
.pagination__item--active { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.pagination__item--disabled { color: var(--md-sys-color-outline); pointer-events: none; }

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--md-sys-spacing-xxl) var(--md-sys-spacing-md);
  color: var(--md-sys-color-on-surface-variant);
}

.empty-state .material-icons { font-size: 64px; color: var(--md-sys-color-outline-variant); margin-bottom: var(--md-sys-spacing-md); }
.empty-state__title { font: var(--md-sys-typescale-title-large); margin-bottom: var(--md-sys-spacing-sm); }
.empty-state__text { font: var(--md-sys-typescale-body-large); }

/* --- Favorite button with bounce animation --- */
.favorite-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-medium);
  padding: var(--md-sys-spacing-xs);
  border-radius: var(--md-sys-shape-corner-full);
  transition: color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.favorite-btn:hover { color: #E91E63; }
.favorite-btn--active { color: #E91E63; }

/* Иконки рендерятся SVG-спрайтом (<use>), не Material-Icons шрифтом —
   селекторы на svg, иначе bounce/scale не применялись. */
.favorite-btn svg {
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

.favorite-btn:active svg {
  transform: scale(1.3);
}

.favorite-btn.is-animating svg {
  animation: favorite-bounce 0.4s var(--md-sys-motion-easing-emphasized);
}

@keyframes favorite-bounce {
  0% { transform: scale(1); }
  25% { transform: scale(1.4); }
  50% { transform: scale(0.9); }
  75% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* --- Breadcrumbs (глобально — на всех страницах, не только маркетплейс) --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 18px;
  color: var(--md-sys-color-on-surface-variant);
}
.breadcrumbs__link {
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  transition: color var(--md-sys-motion-duration-short);
}
.breadcrumbs__link:hover {
  color: var(--brand-green);
  text-decoration: underline;
}
.breadcrumbs__sep {
  color: var(--md-sys-color-outline);
  opacity: 0.6;
}
.breadcrumbs__current {
  color: var(--brand-ink);
  font-weight: 500;
}

/* @username-упоминание в комментариях/ответах базы знаний */
.mention {
  color: var(--brand-green);
  font-weight: 600;
}

/* --- Category icon --- */
.category-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sys-spacing-sm);
  padding: var(--md-sys-spacing-md);
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s;
}

.category-icon:hover { transform: scale(1.05); text-decoration: none; }

.category-icon__img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--md-sys-color-surface-container-low);
  padding: 8px;
}

.category-icon__name {
  font: var(--md-sys-typescale-label-large);
  color: var(--md-sys-color-on-surface);
}

/* --- Category icons row --- */
.category-row {
  display: flex;
  gap: var(--md-sys-spacing-sm);
  overflow-x: auto;
  padding-bottom: var(--md-sys-spacing-sm);
  scrollbar-width: none;
}

.category-row::-webkit-scrollbar { display: none; }

/* ==========================================================================
   Searchable select (Bug 4) — wrapper над native <select>
   ========================================================================== */
.searchable-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.searchable-select--compact { width: auto; min-width: 0; flex: 0 0 auto; }

.searchable-select__native {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
  /* ВАЖНО: оригинальный select виден для form-submit, но визуально скрыт. */
}

.searchable-select__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: var(--md-sys-typescale-body-large);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.searchable-select--compact .searchable-select__trigger {
  /* Bug 27: компактный trigger в header — только флаг (2 emoji char). */
  min-height: 36px;
  padding: 4px 10px;
  font-size: 18px; /* эмодзи флага читаемее */
  border-radius: var(--md-sys-shape-corner-full);
  gap: 4px;
  width: auto;
  min-width: 0;
}
.searchable-select--compact .searchable-select__label {
  flex: 0 0 auto;
  line-height: 1;
}
.searchable-select--compact .searchable-select__caret { font-size: 11px; }
.searchable-select__trigger:hover { border-color: var(--md-sys-color-primary); }
.searchable-select__trigger[aria-expanded="true"] {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  padding: 11px 13px;
}
.searchable-select__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.searchable-select__caret {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
}

.searchable-select__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-2);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.searchable-select--compact .searchable-select__panel {
  right: auto;
  min-width: 240px;
}

.searchable-select__search {
  padding: 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.searchable-select__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  font: inherit;
  outline: none;
  box-sizing: border-box;
}
.searchable-select__input:focus {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  padding: 9px 11px;
}

.searchable-select__list {
  list-style: none;
  margin: 0; padding: 4px 0;
  overflow-y: auto;
  flex: 1;
}
.searchable-select__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  transition: background 0.1s;
}
.searchable-select__item:hover,
.searchable-select__item.is-active {
  background: var(--md-sys-color-secondary-container);
}
.searchable-select__flag {
  font-size: 18px;
  line-height: 1;
}
.searchable-select__empty {
  padding: 12px 14px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

/* На mobile занимаем полную ширину панели. */
@media (max-width: 599px) {
  .searchable-select__panel { max-height: 60vh; }
}

/* ==========================================================================
   Post sheet — bottom-sheet выбора типа объявления (как в мобильном app).
   Триггеры: [data-post-sheet] (fab/header/sidebar). Markup: includes/_post_sheet.html
   ========================================================================== */
.post-sheet {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.post-sheet[hidden] { display: none; }
body.post-sheet-locked { overflow: hidden; }

.post-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity .24s ease;
}
.post-sheet.is-open .post-sheet__backdrop { opacity: 1; }

.post-sheet__panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--md-sys-color-surface, #fff);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0));
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.2, 0, 0, 1);
}
.post-sheet.is-open .post-sheet__panel { transform: translateY(0); }

.post-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--md-sys-color-outline-variant, #ccc);
  margin: 6px auto 4px;
}
.post-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px;
}
.post-sheet__title {
  margin: 0;
  font: 600 17px/24px 'Roboto', sans-serif;
  color: var(--md-sys-color-on-surface, #1c1b1f);
}
.post-sheet__close {
  border: none;
  background: none;
  font-size: 28px;
  line-height: 1;
  color: var(--md-sys-color-on-surface-variant, #666);
  cursor: pointer;
  padding: 0 4px;
}
.post-sheet__list { display: flex; flex-direction: column; gap: 4px; }
.post-sheet__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface, #1c1b1f);
  transition: background .15s;
}
.post-sheet__item:active,
.post-sheet__item:hover { background: var(--md-sys-color-surface-container, rgba(0,0,0,.04)); }
.post-sheet__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1c1b1f;
}
.post-sheet__icon--animal  { background: #A5D6A7; }
.post-sheet__icon--product { background: #FFE0B2; }
.post-sheet__icon--meat    { background: #FFCDD2; }
.post-sheet__icon--milk    { background: #BBDEFB; }
.post-sheet__icon--service { background: #D1C4E9; }
.post-sheet__label {
  flex: 1;
  font: 500 15px/20px 'Roboto', sans-serif;
}
.post-sheet__chevron { color: var(--md-sys-color-outline, #999); display: flex; }
