/* =====================================================
   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; min-height: 100vh; }

/* =====================================================
   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;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

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

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  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;
}

.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; }
.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-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 ~ .main #sidebar-toggle-icon { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
.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 var(--transition);
  min-width: 0;
}

.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; }
.header-spacer { flex: 1; }
.content { padding: 20px; max-width: 1400px; }

/* =====================================================
   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); }

/* =====================================================
   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; }

.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-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,.5);
  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: modal-in var(--duration-normal) var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.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),
              box-shadow var(--duration-fast) var(--ease);
  outline: none;
  line-height: 1.5;
}
.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; }

/* =====================================================
   RESPONSIVE — mobile
   ===================================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    z-index: 50;
    height: 100dvh; height: 100vh;
  }
  .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; }

  .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: column; align-items: flex-start; gap: 10px; padding: 12px; }
  .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; }
  .detail-content { grid-template-columns: 1fr !important; }
  .detail-sidebar { margin-top: 0; 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-end; 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; }

  /* Modal — bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important; width: 100% !important;
    margin: 0; max-height: 92vh;
    border-radius: 14px 14px 0 0;
    animation: slideUp .22s ease;
    border-bottom: none;
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-header { padding: 12px 20px 12px; position: relative; }
  .modal-header::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 32px; height: 4px; background: var(--border); border-radius: 2px;
  }
  .modal-title { font-size: 16px; padding-top: 8px; }
  .modal-body { padding: 0 20px 24px; max-height: calc(92vh - 60px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .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));
  }
  .mobile-tabbar { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
}

/* =====================================================
   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; }
.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;
}

.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; }

/* ─── 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;
}
.data-table-row:hover { background: var(--bg-muted); }
.data-table-row.row-warning       { 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; }


/* =====================================================
   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;
  height: 56px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 8px rgba(0,0,0,0.04);
  z-index: 40;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  align-items: center;
  justify-content: space-around;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px; color: var(--text-muted); text-decoration: none;
  font-size: 10px; font-weight: 500; cursor: pointer;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-width: 0; flex: 1; text-align: center; overflow: hidden;
}
.tab-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab-item svg  { width: 20px; height: 20px; }
.tab-item.active   { color: var(--primary); }
.tab-item:active   { color: var(--primary); }
.tab-item-add      { padding: 0; overflow: visible; }
.tab-add-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(22,163,74,.4);
  margin-top: -10px;
  transition: transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.tab-add-btn svg    { width: 20px; height: 20px; }
.tab-add-btn:active { transform: scale(.9); }

@media (max-width: 768px) {
  .mobile-tabbar { display: flex; }
  .main { padding-bottom: 64px; }
  #btn-new-task { display: none !important; }
}

/* =====================================================
   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); }

@media (max-width: 768px) {
  .ref-table { font-size: 12px; }
  .ref-table th, .ref-table td { padding: 8px 10px; white-space: nowrap; }
  #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: auto; -webkit-overflow-scrolling: touch; }
}

/* =====================================================
   NOTIFICATION DROPDOWN
   ===================================================== */
@media (max-width: 768px) {
  .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-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;
}

/* Кнопки — мягче радиус */
.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 */
.page.active > * {
  animation: page-in .2s ease-out;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* Чужие задачи — полоска через --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: 768px) {
  .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: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ── 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 — actions переносятся под title */
  .page-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header-left { flex: 1; min-width: 0; }
  .page-header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  /* Аналитика — гриды в колонку */
  #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 (дашборд) и page-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;
  }
  /* Табы дашборда — не переносятся */
  #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; }
  /* Убираем тени у всех виджетов внутри дашборда */
  #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, .tab-add-btn {
    -webkit-appearance: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: 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;
  }
}



