/* =====================================================
   ТО Ферма — Design System v2
   Тёплая, минималистичная, дружелюбная
   ===================================================== */

:root {
  /* === Palette === */
  --bg:             #fafaf9;
  --bg-muted:       #f5f5f4;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1c1917;
  --bg-sidebar-hover: rgba(255,255,255,.07);
  --bg-sidebar-active: rgba(255,255,255,.12);

  --border:         #e7e5e4;
  --border-light:   #f0efee;

  --text:           #1c1917;
  --text-secondary: #44403c;
  --text-muted:     #78716c;
  --text-sidebar:   #a8a29e;
  --text-sidebar-active: #fafaf9;

  /* Зелёный — идеально для фермы */
  --primary:        #16a34a;
  --primary-hover:  #15803d;
  --primary-light:  #f0fdf4;
  --primary-ring:   rgba(22,163,74,.15);

  --destructive:       #dc2626;
  --destructive-light: #fef2f2;
  --warning:           #d97706;
  --warning-light:     #fffbeb;
  --success:           #16a34a;
  --success-light:     #f0fdf4;
  --info:              #0284c7;
  --info-light:        #f0f9ff;
  --purple:            #7c3aed;
  --purple-light:      #f5f3ff;

  --radius:    10px;
  --radius-sm:  7px;
  --radius-xs:  5px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --transition: 140ms cubic-bezier(.4,0,.2,1);

  --sidebar-w:           252px;
  --sidebar-w-collapsed:  60px;
  --header-h:            56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

/* === 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 {
  width: 34px; height: 34px;
  background: #ffffff;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.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;
}

.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 3px; right: 3px;
  padding: 0 4px;
  font-size: 9px;
  min-width: 15px;
}

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

.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.3);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: #fff; }

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

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

.btn-toggle { display: none; }
.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-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg { width: 17px; height: 17px; }

.stat-card-info { display: flex; flex-direction: column; min-width: 0; }

.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.danger  .stat-card-icon { background: var(--destructive-light); color: var(--destructive); }
.stat-card.danger  .stat-card-value { color: var(--destructive); }
.stat-card.warning .stat-card-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.warning .stat-card-value { color: var(--warning); }
.stat-card.info    .stat-card-icon { background: var(--info-light); color: var(--info); }
.stat-card.info    .stat-card-value { color: var(--info); }
.stat-card.success .stat-card-icon { background: var(--success-light); color: var(--success); }
.stat-card.success .stat-card-value { color: var(--success); }
.stat-card.purple  .stat-card-icon { background: var(--purple-light); color: var(--purple); }

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

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

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

.section-body { padding: 0; }

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

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: pointer;
  min-height: 56px;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--bg-muted); }

.task-priority-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
  min-height: 32px;
}
.task-priority-bar.critical { background: var(--destructive); }
.task-priority-bar.high     { background: var(--warning); }
.task-priority-bar.normal   { background: #94a3b8; }
.task-priority-bar.low      { background: #d4d0cb; }
.task-priority-bar.mine     { background: var(--primary); }

.task-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  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;
}

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

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

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .03em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-overdue    { background: #dc2626;  color: #fff; }
.badge-pending    { background: #f59e0b;  color: #fff; }
.badge-in_progress{ background: #2563eb;  color: #fff; }
.badge-completed  { background: #16a34a;  color: #fff; }
.badge-cancelled  { background: #a8a29e;  color: #fff; }

/* Dashboard task section — prevent overflow pushing calendar out */
.dashboard-tasks-section { overflow: hidden; min-width: 0; }

/* Правая колонка: статус + счётчики */
.task-status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  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: #f0fdf4;
}
.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;
}

.eq-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  background: var(--bg-card);
}
.eq-card:hover { box-shadow: var(--shadow-md); border-color: #d4d0cb; }

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

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

.eq-card-title    { font-size: 14px; font-weight: 600; line-height: 1.3; }
.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-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28,25,23,.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 16px;
}
.modal-title  { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal-body   { padding: 0 22px 22px; }
.form-group   { margin-bottom: 15px; }
.form-label   { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 11px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-textarea { min-height: 80px; resize: vertical; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}

/* Task type toggle */
#task-type-toggle { display: flex !important; flex-direction: row !important; }
.task-type-btn {
  background: transparent; border: none; color: var(--text-muted);
  transition: all .2s;
  display: inline-flex !important; align-items: center; justify-content: center;
  gap: 6px; flex: 1; min-width: 0;
}
.task-type-btn.active[data-type="regular"]   { background: var(--primary); color: white; box-shadow: 0 1px 3px rgba(22,163,74,.3); }
.task-type-btn.active[data-type="emergency"] { background: var(--destructive); color: white; box-shadow: 0 1px 3px rgba(220,38,38,.3); }

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

  .dashboard-grid {
    display: flex !important; flex-direction: column-reverse !important;
    padding: 0 !important; gap: 10px !important;
  }
  .dashboard-calendar-section { order: 2; }
  .dashboard-tasks-section { order: 1; }
  .dashboard-tasks-scroll { max-height: 55vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

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

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, #ece9e6 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* =====================================================
   LOGIN
   ===================================================== */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar);
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 40px 36px 36px;
  width: 100%; max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.login-logo {
  width: auto; height: auto;
  background: none;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.login-logo svg { color: #fff; width: 24px; height: 24px; }
.login-title    { text-align: center; font-size: 26px; font-weight: 800; margin-bottom: 4px; color: var(--text); letter-spacing: -0.5px; }
.login-subtitle { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-error    { color: var(--destructive); font-size: 13px; text-align: center; margin-bottom: 12px; min-height: 20px; }

/* =====================================================
   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 {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  display: flex; align-items: flex-start; gap: 18px;
}

.detail-header-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.detail-header-icon svg { width: 26px; height: 26px; }

.detail-header-info { flex: 1; min-width: 0; }
.detail-header-name { font-size: 19px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.02em; }

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

.detail-header-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}
.detail-main { min-width: 0; }

/* Spec table */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table tr { border-bottom: 1px solid var(--border-light); }
.spec-table tr:last-child { border-bottom: none; }
.spec-table td { padding: 11px 18px; font-size: 13px; vertical-align: top; }
.spec-table td:first-child { color: var(--text-muted); font-weight: 500; width: 170px; white-space: nowrap; }
.spec-table td:last-child  { font-weight: 500; }

/* Mini stats */
.mini-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border-light);
}
.mini-stat { background: var(--bg-card); padding: 16px 18px; text-align: center; }
.mini-stat-value { font-size: 22px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.mini-stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

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

/* =====================================================
   INVENTORY
   ===================================================== */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px; padding: 0 18px 18px;
}
.part-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: all .15s;
}
.part-card:hover { box-shadow: var(--shadow-md); border-color: var(--border); }
.part-card.low-stock { border-color: #fca5a5; background: #fef2f2; }
.part-card-header  { margin-bottom: 12px; }
.part-card-name    { font-size: 13px; font-weight: 600; line-height: 1.4; }
.part-card-article { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-family: monospace; }
.part-card-stock   { margin-bottom: 12px; }
.part-card-qty     { display: flex; align-items: baseline; gap: 4px; margin-bottom: 6px; }
.part-card-qty-value { font-size: 24px; font-weight: 700; line-height: 1; }
.part-card-qty-unit  { font-size: 12px; color: var(--text-muted); }
.part-card-qty-min   { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.part-stock-bar  { height: 4px; background: var(--border-light); border-radius: 2px; overflow: hidden; }
.part-stock-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.part-card-footer { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.part-card-price { font-weight: 600; }

@media (max-width: 600px) { .inventory-grid { grid-template-columns: 1fr; } }

/* =====================================================
   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; }
.data-table .td-wrap { white-space: normal; max-width: 280px; }

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

/* =====================================================
   TABS (equipment detail)
   ===================================================== */
.eq-detail-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border-light); padding: 0 18px; }
.eq-detail-tab {
  padding: 10px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .14s; background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: var(--font);
}
.eq-detail-tab:hover  { color: var(--text); }
.eq-detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.eq-detail-panel      { display: none; padding: 16px 18px; }
.eq-detail-panel.active { display: block; }

/* Equipment table groups */
.eq-table-group { border-bottom: 2px solid var(--border); }
.eq-table-group:last-child { border-bottom: none; }
.eq-table-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);
}
.eq-table-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;
}

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

/* =====================================================
   PHOTO VIEWER
   ===================================================== */
.photo-viewer-overlay { position:fixed; inset:0; background:rgba(0,0,0,.88); z-index:10000; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.photo-viewer-content { max-width:90vw; max-height:90vh; position:relative; }
.photo-viewer-content img { max-width:90vw; max-height:85vh; object-fit:contain; border-radius:8px; }
.photo-viewer-note  { text-align:center; color:#fff; padding:8px; font-size:13px; }
.photo-viewer-close { position:absolute; top:-12px; right:-12px; background:#fff; color:#000; border:none; border-radius:50%; width:32px; height:32px; font-size:18px; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.3); display:flex; align-items:center; justify-content:center; }

/* =====================================================
   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;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 40;
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
  justify-content: space-around; align-items: center;
}
.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); }
.schedule-card-cursor { cursor: pointer; }

/* =====================================================
   TASK DETAIL — ACTION BUTTONS
   ===================================================== */
.task-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  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; }

.task-action-start    { background: var(--primary); color: #fff; }
.task-action-start:hover { background: var(--primary-hover); box-shadow: 0 3px 10px rgba(22,163,74,.3); }

.task-action-complete { background: #fff; color: #15803d; border: 2px solid #16a34a; }
.task-action-complete:hover { background: var(--success-light); }

.task-action-edit     { background: var(--bg-muted); color: var(--text); border: 1px solid var(--border); }
.task-action-edit:hover { background: var(--border); }

.task-action-print    { background: var(--bg-muted); color: var(--text-secondary); border: 1px solid var(--border); }
.task-action-print:hover { background: var(--border); }

.task-action-cancel   { background: #fff; color: var(--destructive); border: 1px solid #fecaca; }
.task-action-cancel:hover { background: var(--destructive-light); border-color: var(--destructive); }

.task-action-delete   { background: #fff; color: var(--destructive); border: 1px solid #fecaca; margin-top: 4px; }
.task-action-delete:hover { background: var(--destructive-light); border-color: var(--destructive); }

/* Статус "в работе" — баннер */
.task-status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.task-status-banner.in-progress {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}
.task-status-banner.done {
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  color: #15803d;
  flex-direction: column;
  text-align: center;
  padding: 20px;
  gap: 6px;
}
.task-status-banner.done svg { width: 28px; height: 28px; }

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

/* =====================================================
   EQUIPMENT CARDS — улучшенный hover
   ===================================================== */
.eq-card {
  position: relative;
  overflow: hidden;
}
.eq-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
  transition: background var(--transition);
  border-radius: 2px 0 0 2px;
}
.eq-card:hover::before {
  background: var(--primary);
}

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