/* ============================================================
   ГАРАНТИЯ СЕРВИС — Modern PWA Design
   Mobile-First / dark theme
   ============================================================ */

:root {
  /* Поверхности и фон */
  --bg: #0f172a;
  --bg-elev: #0b1120;
  --surface: #1e293b;
  --surface-2: #263449;
  --surface-3: #2f3f57;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Текст */
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Брендовые акценты */
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --faw: #ef4444;
  --faw-soft: rgba(239, 68, 68, 0.16);
  --sitrak: #3b82f6;
  --sitrak-soft: rgba(59, 130, 246, 0.16);
  --dongfeng: #22c55e;
  --dongfeng-soft: rgba(34, 197, 94, 0.16);
  --howo: #a855f7;
  --howo-soft: rgba(168, 85, 247, 0.16);
  --common: #94a3b8;
  --common-soft: rgba(148, 163, 184, 0.16);

  /* Статусы */
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.16);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.16);

  /* Прочее */
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --nav-h: 64px;
  --sidebar-w: 240px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  /* Для светлой — не используем, оставляем тёмную */
  --text-secondary: #94a3b8;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.12);
  --faw: #dc2626;
  --faw-soft: rgba(220, 38, 38, 0.12);
  --sitrak: #2563eb;
  --sitrak-soft: rgba(37, 99, 235, 0.12);
  --dongfeng: #16a34a;
  --dongfeng-soft: rgba(22, 163, 74, 0.12);
  --howo: #9333ea;
  --howo-soft: rgba(147, 51, 234, 0.12);
  --common: #64748b;
  --common-soft: rgba(100, 116, 139, 0.12);

  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.12);

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] body {
  background-image:
    radial-gradient(1200px 500px at 100% -10%, rgba(2, 132, 199, 0.04), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(147, 51, 234, 0.03), transparent 55%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 100% -10%, rgba(56, 189, 248, 0.08), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(168, 85, 247, 0.06), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  position: relative;
}

/* ============================================================
   Нижняя навигация (табы)
   ============================================================ */
.top-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--border);
  z-index: 300;
}

.top-nav .nav-item {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  min-height: 48px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
}

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

.top-nav .nav-item:active {
  transform: scale(0.94);
}

/* ============================================================
   Экраны
   ============================================================ */
.screen {
  display: none;
  animation: fadeIn 0.22s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Шапки экранов
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  gap: 8px;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-xs);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:active {
  background: var(--surface-2);
  transform: scale(0.94);
}

.btn-text {
  min-height: 44px;
  padding: 0 10px;
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================================
   Поиск
   ============================================================ */
.search-wrap {
  position: relative;
  padding: 4px 16px 8px;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 42px 12px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.search-clear:active {
  background: var(--surface-3);
  color: var(--text);
}

/* ============================================================
   Фильтры (таблетки / pills) — горизонтальная прокрутка
   ============================================================ */
.filter-panel {
  display: flex;
  gap: 8px;
  padding: 8px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

.btn-filter {
  flex-shrink: 0;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-filter:active {
  transform: scale(0.95);
}

.btn-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1120;
  font-weight: 700;
}

/* ============================================================
   Списки
   ============================================================ */
.task-list {
  padding: 8px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
   Карточки заданий
   ============================================================ */
.task-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}

.task-card:active {
  transform: scale(0.985);
  background: var(--surface-2);
}

.task-card .task-info h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.task-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ============================================================
   Карточки смен и запчастей
   ============================================================ */
.shift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.shift-card:active {
  transform: scale(0.99);
}

/* Брендовые акцентные полосы слева */
.shift-card.brand-faw    { border-left: 4px solid var(--faw); }
.shift-card.brand-sitrak { border-left: 4px solid var(--sitrak); }
.shift-card.brand-dongfeng { border-left: 4px solid var(--dongfeng); }
.shift-card.brand-howo   { border-left: 4px solid var(--howo); }
.shift-card.brand-common { border-left: 4px solid var(--common); }

.card-top,
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* VIN / номера — моноширинный, контрастный */
.mono {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
}

.mono-neutral {
  font-family: var(--mono);
  color: var(--text-secondary);
  font-size: 13px;
}

.shift-date {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 4px;
}

.card-comment {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-detail {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-muted {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   Бейджи / чипсы статусов
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-working { background: var(--warn-soft);  color: var(--warn); }
.badge-new     { background: var(--danger-soft); color: var(--danger); }
.badge-done    { background: var(--ok-soft);     color: var(--ok); }
.badge-problem { background: var(--danger-soft); color: var(--danger); }

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.card-comment {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-detail {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-muted {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Статусы запчастей (дополнительно) */
.part-none       { background: var(--common-soft); color: var(--common); }
.part-stock      { background: var(--accent-soft); color: var(--accent); }
.part-stock-plus { background: var(--ok-soft); color: var(--ok); }
.part-wait       { background: var(--warn-soft); color: var(--warn); }
.part-problem    { background: var(--danger-soft); color: var(--danger); }
.part-archive    { background: var(--common-soft); color: var(--text-muted); }


/* ============================================================
   Кнопки статусов (чипсы)
   ============================================================ */
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.status-btn:active {
  transform: scale(0.94);
}

.status-btn[data-status="В работе"] { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.status-btn[data-status="Важно"] { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.status-btn[data-status="Выполнено"] { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status-btn[data-status="Не актуально"] { color: var(--common); background: var(--common-soft); border-color: transparent; }

.status-btn.part-await { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.status-btn.part-stock { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status-btn.part-problem { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

/* Действия с карточкой: уведомить, редактировать, удалить */
.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.action-chip:active { transform: scale(0.94); }

.action-chip.notify { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.action-chip.edit   { color: var(--info); background: var(--info-soft); border-color: transparent; }
.action-chip.delete { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.action-circle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--info-soft);
  color: var(--info);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.action-circle-btn:active {
  transform: scale(0.92);
}

/* ============================================================
   Кнопки-фабрики и главные действия
   ============================================================ */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  right: max(16px, calc((100vw - 640px) / 2 + 16px));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0b1120;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(56, 189, 248, 0.4);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  z-index: 250;
}

.fab:active {
  transform: scale(0.9);
}

.btn-action {
  min-height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 12px 16px;
}

.btn-action.primary {
  background: var(--accent);
  color: #0b1120;
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.3);
}

.btn-action.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-action:active {
  transform: scale(0.97);
}

.btn-action.huge {
  min-height: 56px;
  font-size: 16px;
}

.action-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-danger {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-danger:active {
  background: rgba(239, 68, 68, 0.28);
}

/* ============================================================
   Формы / редактор
   ============================================================ */
.editor-body {
  padding: 8px 16px 16px;
}

.editor-body .input-container {
  position: relative;
  margin-bottom: 14px;
}

.input-container {
  position: relative;
}

.editor-body label,
.input-container > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.editor-body input,
.editor-body select,
.editor-body textarea,
.input-container input,
.input-container select,
.input-container textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.editor-body textarea,
.input-container textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.4;
}

.editor-body input:focus,
.editor-body select:focus,
.editor-body textarea:focus,
.input-container input:focus,
.input-container select:focus,
.input-container textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-body input::placeholder,
.input-container input::placeholder,
.editor-body textarea::placeholder,
.input-container textarea::placeholder {
  color: var(--text-muted);
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

.editor-footer {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

.editor-footer .btn-action {
  margin-bottom: 10px;
}

.toolbar-buttons {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
}

.btn-tool {
  min-width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
}

/* ============================================================
   Автоподсказки
   ============================================================ */
.auto-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow);
}

.auto-suggest.hidden { display: none; }

.auto-suggest-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s ease;
}

.auto-suggest-item:hover,
.auto-suggest-item:active {
  background: var(--surface-2);
}

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

.auto-suggest-item .suggest-vin { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.auto-suggest-item .suggest-plate { color: var(--text-secondary); margin-left: 6px; font-family: var(--mono); }
.auto-suggest-item .suggest-model { color: var(--text-muted); font-size: 12px; }
.auto-suggest-item .suggest-owner { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* Выбранное авто в задании */
.task-auto-info {
  background: var(--surface);
  border: 1px solid var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text);
}

.task-auto-info.hidden { display: none; }

.task-auto-info .auto-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-auto-info .auto-info-row strong {
  font-family: var(--mono);
  color: var(--accent);
}

.task-auto-info .auto-info-detail {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.task-auto-info .btn-remove-auto {
  background: var(--danger-soft);
  color: var(--danger);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

/* ============================================================
   Таймлайн истории
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-strong);
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

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

.timeline-date { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-family: var(--mono); }
.timeline-author { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 2px; }
.timeline-action { font-size: 14px; color: var(--text); }
.timeline-comment { font-size: 13px; color: var(--text-secondary); margin-top: 4px; font-style: italic; }

/* ============================================================
   Галерея фото
   ============================================================ */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-delete-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* --- Видео в галерее --- */
.photo-thumb.is-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 50%;
  font-size: 16px;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

/* ============================================================
   Просмотрщик фото
   ============================================================ */
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-img-container { width: 100%; }
.viewer-img-container img { width: 100%; }

.viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  width: 48px;
  height: 64px;
  font-size: 22px;
  border-radius: var(--radius-xs);
}

.viewer-nav.left  { left: 8px; }
.viewer-nav.right { right: 8px; }

/* ============================================================
   Модальные окна (нижние листы)
   ============================================================ */
.modal.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex !important;
  align-items: flex-end;
  justify-content: center;
}

.modal .modal-sheet {
  background: var(--bg-elev);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 0;
  animation: slideUp 0.25s ease;
  border-top: 1px solid var(--border);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal .modal-head {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
}

.modal .modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal .modal-head .modal-close {
  background: var(--surface);
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.modal .modal-body {
  padding: 16px;
}

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.modal input,
.modal select,
.modal textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.modal textarea { min-height: 80px; resize: vertical; }

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-field { margin-bottom: 16px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 900;
  max-width: 90vw;
  text-align: center;
  animation: toastIn 0.25s ease;
}

.toast.hidden { display: none; }

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

/* ============================================================
   Пустые состояния
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 15px;
}

/* Утилиты */
.hidden { display: none !important; }

/* Кнопка камеры под большим пальцем */
.editor-footer { position: sticky; bottom: 0; background: var(--bg-elev); padding: 16px; border-top: 1px solid var(--border); z-index: 100; }
#btn-camera-system { width: 100%; margin-bottom: 10px; min-height: 64px; font-size: 18px; }

/* Улучшение просмотрщика */
.photo-viewer { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.viewer-img-container { width: 100%; display: flex; align-items: center; justify-content: center; }
.viewer-img-container img { max-width: 100%; max-height: 90vh; object-fit: contain; }
.viewer-img-container video { max-width: 100%; max-height: 90vh; object-fit: contain; border-radius: var(--radius-xs); }
.viewer-close { position: absolute; top: 16px; right: 16px; color: white; background: rgba(255,255,255,0.2); border: none; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; z-index: 1001; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); color: white; background: rgba(255,255,255,0.2); border: none; width: 50px; height: 60px; font-size: 24px; border-radius: 8px; z-index: 1001; }
.left { left: 8px; }
.right { right: 8px; }

/* ============================================================
   Sidebar (скрыт на мобилке)
   ============================================================ */
.sidebar {
  display: none;
}

/* ============================================================
   DESKTOP — @media (min-width: 769px)
   ============================================================ */
@media (min-width: 769px) {

  /* --- Скрываем мобильное нижнее меню --- */
  .top-nav { display: none !important; }

  /* --- Показываем сайдбар --- */
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    z-index: 400;
    padding: 24px 0;
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
  }

  .sidebar-logo-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
  }

  .sidebar-brand {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
  }

  .sidebar-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
  }

  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
  }

  .sidebar-item:hover {
    background: var(--surface);
    color: var(--text);
  }

  .sidebar-item.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
  }

  .sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
  }

  .sidebar-status {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .sidebar-status.online { color: var(--ok); }
  .sidebar-status.offline { color: var(--danger); }

  /* --- Основная область --- */
  .main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    padding-bottom: 24px;
  }

  #app {
    max-width: none;
    margin: 0;
    padding-bottom: 0;
  }

  /* --- Заголовки экранов --- */
  .header {
    padding: 24px 32px 16px;
  }

  .header h1 {
    font-size: 24px;
  }

  /* --- Поиск --- */
  .search-wrap {
    padding: 8px 32px 12px;
  }

  .search-clear {
    width: auto;
    min-width: 64px;
    height: 44px;
    right: 40px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    gap: 4px;
    font-size: 20px;
    padding: 0 14px;
  }

  .search-clear::after {
    content: "Очистить";
    font-size: 14px;
    font-weight: 500;
  }

  .search-clear:active,
  .search-clear:hover {
    background: var(--surface-3);
    color: var(--text);
  }

  .search-input {
    padding-right: 120px;
  }

  /* --- Фильтры --- */
  .filter-panel {
    padding: 8px 32px 4px;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  /* --- Списки / сетка карточек --- */
  .task-list {
    padding: 16px 32px 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
  }

  .task-list .shift-card {
    margin-bottom: 0;
  }

  /* --- Карточки заданий --- */
  .task-card {
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  }

  .task-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
  }

  /* --- Карточки смен --- */
  .shift-card {
    transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .shift-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
  }

  /* --- Кнопки --- */
  .status-btn:hover,
  .action-chip:hover,
  .btn-filter:hover,
  .btn-icon:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
  }

  .btn-action:hover {
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
    transform: translateY(-1px);
  }

  .btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
  }

  .fab:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 36px rgba(56, 189, 248, 0.5);
  }

  /* --- FAB позиция на десктопе --- */
  .fab {
    right: 32px;
    bottom: 32px;
  }

  /* --- Модальные окна — центрируем по вертикали --- */
  .modal {
    align-items: center;
  }

  .modal .modal-sheet {
    max-width: 700px;
    border-radius: 20px;
    animation: modalFadeIn 0.25s ease;
  }

  @keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
  }

  @keyframes slideUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
  }

  /* --- Редактор --- */
  .editor-body {
    padding: 16px 32px 24px;
  }

  .editor-footer {
    padding: 16px 32px 24px;
    position: sticky;
    bottom: 0;
  }

  /* --- Галерея фото — 4 колонки на десктопе --- */
  .photo-gallery {
    grid-template-columns: repeat(4, 1fr);
  }

  /* --- Toast — подняли выше --- */
  .toast {
    bottom: 32px;
  }

  /* --- Поиск/автоподсказки — шире --- */
  .auto-suggest {
    max-height: 320px;
  }
}

/* === ЭКРАН ВХОДА === */
.screen-login {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.screen-login.hidden {
  display: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  margin: 16px;
  text-align: center;
}

.login-logo {
  font-size: 56px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 4px;
}

.login-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.login-field {
  margin-bottom: 16px;
  text-align: left;
}

.login-field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.login-field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.login-error.hidden {
  display: none;
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 4px;
}

.login-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 16px;
}

/* --- Кнопка выхода в сайдбаре --- */
.sidebar-logout {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  margin-top: 12px;
  transition: color 0.2s, border-color 0.2s;
}

.sidebar-logout:hover {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

