/* =====================================================
   OpsCore — Industrial SaaS Design System 2026
   Clarity · Hierarchy · Speed · Operational Focus
   ===================================================== */

:root {
  /* ── Unified UI tokens ── */
  --ui-r: 6px;          /* badges, buttons, pills, small elements */
  --ui-r-lg: 8px;       /* containers, cards, panels */
  --ui-r-xl: 12px;      /* shell, modals */
  --ui-border: 1px solid #E6E8EC;

  /* ── Base unit: 4px ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Layout ── */
  --page-padding:  20px;
  --section-gap:   16px;
  --card-padding:  16px;
  --row-height:    64px;
  --row-compact:   48px;

  /* ── Palette: Neutral ── */
  --bg:             #F7F8FA;
  --bg-muted:       #EEF1F5;
  --bg-card:        #FFFFFF;
  --bg-sidebar:     #0F172A;
  --bg-sidebar-hover:  rgba(255,255,255,.06);
  --bg-sidebar-active: rgba(255,255,255,.10);

  --border:         #E6E8EC;
  --border-light:   #F0F2F5;

  --text:           #0F172A;
  --text-secondary: #374151;
  --text-muted:     #6B7280;
  --text-sidebar:   #94A3B8;
  --text-sidebar-active: #F8FAFC;

  /* ── Brand: Emerald (ферма) ── */
  --primary:        #2d7d53;
  --primary-hover:  #1e5c3a;
  --primary-light:  #eef8f2;
  --primary-ring:   rgba(45,125,83,.15);

  /* ── Accent: Blue ── */
  --accent:         #2563EB;
  --accent-hover:   #1D4ED8;
  --accent-light:   #EFF6FF;

  /* ── Status ── */
  --success:           #22C55E;
  --success-light:     #F0FDF4;
  --warning:           #F59E0B;
  --warning-light:     #FFFBEB;
  --destructive:       #EF4444;
  --destructive-light: #FEF2F2;
  --info:              #3B82F6;
  --info-light:        #EFF6FF;
  --purple:            #8B5CF6;
  --purple-light:      #F5F3FF;

  /* ── Priority ── */
  --priority-critical: #EF4444;
  --priority-high:     #F59E0B;
  --priority-medium:   #3B82F6;
  --priority-low:      #9CA3AF;

  /* ── Elevation / Shadows ── */
  --shadow-0:  none;
  --shadow-1:  0 1px 2px rgba(15,23,42,.05);
  --shadow-2:  0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-3:  0 12px 32px rgba(15,23,42,.12), 0 4px 8px rgba(15,23,42,.06);
  --shadow-4:  0 24px 48px rgba(15,23,42,.16), 0 8px 16px rgba(15,23,42,.08);
  /* Алиасы */
  --shadow-sm: var(--shadow-1);
  --shadow:    var(--shadow-1);
  --shadow-md: var(--shadow-2);
  --shadow-lg: var(--shadow-3);

  /* ── Radius ── */
  --radius:    10px;
  --radius-sm:  7px;
  --radius-xs:  5px;
  --radius-full: 999px;

  /* ── Motion ── */
  --duration-fast:   120ms;
  --duration-normal: 180ms;
  --duration-slow:   240ms;
  --ease:            cubic-bezier(.4,0,.2,1);
  --transition:      var(--duration-normal) var(--ease);

  /* ── Layout ── */
  --sidebar-w:            240px;
  --sidebar-w-collapsed:   72px;
  --header-h:              56px;

  /* ── Typography ── */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Manrope', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* ── Density mode (default: comfortable) ── */
  --density-row:      var(--row-height);
  --density-padding:  var(--card-padding);
  --density-font:     14px;
}


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


body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--density-font, 14px);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

/* Tabular nums для всех числовых значений */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* === Layout === */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  /* Короткая анимация (150мс) — компромисс между плавностью и тем,
     чтобы рассинхрон с мгновенным layout-переключением не бросался в глаза. */
  transition: width .15s ease, transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 14px;
  height: var(--header-h);
  gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  flex-shrink: 0;
}
.sidebar-logo svg { color: #fff; }
.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-title {
  color: #fafaf9;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
}

/* Развёрнутое: лого слева, кнопка справа (margin-left:auto прижимает к правому краю). */
.sidebar-toggle {
  margin-left: auto;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.22); }

/* Свёрнуто: шапка переключается в колонку — лого сверху, кнопка под ним.
   Чтобы не было «собирается в середину» — переключение мгновенное (см. правило ниже). */
.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  height: auto;
  padding: 12px 0 10px;
  gap: 8px;
  align-items: center;
}
.sidebar.collapsed .sidebar-toggle { margin-left: 0; }

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-title { display: none; }

.sidebar-nav { flex: 1; min-height: 0; padding: 10px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-nav { scrollbar-width: none; -ms-overflow-style: none; }

.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.28);
  padding: 16px 10px 5px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: var(--text-sidebar);
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  position: relative;
}

.nav-item:hover { background: var(--bg-sidebar-hover); color: #e7e5e4; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.nav-item.active .nav-badge { background: rgba(255,255,255,.2); }

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

/* Вложенный пункт меню (подраздел) */
.nav-item-sub {
  padding-left: 28px;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}
.nav-item-sub:hover { opacity: 1; }
.nav-item-sub svg { width: 13px; height: 13px; opacity: 0.7; }
.sidebar.collapsed .nav-item-sub { padding-left: 10px; }
.sidebar.collapsed .nav-item-sub .nav-label { display: none; }

/* === Секции на странице 1С === */
.sync-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 18px 18px 16px;
  margin: 0 16px 14px;
}
.sync-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.sync-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.sync-section-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sync-section-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.sync-section-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Карточки счётчиков буфера */
.sync-stat-card {
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sync-stat-card:hover { transform: translateY(-1px); }
.sync-stat-card.active { background: var(--bg-card); }
.sync-stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Табы фильтра в буфере */
.sync-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.sync-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  margin-bottom: -1px;
}
.sync-tab:hover { color: var(--text); }
.sync-tab.sync-tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Внутренние табы страницы 1С */
.sync-inner-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 0 14px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.sync-inner-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.sync-inner-tab:hover { border-color: var(--primary); color: var(--primary); }
.sync-inner-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.sync-inner-tab .sync-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,.25);
  color: inherit;
}
.sync-inner-tab:not(.active) .sync-tab-badge {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* Строки токенов / лога / обследований */
.sync-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  transition: border-color .15s;
}
.sync-row:hover { border-color: var(--primary); }

/* === Режим выбора оборудования (пакетная печать QR) === */
.eq-card { position: relative; }
.eq-card .eq-card-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none; /* клик ловится самой карточкой */
  transition: all .15s;
}
.eq-card .eq-card-checkbox svg {
  width: 14px;
  height: 14px;
  color: #fff;
  opacity: 0;
  transition: opacity .15s;
}
body.eq-select-mode .eq-card { cursor: pointer; }
body.eq-select-mode .eq-card .eq-card-checkbox { display: flex; }
body.eq-select-mode .eq-card.is-selected {
  background: #f0fdf4 !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .15);
}
body.eq-select-mode .eq-card.is-selected .eq-card-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}
body.eq-select-mode .eq-card.is-selected .eq-card-checkbox svg { opacity: 1; }

/* Action-bar внизу страницы */
.eq-select-actionbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  z-index: 1000;
  font-size: 14px;
  animation: eqSelectBarIn .18s ease-out;
}
@keyframes eqSelectBarIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.eq-select-actionbar .eq-sel-count {
  font-weight: 700;
  margin-right: 4px;
}
.eq-select-actionbar .eq-sel-count em {
  font-style: normal;
  color: #86efac;
  margin: 0 2px;
}
.eq-select-actionbar .btn-sel {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s;
}
.eq-select-actionbar .btn-sel:hover { background: rgba(255,255,255,.1); }
.eq-select-actionbar .btn-sel.btn-sel-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.eq-select-actionbar .btn-sel.btn-sel-primary:hover { background: #16a34a; }
.eq-select-actionbar .btn-sel:disabled { opacity: .4; cursor: not-allowed; }

/* Кнопка-тогл «Выбрать» в активном состоянии */
#eq-select-toggle-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Таббар внутри раздела «Склад» */
.warehouse-tabbar {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  overflow-x: auto;
  margin: 0 0 16px 0;
  -webkit-overflow-scrolling: touch;
}
.wh-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  text-decoration: none;
  position: relative;
}
.wh-tab:hover { color: var(--text); }
.wh-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.wh-tab svg { width: 15px; height: 15px; flex-shrink: 0; }
.wh-tab .wh-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  margin-left: 4px;
}
@media (max-width: 768px) {
  .warehouse-tabbar { padding: 0 12px; }
  .wh-tab { padding: 10px 12px; font-size: 12px; }
  .wh-tab svg { display: none; }
}

.nav-badge {
  margin-left: auto;
  background: var(--destructive);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}


#sidebar-toggle-btn:hover { background: var(--bg-muted) !important; color: var(--text) !important; }

/* Collapsed sidebar */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-w-collapsed); }
.sidebar.collapsed ~ .mobile-overlay { display: none !important; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer .nav-item { justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 10px; }

/* Badge в свёрнутом sidebar — абсолютное позиционирование */
.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 4px; right: 4px;
  padding: 0 4px;
  font-size: 9px;
  min-width: 14px;
  height: 14px;
  line-height: 14px;
  border-radius: 7px;
  margin-left: 0;
}
/* В обычном режиме badge с иконкой-wrap выглядит правильно */
.sidebar:not(.collapsed) .nav-icon-wrap .nav-badge {
  position: absolute;
  top: -5px; right: -7px;
}

/* Tooltip on collapsed */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: #292524;
  color: #fafaf9;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* SSE dot */
#sse-dot {
  transition: background .4s, box-shadow .4s;
}
@keyframes ssePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
  50%       { box-shadow: 0 0 0 5px rgba(22,163,74,.06); }
}
@keyframes ssePulseAnim {
  0%, 100% { box-shadow: 0 0 0 2px rgba(22,163,74,.25); }
  50%       { box-shadow: 0 0 0 6px rgba(22,163,74,.06); }
}

/* =====================================================
   MAIN / HEADER
   ===================================================== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  transition: margin-left .15s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  background: var(--bg-card); /* убирает серую полосу за таббаром */
}

.header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 200px);
  display: block;
}
@media (max-width: 767px) {
  .header-title { max-width: calc(100vw - 140px); font-size: 14px; }
}
.header-spacer { flex: 1; }
.content { padding: 20px; }

/* =====================================================
   STAT CARDS
   ===================================================== */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 0 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow var(--transition), border-color var(--transition);
  cursor: default;
  flex: 1 1 auto;
  min-width: 140px;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card-header { display: none; }


.stat-card-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.stat-card-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.stat-card-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }

/* Color variants */

.stat-card.card-active {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--primary-light);
}
.stat-card[onclick] { transition: all var(--transition); }
.stat-card[onclick]:active { transform: scale(.96); }

/* Базовые правила подэлементов stat-card (без mobile-override) */
.stat-card-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }

/* Row контейнер для stat-card-ов */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.stats-row .stat-card { margin: 0; min-width: 200px; }

/* Карточка счётчика (раздел «Ресурсы») */
.meter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.meter-card::before {
  content: "";
  position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--meter-accent, #d1d5db);
}
.meter-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--meter-accent, var(--primary));
  transform: translateY(-2px);
}
.meter-card-top { display: flex; gap: 12px; align-items: flex-start; }
.meter-card-icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0; }
.meter-card-name { font-weight: 600; font-size: 14px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-card-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.meter-card-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 16px; }
.meter-card-value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.meter-card-unit { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.meter-card-when { font-size: 11px; margin-top: 3px; }
.meter-card-btn { flex-shrink: 0; }

/* Подзаголовок страницы */
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }


/* =====================================================
   SECTION
   ===================================================== */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -.02em;
}
.section-title svg { width: 16px; height: 16px; color: var(--text-muted); }

.section-body { padding: 0; }

/* =====================================================
   TASK LIST
   ===================================================== */
.task-list { list-style: none; }

/* ─── Task Row (DS 2026) ─── */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--duration-fast) var(--ease);
  cursor: pointer;
  min-height: var(--density-row, 64px);
  position: relative;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover {
  background: var(--bg-muted);
}

/* Priority stripe — 3px, цвет по системе приоритетов */
.task-priority-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
  min-height: 40px;
  margin: 10px 0;
}
.task-priority-bar.critical { background: var(--priority-critical); }
.task-priority-bar.high     { background: var(--priority-high); }
.task-priority-bar.medium   { background: var(--priority-medium); }
.task-priority-bar.normal   { background: var(--border); }
.task-priority-bar.low      { background: var(--border); }
.task-priority-bar.mine     { background: var(--primary); }

/* Task icon */
.task-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.task-icon svg { width: 16px; height: 16px; }

.task-info { flex: 1; min-width: 0; }

.task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  letter-spacing: -.01em;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.task-meta-item {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.task-meta-item svg { width: 11px; height: 11px; }

/* ─── Badges (DS 2026 — pill style) ─── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  padding: 0 10px;
  height: 22px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: .01em;
  flex-shrink: 0;
}

/* Мягкие tint-badge вместо сплошных */
.badge-overdue    { background: #FEE2E2; color: #B91C1C; }
.badge-pending    { background: #FEF3C7; color: #92400E; }
.badge-completed  { background: #d6f0df; color: #173626; }
.badge-cancelled  { background: var(--bg-muted); color: var(--text-muted); }


/* Правая колонка: статус + счётчики */
.task-status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 90px;
}

/* В строке задачи */
.task-item > .badge,
.task-status-col .badge {
  align-self: center;
  flex-shrink: 0;
  min-width: 90px;
  justify-content: center;
}

/* Зона actions — всегда фиксированная ширина для выравнивания */
.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  width: 66px;
  min-width: 66px;
}
.task-actions:empty { visibility: hidden; }

/* Кнопки быстрых действий в строке задачи */
.task-actions .btn-icon {
  width: 28px; height: 28px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #6b7280;
}
.task-actions .btn-icon:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #3b82f6;
}
.task-actions .btn-icon.success {
  border-color: #bbf7d0;
  color: #16a34a;
  background: #eef8f2;
}
.task-actions .btn-icon.success:hover {
  border-color: #16a34a;
  background: #dcfce7;
  color: #15803d;
}
.task-actions .btn-icon svg { width: 14px; height: 14px; }
}

.btn-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-muted); color: var(--text); }
.btn-icon svg { width: 15px; height: 15px; }
.btn-icon.success:hover { background: var(--success-light); color: var(--success); }
.btn-icon.danger:hover  { background: var(--destructive-light); color: var(--destructive); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 8px var(--primary-ring); }

.btn-danger { background: var(--destructive); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Кнопка "Сообщить о проблеме" на странице локации:
   на десктопе — auto-ширина с увеличенным padding (выделяется);
   на мобильном — full-width (палец комфортно ложится). */
.btn-report-loc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 14px;
}
@media (max-width: 768px) {
  .btn-report-loc { width: 100%; }
}
/* Низ страниц-деталей не должен прятаться под мобильный tab-bar (height: ~66px).
   Используем 767px как остальной проект + .active + !important — иначе .content/.page
   и анимации перебивают. */
@media (max-width: 767px) {
  #page-location-detail.active,
  #page-equipment-detail.active,
  #page-task-detail.active,
  #page-task-details.active,
  #page-knowledge.active { padding-bottom: 120px !important; }
}

.btn-outline { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-muted); border-color: #d4d0cb; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* =====================================================
   EQUIPMENT
   ===================================================== */
.eq-group { margin-bottom: 4px; }
.eq-group:last-child { margin-bottom: 0; }

.eq-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-muted);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.eq-group-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px; font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  padding: 0 6px;
}

.eq-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px 16px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px;
}

/* ─── Equipment Card (DS 2026) ─── */
.eq-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-padding);
  padding-left: calc(var(--card-padding) + 6px);
  cursor: pointer;
  transition: box-shadow var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
  background: var(--bg-card);
  box-shadow: var(--shadow-1);
  position: relative;
}
.eq-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  border-color: var(--border);
}
.eq-card:active { transform: translateY(0); }

.eq-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

.eq-card-icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.eq-card-icon svg { width: 20px; height: 20px; }

.eq-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.eq-card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.eq-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.eq-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; }
.eq-status-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card); cursor: pointer; transition: background .15s, border-color .15s; }
.eq-status-btn:hover { background: var(--bg-hover, #f8fafc); border-color: var(--primary); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
/* Quick status sheet — bottom sheet на мобиле, центральная модалка на десктопе */
.qss-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 9998; display: flex; align-items: flex-end; justify-content: center; }
.qss-sheet { background: var(--bg-card); border-radius: 16px 16px 0 0; width: 100%; max-width: 480px; padding: 8px 0 16px; animation: slideUp .2s ease; }
.qss-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 8px auto 12px; }
@media (min-width: 768px) {
  .qss-overlay { align-items: center; padding: 20px; }
  .qss-sheet { border-radius: 16px; max-width: 420px; padding: 16px 0; animation: fadeInUp .15s ease; box-shadow: 0 20px 50px rgba(0,0,0,.15); }
  .qss-handle { display: none; }
}
.eq-status-dot { width: 7px; height: 7px; border-radius: 50%; }
.eq-status-dot.active        { background: var(--success); }
.eq-status-dot.maintenance   { background: var(--warning); }
.eq-status-dot.broken        { background: var(--destructive); }
.eq-status-dot.decommissioned{ background: #a8a29e; }

/* =====================================================
   FILTERS
   ===================================================== */
.filters-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

.filter-chip .chip-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.07);
  font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px;
  border-radius: 9px; padding: 0 4px; margin-left: 2px;
}
.filter-chip.active .chip-count { background: var(--primary-ring); }

/* =====================================================
   MODAL
   ===================================================== */
/* ─── Modal (DS 2026) ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  /* backdrop-filter: blur(4px) убран — убивает производительность при вводе текста */
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-4);
  border: 1px solid var(--border);
  /* animation убрана — transform во время анимации создаёт compositor layer
     который замедляет input events */
  animation: modal-fade var(--duration-fast) ease-out;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-muted);
  border: none; cursor: pointer;
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px 24px 4px;
  overflow-y: auto;
  flex: 1;
}
.form-group   { margin-bottom: 16px; }
.form-label   {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-input, .form-select, .form-textarea, .form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--duration-fast) var(--ease);
  outline: none;
  line-height: 1.5;
  /* box-shadow без transition — мгновенно, без repaint на каждый keystroke */
}
.form-input:focus, .form-select:focus,
.form-textarea:focus, .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-input:hover:not(:focus), .form-select:hover:not(:focus),
.form-textarea:hover:not(:focus), .form-control:hover:not(:focus) {
  border-color: #CBD5E1;
}
.form-textarea { min-height: 80px; resize: vertical; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-muted);
  flex-shrink: 0;
}


.task-item-row { display: flex; align-items: center; gap: 8px; }
.task-item-row input { flex: 1; }
.task-item-row .btn-icon { flex-shrink: 0; color: var(--text-muted); }
.task-item-row .btn-icon:hover { color: var(--destructive); }

/* =====================================================
   TASK ITEMS (checklist in detail)
   ===================================================== */
.task-items-detail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  transition: background .12s;
}
.task-items-detail-item:last-child { border-bottom: none; }
.task-items-detail-item:hover { background: var(--bg-muted); }
.task-items-detail-item.completed { opacity: .55; }
.task-items-detail-item.completed .item-title { text-decoration: line-through; }

.task-items-check {
  width: 19px; height: 19px;
  border-radius: 5px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .13s;
}
.task-items-check:hover { border-color: var(--primary); }
.task-items-check.checked { background: var(--primary); border-color: var(--primary); color: white; }
.task-items-transferred { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty { padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: .35; }
.empty-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.empty-text  { font-size: 13px; }

/* Скрыть пункты сайдбара которые дублируются в таббаре */
@media (max-width: 767px) {
  .hide-mobile-sidebar { display: none !important; }
}

/* =====================================================
   RESPONSIVE — mobile
   ===================================================== */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    z-index: 50;
    height: 100vh; height: 100dvh;
  }
  .sidebar-footer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar-collapse-btn { display: none; }

  .main {
    margin-left: 0 !important;
    height: calc(100vh - var(--header-h, 56px));
    height: calc(100dvh - var(--header-h, 56px));
    position: relative;
    overflow-y: auto;
    background: var(--bg-card);
  }
  /* Страницы скроллятся — padding-bottom чтобы контент не уходил за таббар */
  .page.active {
    min-height: 100%;
    background: var(--bg-card);
  }
  /* Отступ снизу — на всю страницу (кроме AI-чата), чтобы НИКАКОЙ контент,
     включая вложенные списки, не уходил под таб-бар. */
  .page.active:not(#page-ai-chat) {
    padding-bottom: calc(64px + max(4px, env(safe-area-inset-bottom, 0px) / 2));
  }
  /* AI Chat — position absolute, игнорирует padding от .main */
  #page-ai-chat.active {
    position: fixed;
    top: var(--header-h, 56px); left: 0; right: 0;
    bottom: 0;
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  .btn-toggle {
    display: flex;
    width: 34px; height: 34px;
    align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
  }
  .btn-toggle:hover { background: var(--bg-muted); color: var(--text); }

  .content { padding: 10px; }
  .header  { padding: 0 12px; gap: 8px; }
  .header-title { font-size: 14px; }

  .mobile-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 35; display: none;
  }
  .sidebar.mobile-open ~ .mobile-overlay { display: block; }

  /* Stats grid */
  .stats-grid {
    gap: 6px; padding: 0;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .stat-card { min-width: 0; padding: 10px 8px; flex-direction: column; align-items: center; gap: 4px; }
  .stat-card-value { font-size: 18px; }
  .stat-card-sub { font-size: 10px; }
  .stat-card-icon { display: none; }
  .stat-card-info { text-align: center; width: 100%; }

  /* Equipment */
  .eq-cards-grid { grid-template-columns: 1fr; gap: 8px; padding: 8px 12px; }
  .eq-card { padding: 12px; }
  .eq-group-header { padding: 8px 12px; font-size: 12px; }

  /* Task items */
  .task-item { padding: 10px 12px; gap: 8px; flex-wrap: wrap; align-items: flex-start; min-height: auto; }
  .task-priority-bar { width: 3px; align-self: stretch; height: auto; min-height: 32px; }
  .task-icon { width: 28px; height: 28px; min-width: 28px; margin-top: 2px; }
  .task-icon svg { width: 13px; height: 13px; }
  .task-info  { flex: 1; min-width: 0; }
  .task-title { font-size: 13px; white-space: normal; }
  .task-meta  { flex-wrap: wrap; gap: 3px; margin-top: 3px; }
  .task-meta-item { font-size: 11px; }
  .task-status-col { min-width: 80px; }
  .task-actions { width: auto; min-width: auto; }

  /* Tables */
  .data-table { font-size: 12px; }
  .eq-table-group { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: 8px 6px; white-space: nowrap; }

  /* Detail */
  .detail-header { flex-direction: row; align-items: center; gap: 10px; padding: 12px; flex-wrap: wrap; }
  .detail-header-icon { width: 36px; height: 36px; }
  .detail-header-icon svg { width: 18px; height: 18px; }
  .detail-header-name { font-size: 16px; }
  .detail-header-sub  { flex-wrap: wrap; gap: 4px 10px; font-size: 11px; }
  .detail-header-status { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .detail-header-status .btn-sm { font-size: 10px; padding: 4px 8px; }
  .detail-back { padding: 8px 12px !important; }
  .detail-back .btn { font-size: 12px; padding: 4px 10px; }

  /* Single column layout on mobile */
  .detail-grid    { grid-template-columns: 1fr !important; gap: 0 !important; display: flex !important; flex-direction: column !important; }
  /* На телефоне `display:flex !important` перебивал inline `display:none`, и на
     странице сотрудника форма редактирования показывалась ПОД показателями —
     руководитель, зашедший посмотреть цифры, листал мимо полей ввода
     (замечание владельца 18.08.2026). Скрытое обязано оставаться скрытым. */
  .detail-grid[style*="display:none"],
  .detail-grid[style*="display: none"] { display: none !important; }
  .detail-content { grid-template-columns: 1fr !important; }
  .detail-sidebar { margin-top: 0; order: -1; width: 100%; }
  .detail-side    { order: -1; width: 100%; }
  .detail-main    { order: 1; width: 100%; }

  /* Spec table */
  .spec-table td { padding: 8px 12px !important; font-size: 12px; }
  .spec-table td:first-child { min-width: 80px; width: 100px; font-size: 11px; white-space: normal; }
  .spec-table td:last-child   { font-size: 12px; word-break: break-word; }

  /* Mini stats */
  .mini-stats { grid-template-columns: 1fr 1fr !important; }
  .mini-stat  { padding: 10px 8px !important; }
  .mini-stat-value { font-size: 16px !important; }
  .mini-stat-label { font-size: 10px !important; }

  /* Timeline */
  .timeline-item { padding: 10px 12px 10px 24px; }
  .timeline-title { font-size: 13px; }
  .timeline-meta  { font-size: 10px; flex-wrap: wrap; }

  #eq-detail-parts { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #eq-detail-parts .data-table th, #eq-detail-parts .data-table td { padding: 6px 8px; font-size: 11px; }
  #eq-detail-qr img, #eq-detail-qr canvas { max-width: 120px !important; max-height: 120px !important; }

  .section { margin-bottom: 8px; border-radius: 8px; }
  .section-header { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }

  #eq-toolbar { width: 100%; flex-wrap: wrap; justify-content: flex-start; margin-left: 0 !important; }
  #eq-toolbar .btn-sm { font-size: 11px; padding: 5px 8px; }

  #page-analytics [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  #page-schedules .section-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  #page-inventory .section-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }

  #page-knowledge .section-header { flex-wrap: wrap; }
  #page-knowledge .section-header > div:last-child { width: 100%; display: flex; gap: 6px; }
  #kb-search { width: 100% !important; min-width: 0; flex: 1; }

  #page-personnel .section-header { flex-wrap: wrap; gap: 8px; }
  #btn-add-person { flex-shrink: 0; }

  #page-analytics [style*="grid-template-columns"] { padding-left: 12px !important; padding-right: 12px !important; }
  #page-analytics .stats-grid { padding: 0 12px 12px !important; }

  #page-schedules > .section > div[style*="padding:0 16px"] { flex-wrap: wrap; padding: 0 12px 8px !important; }

  .section-header > div[style*="margin-left:auto"],
  .section-header > div[style*="margin-left: auto"] { margin-left: 0 !important; width: 100%; justify-content: flex-end; }

  .filters-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; padding-bottom: 4px !important; }
  .filter-chip { white-space: nowrap; flex-shrink: 0; font-size: 11px; }

  /* form-row — одна колонка на мобильном */
  .form-row { flex-direction: column; gap: 0; }

  .btn-sm { font-size: 11px; padding: 5px 10px; }
  .hide-mobile { display: none !important; }
  .hide-desktop { display: block !important; }
  button.hide-desktop { display: inline-flex !important; }
  #btn-new-task { padding: 6px 8px; }

  .person-card { padding: 12px; border-bottom: 1px solid var(--border-light); }
  .person-card:last-child { border-bottom: none; }
  .personnel-cards { padding: 0; }

  .calendar-grid { font-size: 11px; }
  .calendar-cell { min-height: 50px; padding: 2px; }


  .login-card { padding: 24px 20px 20px; }
}

/* =====================================================
   iOS PWA safe area
   ===================================================== */
@supports (padding-top: env(safe-area-inset-top)) {
  .sidebar { padding-top: env(safe-area-inset-top); }
  .header {
    padding-top: max(0px, env(safe-area-inset-top));
    height: calc(var(--header-h) + env(safe-area-inset-top));
  }
  /* СТРАХОВКА ОТ ШАПКИ ПОД ЧАСАМИ. С viewport-fit=cover приложение занимает
     весь экран, включая полосу статуса. На части Android env(safe-area-inset-top)
     при этом отдаёт НОЛЬ — отступа не добавляется, и содержимое шапки (заголовок,
     переключатель площадки) уезжает под часы: владелец видел от кнопки площадки
     только полоску. max() решает без вреда для устройств, которые отступ
     сообщают правильно: там побеждает их значение. Только телефоны — на
     установленном приложении для компьютера полоски статуса нет. */
  @media (display-mode: standalone) and (max-width: 900px) {
    .header {
      padding-top: max(28px, env(safe-area-inset-top));
      height: calc(var(--header-h) + max(28px, env(safe-area-inset-top)));
    }
  }
  .mobile-tabbar {
    /* подстраховка для старых браузеров без env() */
    padding-bottom: max(4px, calc(env(safe-area-inset-bottom, 0px) / 2));
  }
}

/* iOS/Android PWA — зелёная шапка как системный статус-бар */
@media (display-mode: standalone) {
  .header {
    background: var(--primary-hover) !important;
    border-bottom: none !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.1) !important;
  }

  /* Текст заголовка */
  .header-title, #header-title { color: #fff !important; }

  /* Все кнопки и иконки в хедере — белые */
  .header button,
  .header a,
  #sidebar-toggle-btn,
  #btn-header-qr,
  #notif-bell-btn,
  .header .btn-icon {
    color: rgba(255,255,255,.9) !important;
    border-color: rgba(255,255,255,.25) !important;
    background: transparent !important;
  }
  .header svg {
    stroke: rgba(255,255,255,.9) !important;
    color: rgba(255,255,255,.9) !important;
  }

  /* Бейдж уведомлений */
  #notif-badge { border: 2px solid var(--primary-hover); }

  /* SSE dot — белый когда онлайн, красный когда офлайн */
  #sse-dot { background: rgba(255,255,255,.7) !important; box-shadow: 0 0 0 2px rgba(255,255,255,.25) !important; }

  /* Кнопка Новая заявка — белая обводка */
  #btn-new-task {
    background: rgba(255,255,255,.15) !important;
    border: 1.5px solid rgba(255,255,255,.4) !important;
    color: #fff !important;
  }
  #btn-new-task svg { stroke: #fff !important; }
  #btn-new-task:hover {
    background: rgba(255,255,255,.25) !important;
  }

  /* Btn-toggle (collapse sidebar) */
  #sidebar-toggle-btn {
    background: rgba(255,255,255,.12) !important;
    border-color: rgba(255,255,255,.2) !important;
  }
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d0cb; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a29e; }

/* =====================================================
   PAGE / TABS
   ===================================================== */
.page { display: none; }
.page.active {
  display: block;
  flex: 1;          /* заполняет оставшееся место в .main */
  min-height: 0;    /* без этого flex-item не сжимается и не скроллит */
  overflow-y: auto; /* скролл страниц на ПК */
  overflow-x: hidden;
}
/* AI Chat — отдельная логика скролла, не трогаем */
#page-ai-chat.active {
  overflow: hidden !important;
}
.hide-desktop { display: none; }


/* =====================================================
   LOGIN
   ===================================================== */
/* ── LOGIN — стиль АгроТО лендинга ─────────── */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #faf9f6;
  padding: 24px;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  position: relative;
  overflow: hidden;
}
/* Декоративные круги фона */
.login-screen::before {
  content: '';
  position: fixed; top: -120px; right: -120px;
  width: 480px; height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61,153,102,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.login-screen::after {
  content: '';
  position: fixed; bottom: -100px; left: -100px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(30,92,58,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  background: #ffffff;
  border: 1px solid #e6e0d5;
  border-radius: 20px;
  padding: 44px 40px 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 40px rgba(23,54,38,0.10), 0 1px 4px rgba(0,0,0,0.05);
  position: relative; z-index: 1;
}
.login-logo {
  width: auto; height: auto;
  background: none;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  margin: 0 auto 6px;
}
.login-logo-mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: #1e5c3a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-logo-mark svg { color: #fff; width: 20px; height: 20px; }
.login-logo-name {
  font-size: 22px; font-weight: 700;
  color: #151515; letter-spacing: -0.03em;
  line-height: 1;
}
.login-title    { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; color: #151515; letter-spacing: -0.03em; display: none; }
.login-subtitle { text-align: center; font-size: 13px; color: #767676; margin-bottom: 32px; }
.login-error    { color: #e53e3e; font-size: 13px; text-align: center; margin-bottom: 0; background: transparent; border-radius: 8px; }
.login-error:not(:empty) { padding: 10px 12px; margin-bottom: 12px; background: #fff5f5; border: 1px solid #fed7d7; }
/* Поля ввода в стиле лендинга */
.login-screen .form-input {
  background: #faf9f6;
  border: 1.5px solid #e6e0d5;
  border-radius: 10px;
  color: #151515;
  font-family: 'Onest', sans-serif;
  font-size: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-screen .form-input:focus {
  border-color: #2d7d53;
  box-shadow: 0 0 0 3px rgba(45,125,83,0.12);
  background: #fff;
  outline: none;
}
.login-screen .form-input::placeholder { color: #a0aec0; }
/* Кнопка Войти */
.login-screen .btn-primary {
  background: #1e5c3a;
  border-radius: 10px;
  font-family: 'Onest', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 13px;
  letter-spacing: -0.01em;
  transition: background 0.2s ease, transform 0.15s ease;
}
.login-screen .btn-primary:hover { background: #173626; transform: translateY(-1px); }
.login-screen .btn-primary:active { transform: translateY(0); }
/* Подпись внизу */
.login-hint {
  margin-top: 16px; text-align: center;
  font-size: 12px; color: #a0aec0;
  font-family: 'Onest', sans-serif;
}
/* Ссылка на сайт внизу */
.login-site-link {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  font-family: 'Onest', sans-serif;
  font-size: 12px; color: #767676;
  text-decoration: none; z-index: 2;
  display: flex; align-items: center; gap: 5px;
}
.login-site-link:hover { color: #2d7d53; }

/* =====================================================
   SIDEBAR USER
   ===================================================== */
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  color: var(--text-sidebar);
  font-size: 13px; font-weight: 500;
  margin-bottom: 4px;
}
.sidebar-user svg { width: 17px; height: 17px; flex-shrink: 0; }

/* =====================================================
   DETAIL PAGE
   ===================================================== */
.detail-back { margin-bottom: 16px; }

/* ─── Detail Header (DS 2026) ─── */
.detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  box-shadow: var(--shadow-1);
}

.detail-header-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-header-icon svg { width: 28px; height: 28px; }

.detail-header-info { flex: 1; min-width: 0; }
.detail-header-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  /* Было 2 строки, и «Установка водоочистки…» упиралась в многоточие. У орг 3
     125 названий длиннее 40 знаков, самое длинное 82 — трёх строк хватает
     почти всем, а бегущая строка в ЗАГОЛОВКЕ выглядит нервно: место есть,
     проще перенести. */
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-header-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 12.5px;
}
.detail-header-sub span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.detail-header-sub svg { width: 12px; height: 12px; }

.detail-header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.detail-header-status .badge {
  font-size: 12px;
  padding: 0 12px;
  height: 26px;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
  max-width: 1200px;
}
.detail-main { min-width: 0; }
.detail-back { margin-bottom: 12px; }
.detail-header { max-width: 1200px; }

/* Содержимое страницы сотрудника держим в той же колонке, что и шапка.
   Без этого шапка обрывалась на 1200px, а показатели и список задач ехали
   на всю ширину монитора — строки становились нечитаемо длинными. */
/* Ограничиваем по ширине только экраны, которые ЧИТАЮТ: страницу сотрудника
   и карточку участка. Сами дашборды остаются во всю ширину — это экраны
   наблюдения, там смотрят «сколько горит», и лишнее место работает на пользу.
   ВАЖНО: не класть эти правила в общий блок #page-dashboard .v4-shell — он
   покрывает и «Главный», и скелетон, и я так уже прижал главный экран,
   которого не трогал. */
#person-pane-stats { max-width: 1200px; }
#page-dashboard .v4-shell.drilldown { max-width: 1200px; }


/* ─── Spec table (DS 2026) ─── */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--duration-fast) var(--ease);
}
.spec-table tr:last-child { border-bottom: none; }
.spec-table tr:hover { background: var(--bg-muted); }
.spec-table td { padding: 12px 20px; font-size: 13px; vertical-align: top; }
.spec-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  width: 160px;
  white-space: nowrap;
  font-size: 12px;
}
.spec-table td:last-child { font-weight: 500; color: var(--text); }

/* ─── Mini stats (DS 2026) ─── */
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-light);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.mini-stat { background: var(--bg-card); padding: 18px; text-align: center; }
.mini-stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  line-height: 1;
  margin-bottom: 4px;
}
.mini-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Timeline */
.timeline-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-light); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.timeline-info { flex: 1; min-width: 0; }
.timeline-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.timeline-meta  { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.timeline-notes { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-header { flex-wrap: wrap; }
  .spec-table td:first-child { width: 130px; }
}

/* =====================================================
   CHECKLIST
   ===================================================== */
.checklist-progress-bar {
  height: 3px; background: var(--border-light);
  border-radius: 2px; margin: 0 18px 8px; overflow: hidden;
}
.checklist-progress-fill {
  height: 100%; background: var(--primary);
  border-radius: 2px; transition: width .3s ease;
}
.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background .13s;
}
.checklist-item:hover { background: var(--bg-muted); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item.checked { opacity: .55; }
.checklist-item.has-problem { background: #fef2f2 !important; border-left: 3px solid #ef4444; }
.checklist-item.has-problem:hover { background: #fee2e2 !important; }
.checklist-problem-btn {
  cursor: pointer; display:flex; align-items:center; padding:4px; border-radius:6px;
  color: var(--text-muted); background: none; border: none;
  transition: all .14s; flex-shrink: 0;
}
.checklist-problem-btn:hover { color: #ef4444; background: #fef2f2; }
.checklist-problem-btn.active { color: #ef4444; background: #fee2e2; }
.checklist-photo-area { padding: 0 0 4px 0; }
.checklist-checkbox {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px; transition: all .13s;
}
.checklist-checkbox.checked { background: var(--primary); border-color: var(--primary); color: #fff; }
.checklist-title { font-size: 13px; font-weight: 500; line-height: 1.4; }
.checklist-item.checked .checklist-title { text-decoration: line-through; }
.checklist-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.checklist-text { flex: 1; min-width: 0; }


/* =====================================================
   DATA TABLES
   ===================================================== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: var(--bg-muted); padding: 8px 12px;
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
/* Зебра — чётные строки чуть темнее (порядок важен: zebra → hover → warning) */
.data-table tbody tr:nth-child(even) { background: #f8fafc; }
.data-table-row:hover { background: var(--bg-muted); }
.data-table-row.row-warning,
.data-table tbody tr.row-warning:nth-child(even) { background: #fef2f2; }
.data-table-row.row-warning:hover { background: #fee2e2; }
.data-table-row { cursor: pointer; transition: background .1s; }
.data-table-row td:first-child { font-weight: 500; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.status-dot.active        { background: var(--success); }
.status-dot.maintenance   { background: var(--warning); }
.status-dot.broken        { background: var(--destructive); }
.status-dot.decommissioned{ background: #a8a29e; }


/* =====================================================
   FORM ROW
   ===================================================== */
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* =====================================================
   ANALYTICS
   ===================================================== */
@media (max-width: 900px) {
  #page-analytics > div[style*="grid-template-columns: 2fr"]    { grid-template-columns: 1fr !important; }
  #page-analytics > div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* =====================================================
   KNOWLEDGE BASE
   ===================================================== */
#article-content h3 { font-size: 16px; }
#article-content h4 { font-size: 14px; }
#article-content table { border-collapse: collapse; }
#article-content ul { padding-left: 20px; }
#article-content li { margin: 4px 0; }
#article-content code { background: var(--bg-muted); padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; }

/* =====================================================
   CHECKLIST PHOTOS
   ===================================================== */
.checklist-photo-btn { cursor:pointer; display:flex; align-items:center; padding:4px; border-radius:6px; color:var(--text-muted); transition:all .14s; }
.checklist-photo-btn:hover { color:var(--primary); background:var(--bg-muted); }
.checklist-photos { display:flex; flex-wrap:wrap; gap:6px; padding:6px 0 2px 34px; }
.checklist-photo-thumb { position:relative; width:64px; height:64px; border-radius:8px; overflow:hidden; border:1px solid var(--border-light); cursor:pointer; transition:transform .14s; }
.checklist-photo-thumb:hover { transform:scale(1.05); }
.checklist-photo-thumb img { width:100%; height:100%; object-fit:cover; }
.checklist-photo-del { position:absolute; top:2px; right:2px; background:rgba(0,0,0,.55); color:#fff; border:none; border-radius:50%; width:18px; height:18px; font-size:10px; cursor:pointer; display:none; align-items:center; justify-content:center; }
.checklist-photo-thumb:hover .checklist-photo-del { display:flex; }

/* GPS подозрение — фото сделано не у оборудования */
.checklist-photo-thumb.gps-suspicious { border:2px solid #ef4444; box-shadow:0 0 0 2px rgba(239,68,68,0.18); }
.checklist-photo-thumb .gps-warn-badge {
  position:absolute; bottom:2px; left:2px;
  background:#ef4444; color:#fff;
  border-radius:6px; padding:1px 5px;
  font-size:11px; font-weight:700;
  line-height:1.3;
  box-shadow:0 1px 3px rgba(0,0,0,.25);
  pointer-events:auto; cursor:help;
}


/* =====================================================
   CALENDAR
   ===================================================== */
@media (max-width: 900px) {
  #page-dashboard > div[style*="grid-template-columns: 340px"] { grid-template-columns: 1fr !important; }
}

/* =====================================================
   MOBILE TAB BAR
   ===================================================== */
.mobile-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  /* Высота = контент 64px + половина safe-area (home indicator на iPhone).
     Полная safe-area (34px) даёт лишний воздух — оставляем ~12-16px. */
  height: calc(64px + max(4px, env(safe-area-inset-bottom, 0px) / 2));
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 40;
  padding: 0 4px;
  padding-bottom: max(4px, calc(env(safe-area-inset-bottom, 0px) / 2));
  box-sizing: border-box;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 6px 8px;
  color: #9ca3af; text-decoration: none;
  font-size: 10px; font-weight: 500; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 0; flex: 1; text-align: center;
  position: relative;
  border: none; background: none;
  border-radius: 12px;
  transition: background .15s, color .15s;
}
/* Активная вкладка — зелёная подложка (как в Telegram) */
.tab-item.active {
  color: var(--primary);
  background: none;
}
.tab-item.active svg { color: var(--primary); }
.tab-item.active span { color: var(--primary); font-weight: 700; }
.tab-item span {
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%;
  line-height: 1;
  font-size: 10px;
}
.tab-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.tab-item:active { opacity: .75; }
.tab-item-add { padding: 0; overflow: visible; flex: 0 0 auto; background: none !important; }
.tab-add-btn {
  width: 48px; height: 48px; border-radius: 16px;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(45,125,83,.4);
  transition: transform .12s ease;
  flex-shrink: 0;
}
.tab-add-btn svg    { width: 24px; height: 24px; }
.tab-add-btn:active { transform: scale(.9); }

@media (max-width: 767px) {
  .mobile-tabbar { display: flex; }
  /* padding-bottom для страниц теперь через .page.active, не через .main */
  .main { padding-bottom: 0; }
  #btn-new-task { display: none !important; }
  body { overflow-x: hidden; max-width: 100vw; }
}

/* =====================================================
   REFERENCE TABLES
   ===================================================== */
.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ref-table th { text-align: left; padding: 10px 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.ref-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover { background: var(--bg-muted); }
/* Разворот ветки локаций: кликается всё название, а не стрелка 12×12.
   На телефоне попасть в маленькую стрелку пальцем невозможно. */
.loc-branch-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; padding: 6px 8px 6px 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
  min-height: 36px;
}
.loc-branch-toggle:hover { color: var(--primary); }
.loc-branch-toggle svg { flex: 0 0 auto; }
.loc-branch-count {
  font-size: 11px; font-weight: 400; color: var(--text-muted);
  background: var(--bg-secondary); border-radius: 10px; padding: 2px 8px; white-space: nowrap;
}

/* Колонка действий: кнопки в один ряд, ширина по содержимому */
.ref-table td:last-child { white-space: nowrap; width: 1%; }
.ref-table td:last-child .btn-icon { vertical-align: middle; }

@media (max-width: 767px) {
  /* На телефоне таблица справочников разворачивается в карточки: шапка прячется,
     каждая строка — блок, подписи колонок подставляются из data-label.
     Горизонтальный скролл при этом исчезает совсем. */
  #ref-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  #ref-tabs .filter-chip { white-space: nowrap; flex-shrink: 0; }
  #ref-content { overflow-x: hidden; }

  .ref-table, .ref-table tbody, .ref-table tr, .ref-table td { display: block; width: 100%; }
  .ref-table thead { display: none; }
  .ref-table tr {
    border: 1px solid var(--border-light); border-radius: 12px;
    padding: 10px 12px; margin-bottom: 10px; background: var(--bg-card);
  }
  .ref-table tr:hover { background: var(--bg-card); }
  .ref-table td {
    border: none; padding: 4px 0; font-size: 13px;
    display: flex; gap: 8px; align-items: flex-start; justify-content: space-between;
    white-space: normal; word-break: break-word;
  }
  .ref-table td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 45%;
    color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
    padding-top: 2px;
  }
  .ref-table td:empty, .ref-table td[data-label='']::before { display: none; }
  /* Название — первой строкой, крупно и без подписи */
  .ref-table td:first-child { font-size: 15px; font-weight: 600; padding-bottom: 6px; }
  /* Раскрывашка на телефоне — во всю ширину строки, палец попадает гарантированно */
  .ref-table .loc-branch-toggle { width: 100%; justify-content: flex-start; min-height: 44px; }
  .ref-table .loc-branch-count { margin-left: auto; }
  .ref-table td:first-child::before { display: none; }
  /* Кнопки действий — в ряд по правому краю, не переносятся и не растягиваются.
     ШИРИНУ ЗАДАЁМ ЯВНО: десктопное `.ref-table td:last-child { width: 1% }`
     специфичнее общего `.ref-table td { width: 100% }` и переживает медиа-запрос —
     ячейка схлопывалась в ~3 px, ряд кнопок уезжал за левый край и срезался
     `#ref-content { overflow-x: hidden }`. На телефоне из четырёх кнопок
     оставалась видна одна. */
  .ref-table td:last-child {
    width: 100%; white-space: normal;
    justify-content: flex-end; padding-top: 10px; margin-top: 6px;
    border-top: 1px solid var(--border-light); gap: 8px; flex-wrap: wrap;
  }
  .ref-table td:last-child::before { display: none; }
  /* Палец в 28 px не попадает — на телефоне кнопки крупнее */
  .ref-table td:last-child .btn-icon { flex: 0 0 auto; width: 40px; height: 40px; }
  .ref-table td:last-child .btn-icon svg { width: 18px; height: 18px; }
}

/* =====================================================
   NOTIFICATION DROPDOWN
   ===================================================== */
@media (max-width: 767px) {
  .notif-dropdown-wrap {
    position: fixed !important; top: 60px !important;
    left: 12px !important; right: 12px !important;
    width: auto !important; max-height: 70vh !important; margin-top: 0 !important;
  }
}

/* =====================================================
   INVENTORY CHIPS
   ===================================================== */
#inventory-chips::-webkit-scrollbar { display: none; }
#inventory-chips { -ms-overflow-style: none; scrollbar-width: none; }

/* Task cursor hover */
.task-info[style*="cursor"] .task-title:hover { color: var(--primary); }
.btn.btn-outline.btn-full { display: flex; align-items: center; gap: 8px; }
.eq-card { cursor: pointer; }
.task-item[style*="cursor"] .task-info:hover .task-title { color: var(--primary); }

/* =====================================================
   TASK DETAIL — ACTION BUTTONS
   ===================================================== */
/* ─── Action Buttons (DS 2026) ─── */
.task-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  border: none;
  margin-bottom: 8px;
  text-decoration: none;
  letter-spacing: .01em;
}
.task-action-btn:last-child { margin-bottom: 0; }
.task-action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Primary — start/take */
.task-action-start {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(16,185,129,.25);
}
.task-action-start:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(16,185,129,.35);
  transform: translateY(-1px);
}

/* Success outline — complete */
.task-action-complete {
  background: var(--success-light);
  color: #173626;
  border: 1.5px solid #a8ddb8;
}
.task-action-complete:hover {
  background: #d6f0df;
  border-color: var(--success);
}

/* Ghost — edit/print */
.task-action-edit, .task-action-print {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.task-action-edit:hover, .task-action-print:hover {
  background: var(--border-light);
  color: var(--text);
}

/* Danger — cancel/delete */
.task-action-cancel, .task-action-delete {
  background: var(--destructive-light);
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.task-action-cancel:hover, .task-action-delete:hover {
  background: #FEE2E2;
  border-color: #FCA5A5;
}
.task-action-delete { margin-top: 4px; }

/* ─── Status Banners (DS 2026) ─── */
.task-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.task-status-banner.in-progress {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1E40AF;
}
.task-status-banner.done {
  background: var(--success-light);
  border: 1px solid #a8ddb8;
  color: #173626;
  flex-direction: column;
  text-align: center;
  padding: 24px 20px;
  gap: 8px;
  border-radius: 12px;
}
.task-status-banner.done svg { width: 32px; height: 32px; }

/* Разделитель в блоке действий */
.task-actions-divider {
  height: 1px;
  background: var(--border-light);
  margin: 10px 0;
}

/* =====================================================
   EQUIPMENT CARDS — улучшенный hover
   ===================================================== */
.eq-card {
  position: relative;
  overflow: hidden;
}
/* eq-card stripe — задаётся через JS inline style */

/* =====================================================
   DETAIL HEADER — убираем скучный серый фон
   ===================================================== */
.detail-header {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-muted) 100%);
}

/* =====================================================
   SECTION с иконкой — чуть живее
   ===================================================== */
.section-header {
  background: var(--bg-card);
}
.section:first-child .section-header {
  border-radius: var(--radius) var(--radius) 0 0;
}

/* =====================================================
   STAT CARDS — акцентная полоска
   ===================================================== */
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover::after { opacity: 1; }
.stat-card.danger::after   { background: var(--destructive); }
.stat-card.warning::after  { background: var(--warning); }
.stat-card.info::after     { background: var(--info); }
.stat-card.success::after  { background: var(--success); }
.stat-card.purple::after   { background: var(--purple); }

/* =====================================================
   ПРИОРИТЕТНЫЙ БАР — чуть толще, красивее
   ===================================================== */
.task-priority-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 3px;
  flex-shrink: 0;
  min-height: 32px;
}

/* =====================================================
   HEADER кнопки — чуть живее
   ===================================================== */
.btn-primary {
  box-shadow: 0 1px 3px rgba(22,163,74,.2);
}
.btn-primary:hover {
  box-shadow: 0 3px 10px rgba(22,163,74,.35);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

/* =====================================================
   SECTION — первый section на странице без верхней тени
   ===================================================== */
.section + .section {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.section:first-of-type {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.section:only-of-type {
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════════════════
   OCC DASHBOARD v4 — Stripe/Linear style
   ═══════════════════════════════════════════════════ */
/* ── UNIFIED SHELL ── */
.v4-shell {
  background: #fff;
  border: var(--ui-border);
  border-radius: var(--ui-r-xl);
  margin: 16px 20px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.v4-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
}


/* ── GREETING ── */
/* v4-greeting removed — now v4-header */
.v4-greeting-text {
  font-family: 'Manrope', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
}
.v4-greeting-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.v4-greeting-sub .occ-pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  vertical-align: middle;
  margin-right: 1px;
  animation: v4-pulse 2s ease-in-out infinite;
}
@keyframes v4-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.v4-greeting-sub .occ-pulse.danger { background: #ef4444; }

/* ── KPI ROW — plain numbers ── */
.v4-kpi-row {
  display: flex;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 0;
}
.v4-kpi-item {
  flex: 1;
  padding: 8px 16px;
  border-left: 1px solid var(--border-light);
  cursor: pointer;
  transition: all .12s;
  border-radius: 8px;
  margin: -4px 0;
}
.v4-kpi-item:first-child {
  border-left: none;
  padding-left: 4px;
}
.v4-kpi-item:hover {
  background: var(--bg-muted);
}
.v4-kpi-item.card-active {
  background: var(--primary-light);
  border-color: transparent;
}
.v4-kpi-num {
  font-family: 'Manrope', sans-serif;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.8px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.v4-kpi-num.danger { color: #ef4444; }
.v4-kpi-num.warning { color: #f59e0b; }
.v4-kpi-num.purple { color: #8b5cf6; }
.v4-kpi-num.success { color: #22c55e; }
.v4-kpi-num.muted { color: var(--text-muted); }
/* «Мои задачи» — фирменный зелёный: плитка про принадлежность, а не про
   тревогу, поэтому красный и оранжевый тут не годятся. */
.v4-kpi-num.primary { color: var(--primary); }

/* Строка дополнительных плиток («Мои задачи», «Склад»). Делят ширину поровну:
   одна — во всю строку, две — пополам. Так седьмая плитка не висит обрубком
   на треть ряда, как было на АгроМилке. */
.v4-kpi-row-extra {
  padding-top: 0;
  border-top: none;
}
.v4-kpi-row-extra .v4-kpi-item {
  flex: 1 1 0 !important;
  border-left: none;
  text-align: center;
}
.v4-kpi-row-extra .v4-kpi-item + .v4-kpi-item {
  border-left: 1px solid var(--border-light);
}
.v4-kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 3px;
}

/* ── MAIN GRID ── */
.v4-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  padding: 0;
  align-items: start;
}

/* ── SECTION LABEL ── */
.v4-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── BACK BTN ── */
.occ-back-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--primary);
  background: var(--primary-light); border: none;
  border-radius: var(--ui-r); padding: 3px 8px;
  cursor: pointer; transition: all .15s;
  margin-left: auto;
}
.occ-back-btn:hover { background: #dcfce7; }

/* ── FEED ── */
.v4-feed {
  min-width: 0;
  padding: 16px 20px 20px;
  border-right: 1px solid var(--border-light);
}
.v4-feed-scroll {
  border: var(--ui-border);
  border-radius: var(--ui-r-lg);
  overflow: hidden;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  background: #fff;
}
.v4-feed-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ── GROUP HEADER ── */
.v4-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  list-style: none;
  border-top: 1px solid var(--border-light);
}
.v4-group-header:first-child { border-top: none; }
.v4-group-header.group-overdue {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.v4-group-header.group-in_progress {
  background: #f5f3ff;
  color: #5b21b6;
  border-color: #ede9fe;
}
.v4-group-header.group-today {
  background: #fffbeb;
  color: #92400e;
  border-color: #fef3c7;
}
.v4-group-header.group-upcoming {
  background: var(--bg-muted);
  color: var(--text-muted);
  border-color: var(--border-light);
}
.v4-group-header.group-completed {
  background: #eef8f2;
  color: #166534;
  border-color: #dcfce7;
}
.v4-group-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.v4-group-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--ui-r);
  background: rgba(0,0,0,.06);
}

/* ── TASK ROW ── */
.occ-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 16px;
  cursor: pointer;
  border: none;
  transition: background .08s;
  position: relative;
  min-height: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  flex-direction: row;
  animation: none;
}
.occ-card::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--occ-accent, #d1d5db);
}
.occ-card:hover { background: #f5f7fa; }
.occ-card + .occ-card {
  border-top: none;
}
/* Separator line between cards */
.v4-feed-list .occ-card + .occ-card::after {
  content: '';
  position: absolute;
  top: 0; left: 14px; right: 14px;
  height: 1px;
  background: var(--border-light);
}
/* No separator after group header */
.v4-group-header + .occ-card::after { display: none; }

/* Priority accents */


/* status accent removed — type_color via inline style takes priority */


/* Critical bg */
.occ-card.priority-critical { background: #fffbfb; }
.occ-card.priority-critical:hover { background: #fef5f5; }

/* Card internals — now horizontal layout */
.occ-card-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.occ-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}
.occ-card-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: .3px;
  text-transform: uppercase;
  align-self: flex-start;
}
.badge-occ-overdue  { background: #ef4444; color: #fff; }
.badge-occ-pending  { background: #f3f4f6; color: #6b7280; }
.badge-occ-progress { background: #8b5cf6; color: #fff; }
.badge-occ-today    { background: #f59e0b; color: #fff; }
.badge-occ-done     { background: #22c55e; color: #fff; }

.occ-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.occ-card-meta-item {
  display: flex; align-items: center; gap: 3px;
}
.occ-card-meta-item svg { opacity: .5; flex-shrink: 0; }

.occ-card-deadline {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--ui-r);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.occ-card-deadline.overdue { background: #fef2f2; color: #dc2626; }
.occ-card-deadline.today   { background: #fffbeb; color: #b45309; }
.occ-card-deadline.soon    { background: #eef8f2; color: var(--primary); }
.occ-card-deadline.future  { background: var(--bg-muted); color: var(--text-muted); }
.occ-card-deadline.done    { background: #eef8f2; color: #16a34a; }

/* Action buttons on task cards */
.occ-action-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.occ-action-btn:hover { border-color: var(--primary); color: var(--primary); background: #eef8f2; }
.occ-action-done:hover { border-color: #16a34a; color: #16a34a; background: #eef8f2; }
.occ-card-mine { background: #eff6ff !important; }
.occ-card-mine:hover { background: #e8f1fd !important; }

/* Tasks page uses occ-card list inside .task-list */
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list .occ-card + .occ-card::after {
  content: ''; position: absolute;
  top: 0; left: 14px; right: 14px;
  height: 1px; background: var(--border-light);
}
.task-list .v4-group-header + .occ-card::after { display: none; }

/* Чужие задачи */


/* ── EMPTY STATE ── */
.occ-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}
.occ-empty-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: #eef8f2;
  display: flex; align-items: center; justify-content: center;
  color: #22c55e;
}
.occ-empty-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.occ-empty-sub { font-size: 12px; color: var(--text-muted); }

/* ── CALENDAR ── */
.v4-right {
  min-width: 0;
  padding: 16px 20px 20px;
}
.v4-cal-wrap {
  border: var(--ui-border);
  border-radius: var(--ui-r-lg);
  overflow: hidden;
  background: #fff;
}

/* ── RESPONSIVE ── */

@media (max-width: 767px) {
  .v4-shell { margin: 8px; border-radius: 10px; }
  .v4-header { padding: 12px 14px 10px; }
  .v4-greeting-text { font-size: 17px; }
  .v4-kpi-row {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 0;
  }
  .v4-kpi-item {
    flex: 0 0 33.33%;
    padding: 6px 10px;
    border-left: none;
  }
  .v4-kpi-item:nth-child(n+4) {
    border-top: 1px solid var(--border-light);
    margin-top: 6px;
    padding-top: 10px;
  }
  .v4-kpi-num { font-size: 22px; }
  .v4-grid {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
  }
  .v4-feed { padding: 12px; border-right: none; }
  .v4-right { padding: 12px; order: -1; border-bottom: 1px solid var(--border-light); }
  .v4-right { order: -1; }
  .v4-cal-wrap #calendar-widget { width: 100%; }
  .v4-cal-wrap #calendar-widget > div {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px !important;
  }
  .v4-cal-wrap table { width: 100% !important; table-layout: fixed !important; }
  .v4-feed-scroll { max-height: 60vh; }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { transform: translateX(-100%) !important; }
  .sidebar.mobile-open { transform: translateX(0) !important; }
  .main { margin-left: 0 !important; }
  .mobile-tabbar { display: flex !important; }
  .v4-shell { margin: 12px; }
  .v4-grid { grid-template-columns: 1fr 300px; gap: 0; padding: 0; }
  .v4-kpi-row { padding: 12px 16px; }
  .v4-header { padding: 14px 16px 10px; }
}


/* ── Calendar unification ── */
.v4-cal-wrap .btn-icon {
  width: 28px;
  height: 28px;
  border: var(--ui-border);
  border-radius: var(--ui-r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
  padding: 0;
}
.v4-cal-wrap .btn-icon:hover {
  background: var(--bg-muted);
  color: var(--text);
  border-color: var(--border);
}
.v4-cal-wrap .btn-icon svg { width: 14px; height: 14px; }

/* ─── GLOBAL 2026 UPGRADES ─── */

/* Заголовки страниц */
.header-title, #header-title {
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
  letter-spacing: -.02em !important;
}

/* Все detail-header-name */
.detail-header-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.02em;
}

/* Название ЗАДАЧИ — целиком, без многоточия. Три строки хватало не всем:
   «Регулировка температуры охлаждения...» упиралась в обрез, а человеку надо
   понять, что именно за работа (замечание владельца 19.08.2026). Карточка
   оборудования уже показывает название полностью — приводим к ней. */
#page-task-detail .detail-header-name {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  overflow-wrap: anywhere;
}

/* Кнопки — мягче радиус */
.btn {
  border-radius: var(--ui-r) !important;
}
.btn-primary {
  box-shadow: 0 1px 3px rgba(22,163,74,.2);
}
.btn-primary:hover {
  box-shadow: 0 3px 10px rgba(22,163,74,.3);
  transform: translateY(-1px);
}

/* Модальные окна — новый стиль */
.modal-content, .modal-body {
  border-radius: var(--ui-r-xl) !important;
}

/* Входящие list items — subtle hover */
.task-item:hover { background: var(--bg-muted); }
.task-item:last-child { border-bottom: none; }

/* Бейджи — чуть мягче */
.badge {
  border-radius: var(--ui-r) !important;
  font-weight: 600 !important;
}

/* Detail grid header */
.detail-header {
  border-radius: var(--radius) !important;
}

/* Stat cards на других страницах — обновлённые */
.stat-card {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-1px);
}

/* Filter chips — мягче */
.filter-chip {
  border-radius: var(--ui-r) !important;
}

/* Form inputs — новый радиус */
.form-input, input[type="text"], input[type="tel"], input[type="email"],
input[type="password"], input[type="number"], input[type="date"],
select, textarea {
  border-radius: var(--ui-r) !important;
}

/* Page content slide-in — убрана, вызывала layout thrashing */
/* .page.active > * { animation: page-in .2s ease-out; } */


/* Чужие задачи — полоска через --occ-accent (inline), чуть прозрачнее */
.occ-card.occ-card-other { opacity: .85; }
.occ-card.occ-card-other:hover { opacity: 1; background: #f5f7fa; }

/* Скрываем бейдж "Система работает" на мобиле */
@media (max-width: 767px) {
  .occ-status-dot { display: none; }
}

/* Приоритеты: только critical (красный) и normal (зелёный/серый) */
.occ-card.priority-high { background: #fff; }

/* ═══════════════════════════════════════════════════
   DESIGN SYSTEM 2026 — Component Tokens
   ═══════════════════════════════════════════════════ */

/* ── Status Chips (pills) ── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.chip-success  { background: var(--success-light);     color: #15803d; }
.chip-warning  { background: var(--warning-light);     color: #b45309; }
.chip-danger   { background: var(--destructive-light); color: #b91c1c; }
.chip-info     { background: var(--info-light);        color: #1d4ed8; }
.chip-muted    { background: var(--bg-muted);          color: var(--text-muted); }
.chip-purple   { background: var(--purple-light);      color: #6d28d9; }

/* Status-specific */
.chip-in-progress  { background: #EFF6FF; color: #1d4ed8; }


/* ── Updated section ── */
.section {
  box-shadow: var(--shadow-1) !important;
}
.section:hover {
  box-shadow: var(--shadow-2) !important;
}

/* ── Updated buttons ── */
.btn {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--ui-r) !important;
  transition: all var(--duration-fast) var(--ease);
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: var(--ui-r) !important; }

.btn-primary {
  background: var(--primary);
  box-shadow: 0 1px 3px rgba(16,185,129,.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(16,185,129,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-1); }

/* ── Updated task rows ── */
.task-item {
  min-height: var(--density-row, 64px) !important;
  padding: 0 18px !important;
  transition: background var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease) !important;
}
.task-item:hover {
  background: var(--bg-muted) !important;
}

/* ── KPI numbers ── */
.stat-card-value {
  font-family: var(--font-display) !important;
  font-size: 28px !important;
  font-weight: 800 !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -.04em !important;
  line-height: 1 !important;
}

/* ── Smooth page transitions ── */
.page { transition: opacity var(--duration-fast) var(--ease); }
.page.active { animation: ds-fadein var(--duration-normal) var(--ease); }
@keyframes ds-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ─── Мобиль: скрываем в sidebar пункты которые есть в нижнем табе ─── */
@media (max-width: 767px) {
  .sidebar .nav-item[data-page="dashboard"],
  .sidebar .nav-item[data-page="tasks"],
  .sidebar .nav-item[data-page="emergencies"] {
    display: none !important;
  }
}

/* Searchable dropdown */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: #fff; border: 1.5px solid var(--primary); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.search-dropdown .sd-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}
.search-dropdown .sd-item:last-child { border-bottom: none; }
.search-dropdown .sd-item:hover, .search-dropdown .sd-item.active {
  background: var(--primary-light); color: var(--primary-dark);
}
.search-dropdown .sd-item .sd-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.search-dropdown .sd-empty {
  padding: 12px; text-align: center; font-size: 12px; color: var(--text-muted);
}

/* ─── Tasks Calendar ─── */
.cal-grid-header { display:grid; grid-template-columns:repeat(7,1fr); margin-bottom:4px; }
.cal-grid        { display:grid; grid-template-columns:repeat(7,1fr); gap:3px; }
.cal-cell {
  min-height:64px; padding:6px; border-radius:8px;
  border:1px solid var(--border-light);
  transition:background var(--duration-fast) var(--ease);
  overflow:hidden;
}
.cal-cell:hover:not(.cal-cell-empty) { background:var(--bg-muted); }
.cal-cell-empty { border:none; background:transparent; }
.cal-day-num { font-size:12px; font-weight:600; line-height:1; }
@media (max-width:600px) {
  .cal-cell { min-height:44px; padding:4px; }
  .cal-day-num { font-size:11px; }
}



/* ═══════════════════════════════════════════════════
   PAGE LAYOUT — Tabler-inspired (2026)
   ═══════════════════════════════════════════════════ */

/* ── Page Shell — единый белый контейнер страницы ── */
.page-shell {
  background: #fff;
  border: var(--ui-border);
  border-radius: var(--ui-r-xl);
  margin: 16px 20px;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
/* Сохраняем скруглённые углы у первого и последнего дочернего элемента */
.page-shell > *:first-child { border-radius: var(--ui-r-xl) var(--ui-r-xl) 0 0; overflow: hidden; }
.page-shell > *:last-child  { border-radius: 0 0 var(--ui-r-xl) var(--ui-r-xl); overflow: hidden; }

/* ── Page Header — заголовок страницы (Tabler style) ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
  min-height: 56px;
}
.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.page-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-title svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Page Filters Bar ── */
.page-filters {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.page-filters:empty { display: none; }

/* ── Page Body — область контента ── */
.page-body { }
.page-body .task-list { }

/* ── Страницы с таблицей — убираем лишние отступы ── */
.page-shell .data-table { border-radius: 0; }
.page-shell .filters-bar { padding: 10px 20px; border-bottom: 1px solid var(--border-light); }

/* Mobile */
@media (max-width: 767px) {
  .page-shell { margin: 8px; border-radius: 10px; }
  .page-header { padding: 12px 14px; min-height: 48px; }
  .page-title { font-size: 15px; }
  .page-header-actions { gap: 6px; }
  .page-filters { padding: 8px 12px; }
}

/* ── Page Filters — inputs/selects не растягиваются на всю ширину ── */
.page-filters .form-select,
.page-filters select {
  width: auto !important;
  min-width: 120px;
  max-width: 220px;
  flex-shrink: 0;
}
.page-filters .form-input,
.page-filters input[type="text"] {
  width: auto !important;
  min-width: 160px;
}

/* ── Inventory filters — горизонтальная строка фильтров ── */
.inv-filters-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
}
.inv-filters-row .form-select,
.inv-filters-row select {
  width: auto !important;
  min-width: 0;
  flex: 1 1 140px;
  max-width: 200px;
  height: 36px;
  font-size: 13px;
  text-overflow: ellipsis;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px !important;
  cursor: pointer;
}
.inv-filters-row .form-input {
  width: auto !important;
  min-width: 0;
  flex: 1 1 160px;
  max-width: 240px;
  height: 34px;
  font-size: 13px;
}
@media (max-width: 900px) {
  .inv-filters-row { flex-wrap: wrap; }
  .inv-filters-row .form-select,
  .inv-filters-row select { flex: 1 1 120px; max-width: none; }
  .inv-filters-row .inv-search-wrap { flex: 1 1 100%; max-width: none; }
}
.inv-filters-row .inv-search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 280px;
}
.inv-filters-row .inv-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.inv-filters-row .inv-search-wrap input {
  padding-left: 32px !important;
  width: 100% !important;
}

/* ── Action buttons in tables (edit/delete) — красивее ── */
.ref-table .btn-icon,
.data-table .btn-icon,
.task-list .btn-icon {
  width: 28px; height: 28px;
  border-radius: var(--ui-r);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all .12s;
}
.ref-table .btn-icon:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.ref-table .btn-icon.danger:hover,
.ref-table .btn-icon[onclick*="delete"]:hover,
.ref-table .btn-icon[onclick*="Delete"]:hover { border-color: var(--destructive); background: var(--destructive-light); color: var(--destructive); }

/* Кнопка редактирования в таблице склада */
.data-table .btn.btn-outline.btn-sm {
  border-color: var(--border);
  color: var(--text-muted);
  background: var(--bg-card);
}
.data-table .btn.btn-outline.btn-sm:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ═══════════════════════════════════════════════════
   BEAUTIFUL SELECT — кастомная стрелка, чистый вид
   ═══════════════════════════════════════════════════ */
.inv-filters-row select,
.inv-filters-row .form-select,
.page-filters select,
.page-filters .form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--ui-r) !important;
  background-color: var(--bg-card) !important;
  color: var(--text) !important;
  font-size: 13px !important;
  font-family: var(--font) !important;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  height: 34px !important;
  line-height: 1;
}
.inv-filters-row select:focus,
.inv-filters-row .form-select:focus,
.page-filters select:focus,
.page-filters .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-ring) !important;
  outline: none;
}
.inv-filters-row select:hover,
.page-filters select:hover {
  border-color: #CBD5E1 !important;
}

/* Опции в выпадающем — нативные, но хоть цвет */
.inv-filters-row select option,
.page-filters select option {
  font-size: 13px;
  padding: 6px 12px;
  color: var(--text);
  background: var(--bg-card);
}

/* ═══════════════════════════════════════════════════
   MOBILE — полный аудит всех page-shell страниц
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* page-header mobile — кнопка под заголовком */
  .page-header {
    flex-wrap: wrap;
    gap: 0;
    padding-bottom: 12px;
  }
  .page-header-left { flex: 1 1 100%; min-width: 0; margin-bottom: 10px; }
  .page-header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header-actions .btn {
    flex: 0 0 auto;
  }

  /* Аналитика — гриды в колонку */
  #page-analytics .page-shell > div[style*="grid-template-columns:2fr"],
  #page-analytics .page-shell > div[style*="grid-template-columns: 2fr"],
  #page-analytics .page-shell > div[style*="grid-template-columns:1fr 1fr"],
  #page-analytics .page-shell > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* KPI ряд аналитики */
  #analytics-kpi { padding: 12px !important; }
  #analytics-kpi .stat-card { min-width: 0; padding: 10px 8px; flex-direction: column; align-items: center; gap: 4px; }
  #analytics-kpi .stat-card-value { font-size: 18px !important; }

  /* Inventory KPI row */
  #inventory-summary { flex-wrap: wrap; }
  #inventory-summary .v4-kpi-item {
    flex: 1 1 45%;
    border-top: 1px solid var(--border-light);
    border-left: none !important;
  }
  #inventory-summary .v4-kpi-item:first-child,
  #inventory-summary .v4-kpi-item:nth-child(2) { border-top: none; }
  #inventory-summary .v4-kpi-item:nth-child(odd) { border-left: none !important; }
  #inventory-summary .v4-kpi-item:nth-child(even) { border-left: 1px solid var(--border-light) !important; }

  /* Inv filters — поиск на всю ширину, селекты по 2 в ряд */
  .inv-filters-row { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .inv-filters-row .inv-search-wrap { flex: 1 1 100%; max-width: none; }
  .inv-filters-row .form-select,
  .inv-filters-row select { flex: 1 1 calc(50% - 6px); max-width: none; }

  /* Таблица данных на мобиле — скролл */
  .page-shell .data-table { font-size: 11px; }
  .page-shell .data-table th,
  .page-shell .data-table td { padding: 8px 8px; white-space: nowrap; }
  .page-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Кнопки в таблице */
  .data-table .btn.btn-outline.btn-sm { font-size: 11px; padding: 0 6px; height: 26px; }

  /* Справочники */
  .ref-table { font-size: 12px; }
  .ref-table th, .ref-table td { padding: 8px 10px; }

  /* Мониторинг */
  .mon-health-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }

  /* page-shell в модулях без отступа */
  #page-reports .page-shell,
  #page-audit .page-shell { margin: 8px; }

  /* Отчёты — фильтры в колонку */
  #page-reports .section-body > div[style*="flex-wrap"] { flex-direction: column; }
  #page-reports .section-body input[type="date"] { width: 100% !important; }
  #page-reports .section-body select { width: 100% !important; }

  /* Скрываем лишнее на мобиле в таблице склада */
  .data-table th:nth-child(3),
  .data-table td:nth-child(3) { display: none; } /* место хранения */
  .data-table th:nth-child(7),
  .data-table td:nth-child(7) { display: none; } /* цена */
}

@media (max-width: 480px) {
  .page-title { font-size: 14px; }
  .page-title svg { display: none; }
  .inv-filters-row .form-select,
  .inv-filters-row select { flex: 1 1 100%; }
}

/* Кнопки действий внутри occ-card (одобрить, заказано, изменить и т.п.) */
.occ-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--ui-r);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .1s, border-color .1s;
}
.occ-action-btn:hover { background: var(--bg-muted); }

/* ── Кнопка закрытия модалок ── */
.modal-close-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.modal-close-btn:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.modal-close-btn svg { display: block; }

/* ══════════════════════════════════════════════
   МОБИЛЬНЫЙ POLISH — occ-card задачи и закупки
   ══════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* page-shell — без отступов по бокам на мобиле */
  .page-shell {
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

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

  /* occ-card — убираем лишнее, добавляем отступы между картами */
  .v4-feed-list .occ-card {
    padding: 10px 12px 10px 18px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
  }

  /* Левая полоска — чуть тоньше */
  .v4-feed-list .occ-card::before { left: 3px; top: 8px; bottom: 8px; }

  /* Разделитель между задачами */
  .v4-feed-list .occ-card + .occ-card::after {
    left: 0; right: 0;
  }

  /* Заголовок карты: бейдж + название в строку */
  .occ-card-inner { width: 100%; }
  .occ-card-title {
    white-space: normal !important;
    font-size: 13px;
    line-height: 1.35;
    overflow: visible !important;
    text-overflow: unset !important;
  }

  /* Мета-строка — меньше шрифт, перенос */
  .occ-card-meta {
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 4px !important;
  }
  .occ-card-meta-item { font-size: 11px; }

  /* Бейдж статуса — правее за title */
  .occ-card-badge { font-size: 9px; padding: 2px 6px; }

  /* Дедлайн — не уходит за экран */
  .occ-card-deadline { font-size: 10px; flex-shrink: 0; }

  /* Кнопки задач (▶ ✓) — убираем из inline, ставим под контентом */
  .task-actions {
    display: flex !important;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
  }
  .task-actions .btn-icon {
    width: 32px; height: 32px;
  }

  /* Закупки — кнопки под карточкой */
  #purchases-list .occ-card {
    flex-wrap: wrap !important;
  }
  #purchases-list .occ-card > div:last-child {
    width: 100%;
    padding-left: 0 !important;
    padding-top: 8px;
    flex-wrap: wrap;
    gap: 6px;
  }
  #purchases-list .btn.btn-sm {
    flex: 1;
    justify-content: center;
    min-width: 80px;
  }

  /* Закупки summary — 2 в ряд */
  #purchases-summary > div { flex-wrap: wrap; padding: 0 0 8px !important; }
  #purchases-summary .section { flex: 1 1 calc(50% - 4px) !important; min-width: 0; padding: 10px 8px !important; }

  /* purchases-list — без отступов по бокам */
  #purchases-list, #purchases-summary { padding-left: 0 !important; padding-right: 0 !important; }
  #purchases-list .v4-feed-list {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
}

@media (max-width: 767px) {
  /* task-item мобильный layout */
  .task-item {
    flex-wrap: wrap !important;
    padding: 10px 10px 8px 10px !important;
    gap: 6px !important;
    align-items: flex-start !important;
    position: relative;
  }

  /* Иконка — меньше */
  .task-icon { width: 26px !important; height: 26px !important; min-width: 26px !important; margin-top: 1px; }

  /* task-info занимает всю ширину минус иконка */
  .task-info { flex: 1; min-width: 0; }

  /* Название — переносится */
  .task-title { white-space: normal !important; font-size: 13px; line-height: 1.35; }

  /* Статус-бейдж — перемещаем в мета-строку, скрываем отдельную колонку */
  .task-status-col {
    order: 10;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 32px;
    margin-top: 0;
    min-width: 0 !important;
  }

  /* Кнопки — под контентом справа */
  .task-actions {
    order: 11;
    width: 100%;
    display: flex !important;
    justify-content: flex-end;
    gap: 6px;
    padding-left: 32px;
    margin-top: 4px;
    min-width: 0 !important;
    width: auto !important;
  }
  .task-actions .btn-icon {
    width: 34px !important; height: 34px !important;
    border-radius: 8px !important;
    border: 1.5px solid var(--border) !important;
    background: var(--bg-card) !important;
  }
  .task-actions .btn-icon.success {
    border-color: #bbf7d0 !important;
    background: #eef8f2 !important;
  }
}

@media (max-width: 767px) {
  /* Убираем тень и рамки у v4-shell на мобиле */
  .v4-shell {
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    box-shadow: none !important;
  }
  .page-shell {
    box-shadow: none !important;
  }
}

@media (max-width: 767px) {
  /* Прячем тени карточек за пределами экрана */
  .main { overflow-x: hidden; }
  /* Явно убираем тени у всех карточек/секций на мобиле */
  .section, .v4-shell, .page-shell, .occ-card, .v4-feed-list {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
  }
}

@media (max-width: 767px) {
  /* Календарь дашборда — без рамки и тени на мобиле */
  .v4-cal-wrap {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
  /* Календарь и лента задач жили по РАЗНЫМ сеткам: календарь отступал от края
     на 23px, лента на 11px, а справа у ленты оставалась щель 21px против 11px
     слева. Отсюда ощущение, что карточка задачи «не во всю ширину и даже уже
     календаря» (замечание владельца 19.08.2026). Ставим оба блока на одну
     линию и во всю ширину экрана. */
  .v4-right {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  .v4-feed { width: 100% !important; }
  .v4-feed-scroll, .v4-feed-list { width: 100% !important; }
  /* Табы дашборда — не переносятся */
  #dashboard-view-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 12px 16px 0 !important;
  }
  #dashboard-view-tabs::-webkit-scrollbar { display: none; }
  #dashboard-view-tabs .filter-chip { flex-shrink: 0; white-space: nowrap; }
  #dashboard-view-tabs .filter-chip svg { display: none; }
  /* Табы справочников на мобиле — горизонтальный скролл */
  #ref-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    gap: 6px !important;
    padding: 0 12px 12px !important;
  }
  #ref-tabs::-webkit-scrollbar { display: none; }
  #ref-tabs .filter-chip { flex-shrink: 0 !important; white-space: nowrap !important; }
  /* Убираем тени у всех виджетов внутри дашборда */
  #page-dashboard .section,
  #page-dashboard [style*="border-radius"],
  #page-dashboard [style*="box-shadow"] {
    box-shadow: none !important;
  }
}

@media (max-width: 767px) {
  /* Убираем WebKit-тени на pill-кнопках */
  .filter-chip {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -webkit-appearance: none !important;
  }
  .btn, .btn-sm, .btn-outline, .btn-primary {
    -webkit-appearance: none !important;
  }
}

@media (max-width: 767px) {
  /* v4-feed-scroll — без рамки, на всю ширину */
  .v4-feed-scroll {
    border: none !important;
    border-radius: 0 !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
  .v4-feed {
    padding: 10px 0 16px !important;
    border-right: none !important;
  }
  .v4-section-label {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}




/* ===== DASHBOARD TABS ===== */
.dash-header-bar {
  display: flex;
  align-items: center;
  padding: 12px 20px 0;
}

/* Desktop: underline tabs */
.dash-tabs-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dash-tabs-wrap::-webkit-scrollbar { display: none; }

.dash-tabs {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 2px solid var(--border);
}

.dash-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 42px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s;
  border-radius: 0;
  flex-shrink: 0;
}
.dash-tab:hover { color: var(--primary); background: var(--bg-secondary); border-radius: 8px 8px 0 0; }
.dash-tab.active { color: var(--primary); font-weight: 700; }
.dash-tab svg { flex-shrink: 0; width: 14px; height: 14px; }

.dash-tab-indicator {
  position: absolute;
  bottom: -2px;
  height: 2.5px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  transition: left 0.25s cubic-bezier(.4,0,.2,1), width 0.25s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}

/* Mobile: segment control (iOS style) */
@media (max-width: 640px) {
  .dash-header-bar {
    padding: 10px 12px 6px;
  }
  .dash-tabs-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dash-tabs-wrap::-webkit-scrollbar { display: none; }
  .dash-tabs {
    min-width: 100%;
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    background: var(--bg-secondary) !important;
    border-radius: 10px;
    border-bottom: none;
    padding: 3px;
    gap: 2px;
  }
  .dash-tab {
    flex: 1 1 auto;
    min-width: fit-content;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 10px;
    height: 36px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: 8px;
    white-space: nowrap;
    overflow: visible;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 1;
    min-width: 0;
  }
  .dash-tab svg { width: 12px; height: 12px; flex-shrink: 0; }
  .dash-tab:hover { background: none; color: var(--text); }
  .dash-tab.active {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 1px 6px rgba(45,125,83,.3);
  }
  .dash-tab.active svg { stroke: #fff; }
  .dash-tab-indicator { display: none !important; }
}


/* ===== SKELETON (универсальный) ===== */
@keyframes skeleton-pulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}
.skel-box {
  background: var(--bg-secondary);
  border-radius: 6px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

/* ===== DASHBOARD SKELETON ===== */
@keyframes skel-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skel-line,
.skel-kpi,
.skel-task,
.skel-cal {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--border) 37%,
    var(--bg-secondary) 63%
  );
  background-size: 1200px 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

.skel-kpi {
  height: 56px;
  flex: 1;
  min-width: 60px;
  border-radius: 10px;
}

.skel-task {
  height: 62px;
  width: 100%;
  border-radius: 10px;
  margin-bottom: 8px;
}

.skel-cal {
  height: 260px;
  width: 100%;
  border-radius: 12px;
}

/* Адаптив скелетона */
@media (max-width: 640px) {
  .skel-kpi  { height: 48px; }
  .skel-task { height: 56px; }
  .skel-cal  { height: 200px; }
}

/* ===== DASHBOARD CARD & TABS ===== */
#page-dashboard {
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
#page-dashboard #dashboard-view-tabs {
  padding: 8px 0 6px !important;
  margin: 0 !important;
}
@media (max-width: 640px) {
  #dash-tab-specialists svg { display: inline !important; }
  #dash-tab-specialists { flex: 1 1 0 !important; }
  /* Все табы равной ширины на всю страницу */
  #page-dashboard .dash-tabs {
    border-radius: 0 !important;
    padding: 4px 4px !important;
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    gap: 3px !important;
    width: 100% !important;
  }
  #page-dashboard .dash-tab {
    border-radius: 20px !important;
    padding: 0 6px !important;
    font-size: 11.5px !important;
    height: 34px !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    letter-spacing: -0.2px !important;
    gap: 4px !important;
  }
  #page-dashboard .dash-tab.active {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700 !important;
  }
  #page-dashboard .dash-tab svg {
    width: 12px !important; height: 12px !important;
    display: inline !important;
    flex-shrink: 0 !important;
  }
  #page-dashboard .dash-tab-indicator { display: none !important; }
}
/* Все три вида — одинаковый стиль карточки */
#page-dashboard #dash-view-main .v4-shell,
#page-dashboard #dash-skeleton .v4-shell,
#page-dashboard #dash-sections-grid .v4-shell,
#page-dashboard #dash-specialists-grid .v4-shell {
  margin: 0 16px 16px !important;
  border-radius: 16px !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.06) !important;
  overflow: hidden !important;
}
@media (max-width: 767px) {
  #page-dashboard #dash-view-main .v4-shell,
  #page-dashboard #dash-skeleton .v4-shell,
  #page-dashboard #dash-sections-grid .v4-shell,
  #page-dashboard #dash-specialists-grid .v4-shell {
    margin: 0 10px 12px !important;
    border-radius: 16px !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,.06) !important;
    overflow: hidden !important;
  }
}

/* Drilldown карточка (Участки/Специалисты → клик на строку) — НЕ overflow:hidden,
   иначе длинный список задач обрезается и его не пролистать на iOS PWA */
#dash-sections-grid .v4-shell,
#dash-specialists-grid .v4-shell {
  overflow: visible !important;
}
#dash-sections-grid #sec-tasks-list,
#dash-specialists-grid #spec-tasks-list {
  overflow: visible !important;
  -webkit-overflow-scrolling: touch;
}

/* =====================================================
   MODAL BOTTOM SHEET — для всех устройств с таббаром
   (телефоны max-width:767px И планшеты 768-1024px)
   ===================================================== */
@media (max-width: 1024px) {
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal {
    max-width: 100% !important; width: 100% !important;
    margin: 0 !important; max-height: 94vh !important;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUp .25s cubic-bezier(.32,0,.67,0) !important;
    border-bottom: none !important;
    box-shadow: 0 -4px 32px rgba(0,0,0,.12) !important;
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

  .modal-header { padding: 8px 20px 12px !important; position: relative !important; }
  .modal-header::before {
    content: ''; display: block;
    width: 36px; height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin: 0 auto 10px;
  }
  .modal-title { font-size: 18px !important; font-weight: 700 !important; }
  .modal-close { width: 32px !important; height: 32px !important; border-radius: 50% !important; }

  .modal-body {
    padding: 8px 20px 12px !important;
    max-height: calc(94vh - 130px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
  }

  /* Inputs и footer — управляются через showModal() JS для динамических модалок,
     и через исходный CSS для статических (Новая задача и др.) */
}

/* ═══ Action Sheet ═══ */
.action-sheet-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.action-sheet-btn:hover, .action-sheet-btn:active {
  background: var(--bg-muted);
}
.action-sheet-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-sheet-text {
  flex: 1;
  min-width: 0;
}
.action-sheet-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.action-sheet-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══ AI Chat ═══ */
#page-ai-chat { padding:0 !important; overflow:hidden; }
#page-ai-chat.active { display:flex !important; flex-direction:column; overflow:hidden; }

#ai-chat-shell {
  display:flex; flex-direction:column;
  flex:1; min-height:0; overflow:hidden;
  background:var(--bg-page);
}

/* Минимальный хедер */
#ai-chat-header {
  display:flex; align-items:center;
  padding:8px 16px;
  background:var(--bg-card);
  border-bottom:1px solid var(--border-light);
  flex-shrink:0; gap:8px;
}
#ai-chat-header-left { display:flex; align-items:center; gap:8px; }
#ai-chat-avatar {
  width:28px; height:28px; border-radius:50%;
  background:var(--primary);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
#ai-chat-header-title { font-size:14px; font-weight:700; color:var(--text); }

#ai-chat-scroll {
  flex:1; min-height:0; overflow-y:auto;
  -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
  display:flex; flex-direction:column;
}

#ai-chat-welcome-screen {
  flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  text-align:center; padding:24px 24px 16px; gap:10px;
}
#ai-chat-welcome-icon {
  width:60px; height:60px; border-radius:50%; background:var(--primary);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 20px rgba(34,197,94,.3); flex-shrink:0;
}
#ai-chat-welcome-title { font-size:20px; font-weight:800; color:var(--text); letter-spacing:-.3px; }
#ai-chat-welcome-sub { font-size:13px; color:var(--text-muted); line-height:1.6; max-width:280px; }

#ai-chat-messages { padding:12px 14px 8px; display:flex; flex-direction:column; gap:12px; }

#ai-chat-bottom {
  flex-shrink:0;
  background:var(--bg-card);
  border-top:1px solid var(--border-light);
  padding-top:4px;
  padding-bottom:calc(64px + env(safe-area-inset-bottom, 0px));
}

#ai-chat-quick-actions {
  display:flex; gap:6px; padding:8px 14px 6px;
  overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
#ai-chat-quick-actions::-webkit-scrollbar { display:none; }
.ai-quick-chip {
  display:inline-flex; align-items:center; gap:5px; padding:6px 12px;
  background:var(--bg-muted); border:1.5px solid var(--border);
  border-radius:20px; font-size:12px; font-weight:600; color:var(--text);
  cursor:pointer; white-space:nowrap; flex-shrink:0;
  transition:all .15s; -webkit-tap-highlight-color:transparent;
}
.ai-quick-chip:active { background:var(--primary); color:#fff; border-color:var(--primary); }
.ai-quick-chip-red { border-color:#fca5a5; color:#dc2626; background:#fff5f5; }
.ai-quick-chip-red:active { background:#ef4444; color:#fff; border-color:#ef4444; }

/* Claude-style input box */
#ai-input-box {
  margin:4px 12px 10px;
  background:var(--bg-card);
  border:1.5px solid var(--border);
  border-radius:16px;
  box-shadow:0 2px 12px rgba(0,0,0,.08);
  transition:border-color .2s, box-shadow .2s;
}
#ai-input-box:focus-within {
  border-color:var(--primary);
  box-shadow:0 2px 16px rgba(34,197,94,.12);
}
#ai-chat-input {
  display:block; width:100%; box-sizing:border-box;
  padding:12px 14px 6px;
  border:none; outline:none; resize:none;
  font-size:16px; font-family:inherit; line-height:1.45;
  background:transparent; color:var(--text);
  max-height:140px; overflow-y:hidden;
}
#ai-chat-input::placeholder { color:var(--text-muted); }
#ai-chat-input::-webkit-scrollbar { display:none; }
#ai-chat-input { scrollbar-width:none; -ms-overflow-style:none; }

#ai-input-actions {
  display:flex; align-items:center; justify-content:space-between;
  padding:2px 6px 8px;
}

/* Левая кнопка + */
#ai-plus-btn {
  width:42px; height:42px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none; cursor:pointer;
  color:var(--text-muted);
  transition:all .2s; -webkit-tap-highlight-color:transparent;
  flex-shrink:0;
}
#ai-plus-btn:active { background:var(--bg-secondary); color:var(--primary); transform:rotate(45deg); }

/* Универсальная иконка-кнопка (для совместимости) */
.ai-input-icon-btn {
  width:34px; height:34px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none; cursor:pointer;
  color:var(--text-muted); transition:all .15s;
  -webkit-tap-highlight-color:transparent;
}
.ai-input-icon-btn:active { background:var(--bg-secondary); color:var(--text); }

/* Правая кнопка mic/send */
#ai-right-btn {
  width:42px; height:42px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  border:none; cursor:pointer; flex-shrink:0;
  transition:all .25s cubic-bezier(.34,1.56,.64,1);
  -webkit-tap-highlight-color:transparent;
}
.ai-right-btn-mic {
  background:none;
  color:var(--text-muted);
}
.ai-right-btn-mic:active { background:var(--bg-secondary); }
.ai-right-btn-send {
  background:var(--primary);
  color:#fff;
  box-shadow:0 2px 8px rgba(34,197,94,.35);
  transform:scale(1.05);
}
#ai-right-btn svg { width:22px; height:22px; }
#ai-plus-btn svg { width:22px; height:22px; }
.ai-right-btn-send:active { transform:scale(.93); }

/* Запись голоса */
#ai-right-btn.recording {
  background:#fef2f2 !important;
  color:#ef4444 !important;
  animation:micPulse 1s infinite;
}
@keyframes micPulse {
  0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.4)}
  50%{box-shadow:0 0 0 6px rgba(239,68,68,0)}
}

/* Plus action sheet */
#ai-plus-sheet-overlay {
  position:fixed; inset:0; z-index:700;
  background:rgba(0,0,0,.4);
  display:flex; align-items:flex-end; justify-content:center;
}
#ai-plus-sheet {
  background:var(--bg-card);
  border-radius:20px 20px 0 0;
  width:100%; max-width:480px;
  padding:0 0 calc(8px + env(safe-area-inset-bottom,0px));
  animation:slideUp .25s cubic-bezier(.32,.72,0,1);
}
.ai-plus-item {
  display:flex; align-items:center; gap:14px;
  padding:15px 20px;
  cursor:pointer; border:none; background:none;
  width:100%; text-align:left;
  font-size:15px; color:var(--text);
  -webkit-tap-highlight-color:transparent;
  transition:background .15s;
}
.ai-plus-item:active { background:var(--bg-secondary); }
.ai-plus-item-icon {
  width:42px; height:42px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; font-size:20px;
}
.ai-plus-item-label { font-weight:600; }
.ai-plus-item-sub { font-size:12px; color:var(--text-muted); margin-top:1px; }
.ai-plus-divider { height:1px; background:var(--border-light); margin:0 20px; }

/* На ПК Plus sheet — центрированная модалка */
@media (min-width: 769px) {
  #ai-plus-sheet-overlay { align-items: center; }
  #ai-plus-sheet {
    border-radius: 16px;
    max-width: 420px;
    padding: 8px 0 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: scaleIn .2s cubic-bezier(.32,.72,0,1);
  }
  #ai-plus-sheet > div:first-child { display: none; }
}
@keyframes scaleIn { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }

.ai-chat-msg { display:flex; flex-direction:column; gap:2px; animation:msgIn .2s ease; }
@keyframes msgIn { from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)} }
.ai-chat-msg-user { align-items:flex-end; }
.ai-chat-msg-ai   { align-items:flex-start; }
.ai-chat-bubble { max-width:88%; padding:11px 14px; border-radius:18px; font-size:14px; line-height:1.65; word-break:break-word; }
.ai-chat-bubble-user { background:var(--primary); color:#fff; border-bottom-right-radius:4px; }
.ai-chat-bubble-ai { background:var(--bg-card); color:var(--text); border:1px solid var(--border-light); border-bottom-left-radius:4px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.ai-chat-bubble-ai p { margin:0 0 6px; }
.ai-chat-bubble-ai p:last-child { margin-bottom:0; }
.ai-chat-bubble-ai strong { font-weight:700; }
.ai-chat-bubble-ai ul,.ai-chat-bubble-ai ol { margin:3px 0 6px 16px; padding:0; }
.ai-chat-bubble-ai li { margin:2px 0; }
.ai-chat-bubble-ai h2,.ai-chat-bubble-ai h3 { font-size:13px; font-weight:700; margin:6px 0 3px; }
.ai-chat-bubble-ai code { background:var(--bg-muted); padding:1px 5px; border-radius:4px; font-size:12px; font-family:monospace; }
.ai-chat-bubble-error { background:#fef2f2; border-color:#fca5a5; color:#991b1b; }
.ai-chat-time { font-size:10px; color:var(--text-muted); padding:0 4px; margin-top:1px; }

.ai-chat-typing { display:flex; align-items:center; gap:5px; padding:12px 16px; background:var(--bg-card); border:1px solid var(--border-light); border-radius:18px; border-bottom-left-radius:4px; width:fit-content; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.ai-chat-typing span { width:6px; height:6px; background:var(--text-muted); border-radius:50%; animation:aiDot .7s infinite alternate; }
.ai-chat-typing span:nth-child(2){animation-delay:.22s}
.ai-chat-typing span:nth-child(3){animation-delay:.44s}
@keyframes aiDot{0%{opacity:.2;transform:translateY(0)}100%{opacity:.7;transform:translateY(-3px)}}

/* Статус вместо трёх точек: «смотрю задачи и просрочки…».
   Пузырь тот же, поэтому переход из точек в текст не дёргает layout —
   меняется только содержимое. Точка-пульс слева заменяет анимацию троеточия. */
.ai-chat-typing.ai-chat-typing-status { gap:8px; max-width:min(78%,420px); }
.ai-chat-typing-status .ai-status-dot { width:6px; height:6px; flex:0 0 6px; background:var(--text-muted); border-radius:50%; animation:aiPulse 1.1s ease-in-out infinite; }
/* Ширина статуса. Базовый .ai-chat-typing — это flex с width:fit-content, а
   .ai-chat-bubble задаёт word-break:break-word. В такой связке текстовый
   флекс-элемент сжимается до МИНИМАЛЬНОЙ ширины содержимого, а break-word
   разрешает разрыв в любом месте — то есть до ОДНОЙ БУКВЫ, и подпись
   печаталась вертикальным столбиком. Лечим на самом тексте: nowrap делает
   min-content равным всей строке, ellipsis подстрахует длинную подпись. */
.ai-chat-typing-status .ai-status-text { flex:0 1 auto; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; word-break:normal; overflow-wrap:normal; font-size:13px; line-height:1.35; color:var(--text-muted); animation:aiStatusIn .18s ease-out; }
@keyframes aiPulse{0%,100%{opacity:.25;transform:scale(.85)}50%{opacity:.8;transform:scale(1)}}
@keyframes aiStatusIn{from{opacity:0;transform:translateY(2px)}to{opacity:1;transform:none}}

/* Предпросмотр генерации: текст печатается прямо в пузыре ответа.
   Разметка намеренно повторяет настоящий ответ (_renderOneMsg в app-ai-cards.js):
   тот же пузырь ai-chat-bubble-ai с БЛОЧНЫМ потомком внутри. Первая попытка
   положила текст в inline-span — пузырь тогда сжимался до минимальной ширины
   содержимого и печатал столбик по букве в строке.
   pre-wrap — модель шлёт переводы строк, разметку наведёт финальный рендер.
   word-break:normal перекрывает break-word из базового .ai-chat-bubble: тот
   разрешает разрыв в любом месте, из-за чего min-content равен одной букве.
   overflow-wrap:break-word переносит длинные слова так же, но на min-content
   не влияет. min-width — страховка: что бы ни случилось со схлопыванием,
   уже столбика не будет. */
#ai-preview .ai-chat-bubble { max-width:88%; min-width:min(180px,70%); word-break:normal; overflow-wrap:break-word; }
#ai-preview .ai-preview-text { margin:0; white-space:pre-wrap; }
#ai-preview .ai-preview-text::after { content:""; display:inline-block; width:2px; height:1em; margin-left:2px; vertical-align:-.15em; background:var(--text-muted); opacity:.7; animation:aiCaret 1s step-end infinite; }
@keyframes aiCaret{0%,50%{opacity:.7}51%,100%{opacity:0}}
@media (prefers-reduced-motion: reduce){
  .ai-chat-typing-status .ai-status-dot,
  #ai-preview .ai-preview-text::after,
  .ai-chat-typing-status .ai-status-text { animation:none; }
}

.ai-action-card { margin-top:6px; padding:9px 12px; background:var(--bg-muted); border:1px solid var(--border); border-radius:12px; font-size:13px; cursor:pointer; display:flex; align-items:center; gap:8px; -webkit-tap-highlight-color:transparent; }
.ai-action-card:active { background:var(--bg-secondary); }
.ai-action-card-icon { width:26px; height:26px; border-radius:7px; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; flex-shrink:0; }

@media (max-width:768px) {
  /* Страница заканчивается ровно там, где начинается таббар (с учётом safe-area) */
  #page-ai-chat.active {
    position:fixed; top:var(--header-h, 56px); left:0; right:0;
    bottom:0;
    overflow:hidden !important; padding-bottom:0 !important;
  }
  #ai-chat-bottom { padding-top:0; }
  #ai-chat-quick-actions { padding:4px 12px 2px; }
  #ai-input-box { margin:2px 8px 4px; }
  #ai-chat-input { padding:9px 14px 4px; font-size:15px; }
  #ai-input-actions { padding:0 6px 4px; }
  #ai-plus-btn,#ai-right-btn { width:36px; height:36px; }
  .ai-chat-bubble { max-width:92%; }
  #ai-chat-messages { padding:10px 12px 6px; }
}


/* Кликабельные сущности в ответе Тоши: запчасти / оборудование / задачи / регламенты */
.ai-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity .15s;
}
.ai-link:hover  { opacity: 0.75; }
.ai-link:active { opacity: 0.6; }
.ai-part-link { color: var(--accent, #16a34a); }   /* запчасти — зелёный */
.ai-eq-link   { color: #2563eb; }                  /* оборудование — синий */
.ai-task-link { color: #d97706; }                  /* задачи — оранжевый */
.ai-reg-link  { color: #7c3aed; }                  /* регламенты — фиолетовый */

/* === Подвкладки Техники === */
.vehicles-subtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.vehicles-subtab:hover { color: var(--text-primary); }
.vehicles-subtab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* === Отключаем нативный pull-to-refresh браузера (свой жест — в app-pulltorefresh.js) === */
html, body { overscroll-behavior-y: none; }
.main { overscroll-behavior-y: contain; }

/* ── Мини-апп MAX: своя системная шапка сверху — не дублируем инсет статус-бара ── */
html.in-max .header { padding-top: 0 !important; height: var(--header-h) !important; }
html.in-max .sidebar { padding-top: 0 !important; }


/* === Единый строчный список оборудования === */
.eq-rows-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}
.eq-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border-radius: 12px;
}
.eq-row:hover { transform: none; }
.eq-row .eq-card-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eq-row-main { flex: 1; min-width: 0; }
.eq-row-right {
  display: flex; align-items: center; gap: 5px;
  flex-shrink: 0; white-space: nowrap;
}
.eq-row-go { color: #cbd5e1; flex-shrink: 0; }
.eq-row-stripe {
  position: absolute; left: 4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
}
.eq-row-cat {
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 20px;
  white-space: nowrap;
}
/* Колонка названия в шапке подгруппы. min-width задаём ЗДЕСЬ, а не инлайном:
   инлайновый min-width:0 перебивал мобильное правило по приоритету. */
.eq-sub-main { flex: 1; min-width: 0; }
.eq-subgroup { box-shadow: var(--shadow-1); }
.eq-subgroup-head:hover { background: var(--bg-hover, #f8fafc); }
/* чекбокс пакетного выбора — по центру строки */
.eq-row .eq-card-checkbox { top: 50%; left: 10px; transform: translateY(-50%); }
body.eq-select-mode .eq-row { padding-left: 40px; }
@media (max-width: 640px) {
  .eq-rows-list { padding: 8px 12px; }
  .eq-row { padding: 10px 12px 10px 14px; }
  .eq-row-cat { display: none; }
  .eq-row-right span:last-child { display: none; }

  /* НАЗВАНИЕ ОБОРУДОВАНИЯ ВИДНО ЦЕЛИКОМ. Замер 17.08 на 390px: из 70 строк
     8 резались многоточием, у «Котел автоматический пеллетный ZOTA Pellet S 1»
     за кадром оставалось 154px из 338. На телефоне переносим по словам —
     ровно так же, как давно сделано у задач (.task-title). */
  .eq-row .eq-card-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
  }

  /* ШАПКА ПОДГРУППЫ однотипных единиц мобильных правил не имела ВООБЩЕ:
     категория, бейджи и блок «2 шт / все 2 работают» держали ширину
     (flex-shrink:0 + nowrap), и колонке названия доставалось 0-75px из 339 —
     название рассыпалось по одному слову в строку. */
  .eq-subgroup-head { gap: 8px; padding: 10px 10px 10px 14px; }
  .eq-subgroup-head .eq-row-cat { display: none; }
  .eq-subgroup-head .eq-sub-main { min-width: 120px; }
  .eq-subgroup-head .eq-sub-right { max-width: 92px; }
  .eq-subgroup-head .eq-sub-status {
    white-space: normal !important;
    font-size: 11px;
    line-height: 1.25;
  }
  .eq-subgroup-head .eq-card-title,
  .eq-subgroup-head .eq-card-subtitle { word-break: break-word; }
}

/* Бейдж подрядчика — регламенты и задачи, работы выполняет сторонняя организация */
.badge-contractor {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
  vertical-align: middle;
}


/* Запчасти к оборудованию в карточке задачи (основная колонка).
   В правой колонке имена обрезались, а количество налезало на название склада. */
.task-part-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-top: 1px solid var(--border-light);
  cursor: pointer; transition: background .1s;
}
.task-part-row:first-child { border-top: none; }
.task-part-row:hover { background: var(--bg-secondary); }
.task-part-mark { font-size: 14px; font-weight: 700; line-height: 20px; flex: 0 0 14px; }
.task-part-name { flex: 1; min-width: 0; font-size: 14px; word-break: break-word; }
.task-part-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.task-part-qty { font-size: 14px; font-weight: 700; white-space: nowrap; flex: 0 0 auto; padding-left: 8px; }
.task-part-more {
  padding: 10px 14px; text-align: center; font-size: 13px;
  color: var(--primary); cursor: pointer; border-top: 1px solid var(--border-light);
}
@media (max-width: 767px) {
  .task-part-row { padding: 12px 12px; }
  .task-part-name { font-size: 15px; }
}


/* ── Блок задач в карточке оборудования ──────────────────────────────────────
   Жалоба владельца: «все разделы одинаковые, всё сливается воедино». Задачи —
   единственный блок карточки, ради которого её открывают в поле, поэтому ему
   даём отличие: полоса основного цвета слева, слегка подкрашенная шапка и
   цветной значок. Остальные разделы не трогаем — иначе выделение перестанет
   что-либо значить. */
#eq-tasks-section {
  border-left: 3px solid var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
#eq-tasks-section > .section-header {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  border-radius: 0 8px 0 0;
}
#eq-tasks-section > .section-header .section-title { color: var(--primary); }
/* Кнопок в шапке стало две («+ Задача» и «Работа выполнена»), а правая колонка
   карточки оборудования узкая: шапка секции на ПК не переносилась, и кнопки
   уезжали за край блока. Разрешаем перенос — они падают на свою строку. */
#eq-tasks-section > .section-header { flex-wrap: wrap; }
#eq-tasks-section > .section-header > .section-title { flex: 1 1 auto; min-width: 0; }
#eq-tasks-section > .section-header > div:last-child { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
#eq-tasks-section > .section-header .btn-sm { white-space: nowrap; }
#eq-tasks-section > .section-header .section-title svg { color: var(--primary); }
/* Счётчик активных задач — не серый, а цветной: ноль задач и три задачи должны
   отличаться с одного взгляда. */
#eq-tasks-count:not([style*="display: none"]) {
  background: var(--primary) !important;
  color: #fff !important;
}


/* Карточки задач сверх лимита группы на дашборде — скрыты до нажатия
   «Смотреть все N» (dashExpandGroup снимает этот класс). */
.occ-extra-hidden { display: none !important; }

/* ─── Присутствие в карточке задачи ────────────────────────────────────
   Список отметок по меткам: кто, когда, где, насколько близко. Первые три
   видны всегда, остальные под кнопкой — на ежедневном обходе за неделю их
   набирается много. На телефоне строки переносятся, а не режутся. */
.presence-list { display: flex; flex-direction: column; gap: 8px; }
.presence-item { display: flex; align-items: flex-start; gap: 9px; min-width: 0; }
.presence-mark {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-secondary); color: var(--text-muted);
}
.presence-mark.is-pinned { background: #dcfce7; color: #15803d; }
.presence-body { min-width: 0; flex: 1; }
.presence-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35; }
.presence-title .presence-when { font-weight: 500; color: var(--text-secondary); }
.presence-meta {
  font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-top: 1px;
  display: flex; flex-wrap: wrap; gap: 2px 8px;
}
.presence-meta .presence-far { color: #b45309; }
.presence-event { font-size: 11px; font-weight: 700; color: #15803d; text-transform: uppercase; letter-spacing: .3px; }
.presence-more {
  align-self: flex-start; background: none; border: none; padding: 2px 0;
  font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer;
}
.presence-more:hover { text-decoration: underline; }
@media (max-width: 767px) {
  .presence-title { font-size: 12.5px; }
  .presence-meta  { font-size: 11.5px; gap: 1px 6px; }
  .presence-mark  { width: 20px; height: 20px; }
}

