/* ============================================================
   ГКУ ОП Заявки — Единая система стилей (main.css)
   Базовая сетка: 8px (--space-*)
   ------------------------------------------------------------
   CSS-переменные → темизация, переопределение под бренд
   ============================================================ */

/* ─── CSS Custom Properties (Theme) ─────────────────────── */
:root {
  /* Цветовая палитра */
  --color-primary: #e94560;
  --color-primary-hover: #d63851;
  --color-primary-light: #fef2f2;
  --color-primary-bg: #fce4ec;

  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-surface-hover: #f9fafb;
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-border-focus: #e94560;

  --color-text: #1a1a2e;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-text-inverse: #ffffff;

  /* Семантические цвета */
  --color-success: #10b981;
  --color-success-bg: #d1fae5;
  --color-success-text: #065f46;
  --color-warning: #f59e0b;
  --color-warning-bg: #fef3c7;
  --color-warning-text: #92400e;
  --color-error: #ef4444;
  --color-error-bg: #fee2e2;
  --color-error-text: #991b1b;
  --color-info: #3b82f6;
  --color-info-bg: #dbeafe;
  --color-info-text: #1e40af;

  /* Статусы заявок */
  --color-status-new-bg: #dbeafe;
  --color-status-new-text: #1e40af;
  --color-status-work-bg: #fef3c7;
  --color-status-work-text: #92400e;
  --color-status-ready-bg: #c9fec7;
  --color-status-ready-text: #0e9250;
  --color-status-approved-bg: #d1fae5;
  --color-status-approved-text: #065f46;
  --color-status-rejected-bg: #fee2e2;
  --color-status-rejected-text: #991b1b;
  --color-status-parts-bg: #ffedd5;
  --color-status-parts-text: #9a3412;
  --color-status-resolved-bg: #d1fae5;
  --color-status-resolved-text: #065f46;
  --color-status-completed-bg: #10b981;
  --color-status-completed-text: #ffffff;
  --color-status-default-bg: #f3f4f6;
  --color-status-default-text: #374151;

  /* Типографика */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 22px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* 8px базовая сетка */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Скругления */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-2xl: 12px;
  --radius-full: 9999px;

  /* Тени */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-xl: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-button: 0 2px 4px rgba(233,69,96,0.3);
  --shadow-button-hover: 0 4px 12px rgba(233,69,96,0.4);

  /* Анимации */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-index слои */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 900;
  --z-modal: 950;
  --z-preview: 999;
  --z-lightbox: 1000;
  --z-toast: 1100;
}

/* ─── Сброс и база ─────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Утилиты ──────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ─── Header ───────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: var(--color-text-inverse);
  padding: var(--space-5) var(--space-8);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.header h1 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.3px;
}

.header h1 span { color: var(--color-primary); }

.header a {
  color: var(--color-primary);
  font-size: var(--font-size-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.header a:hover {
  background: rgba(233, 69, 96, 0.1);
  text-decoration: none;
}

/* ─── Container ────────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5);
}

/* ─── Карточки ─────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
  transition: box-shadow var(--transition-base);
}

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

.card h2 {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-4);
  font-weight: var(--font-weight-semibold);
}

/* ─── Сетка информации ─────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

.info-item .label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.3px;
}

.info-item .value {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  line-height: var(--line-height-tight);
}

/* ─── Кнопки ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  line-height: var(--line-height-tight);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-button);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.btn-success {
  background: var(--color-success);
  color: var(--color-text-inverse);
}

.btn-success:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}

.btn-warning {
  background: var(--color-warning);
  color: var(--color-text-inverse);
}

.btn-warning:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-1px);
}

.btn-info {
  background: var(--color-info);
  color: var(--color-text-inverse);
}

.btn-info:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-lg);
}

/* ─── Поля ввода ───────────────────────────────────────── */
.input, .select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  outline: none;
  transition: all var(--transition-base);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  min-height: 40px;
}

.input:focus, .select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.input::placeholder {
  color: var(--color-text-muted);
}

.input.error, .select.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input.success, .select.success {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* ─── Фильтры ──────────────────────────────────────────── */
.filters {
  background: var(--color-surface);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
}

.filters .input { flex: 1; min-width: 220px; }
.filters .select { width: auto; min-width: 160px; }

/* ─── Табы ─────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
}

.tab-btn {
  flex: 1;
  padding: var(--space-3) var(--space-5);
  border: none;
  background: var(--color-surface);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--color-text-secondary);
  text-align: center;
  position: relative;
}

.tab-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.tab-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.tab-btn .count {
  display: inline-block;
  background: rgba(0,0,0,0.08);
  border-radius: var(--radius-full);
  padding: 1px var(--space-2);
  font-size: var(--font-size-xs);
  margin-left: var(--space-1);
  min-width: 24px;
  text-align: center;
}

.tab-btn.active .count {
  background: rgba(255,255,255,0.25);
}

/* ─── Таблица ──────────────────────────────────────────── */
.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-light);
}

table { width: 100%; border-collapse: collapse; }

th {
  background: var(--color-surface-hover);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.5px;
  transition: color var(--transition-fast);
}

th:hover { color: var(--color-primary); }

th .arrow {
  margin-left: var(--space-1);
  font-size: 10px;
  display: inline-block;
  transition: transform var(--transition-fast);
}

td {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border-light);
  font-size: var(--font-size-base);
  vertical-align: middle;
}

tr {
  transition: background var(--transition-base);
}

tr:hover td {
  background: #b1cbfd;
  transition: background var(--transition-base);
}

/* Анимация появления строк */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.table-wrap tbody tr {
  animation: rowFadeIn 0.25s ease both;
}

.table-wrap tbody tr:nth-child(1) { animation-delay: 0s; }
.table-wrap tbody tr:nth-child(2) { animation-delay: 0.02s; }
.table-wrap tbody tr:nth-child(3) { animation-delay: 0.04s; }
.table-wrap tbody tr:nth-child(4) { animation-delay: 0.06s; }
.table-wrap tbody tr:nth-child(5) { animation-delay: 0.08s; }
.table-wrap tbody tr:nth-child(6) { animation-delay: 0.10s; }
.table-wrap tbody tr:nth-child(7) { animation-delay: 0.12s; }
.table-wrap tbody tr:nth-child(8) { animation-delay: 0.14s; }
.table-wrap tbody tr:nth-child(9) { animation-delay: 0.16s; }
.table-wrap tbody tr:nth-child(10) { animation-delay: 0.18s; }

/* Zebra-striping — чередование цветов строк */
.table-wrap tbody tr:nth-child(even) {
  background-color: #f8faff;
}

.table-wrap tbody tr:hover {
  background-color: #d0e2ff !important;
}

/* Иконка скрепки (paperclip) рядом с номером заявки */
.paperclip-icon {
  font-size: 0.75em;
  margin-left: 4px;
  color: var(--color-text-muted);
  vertical-align: middle;
  display: inline-block;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.ticket-link:hover .paperclip-icon {
  opacity: 1;
  color: var(--color-primary);
}

/* ─── Бейджи статусов ──────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  line-height: 1.6;
}

.status-new { background: var(--color-status-new-bg); color: var(--color-status-new-text); }
.status-work { background: var(--color-status-work-bg); color: var(--color-status-work-text); }
.status-ready { background: var(--color-status-ready-bg); color: var(--color-status-ready-text); }
.status-approved { background: var(--color-status-approved-bg); color: var(--color-status-approved-text); }
.status-rejected { background: var(--color-status-rejected-bg); color: var(--color-status-rejected-text); }
.status-parts { background: var(--color-status-parts-bg); color: var(--color-status-parts-text); }
.status-resolved { background: var(--color-status-resolved-bg); color: var(--color-status-resolved-text); }
.status-completed { background: var(--color-status-completed-bg); color: var(--color-status-completed-text); }
.status-completed::before { content: "✓ "; font-weight: var(--font-weight-bold); }
.status-default { background: var(--color-status-default-bg); color: var(--color-status-default-text); }

/* ─── Ссылка на заявку ─────────────────────────────────── */
.ticket-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast);
}

.ticket-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ─── Пагинация ────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
  user-select: none;
}

.page-btn:hover:not(:disabled):not(.active) {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.page-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-button);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  padding: 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ─── Загрузка / Пусто / Ошибка ────────────────────────── */
.loading, .empty {
  text-align: center;
  padding: var(--space-10);
  color: var(--color-text-muted);
}

.loading::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: var(--space-2);
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-msg {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  display: none;
  font-size: var(--font-size-base);
  border-left: 4px solid var(--color-error);
  animation: slideDown 0.3s ease;
}

.error-msg.success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-left-color: var(--color-success);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Согласование ─────────────────────────────────────── */
.soglasovano-line {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  display: inline-block;
  border-left: 4px solid #059669;
}

/* ─── История ──────────────────────────────────────────── */
.history-item {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
  padding-left: var(--space-3);
  border-left: 3px solid transparent;
}

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

.history-item:hover {
  background: var(--color-surface-hover);
  border-left-color: var(--color-primary);
  padding-left: calc(var(--space-3) + var(--space-2));
}

.history-item .date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.history-item .date .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}

.history-item .comment {
  margin-top: var(--space-2);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  white-space: pre-wrap;
}

.history-item .changes {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.change-tag {
  display: inline-block;
  background: var(--color-surface-hover);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
}

/* ─── Кнопки действий ──────────────────────────────────── */
.action-buttons {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  justify-content: flex-end;
  align-items: center;
}

/* Кнопка "Назад к списку" — единый стиль с btn-action, синий оттенок */
.btn-back {
  background: var(--color-info);
  color: var(--color-text-inverse);
  border: none;
  text-decoration: none;
}

.btn-back:hover {
  background: #2563eb;
  color: var(--color-text-inverse);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

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

.btn-action {
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.btn-complete { background: var(--color-success); color: var(--color-text-inverse); }
.btn-complete:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,0.4); }
.btn-archive { background: var(--color-warning); color: var(--color-text-inverse); }
.btn-archive:hover { background: #d97706; box-shadow: 0 4px 12px rgba(245,158,11,0.4); }
.btn-restore { background: var(--color-info); color: var(--color-text-inverse); }
.btn-restore:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.4); }

/* ─── Изображения и документы ──────────────────────────── */
.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.image-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface-hover);
  position: relative;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  animation: cardFadeIn 0.3s ease both;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.image-card:nth-child(1) { animation-delay: 0s; }
.image-card:nth-child(2) { animation-delay: 0.05s; }
.image-card:nth-child(3) { animation-delay: 0.10s; }
.image-card:nth-child(4) { animation-delay: 0.15s; }
.image-card:nth-child(5) { animation-delay: 0.20s; }
.image-card:nth-child(6) { animation-delay: 0.25s; }

.image-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.image-card .preview-wrap {
  width: 100%;
  height: 150px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-hover);
  cursor: pointer;
  position: relative;
}

.image-card .preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-slow);
}

.image-card:hover .preview-wrap img {
  transform: scale(1.05);
}

.image-card .preview-wrap img.contain {
  object-fit: contain;
  padding: var(--space-2);
}

.image-card .preview-wrap .doc-icon {
  font-size: 48px;
  opacity: 0.5;
}

.image-card .preview-wrap:hover { opacity: 0.9; }

.image-card .image-info {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.image-card .image-info .filename {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.image-card .image-info .file-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-1);
}

.file-type-badge {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.file-type-pdf { background: #fee2e2; color: #991b1b; }
.file-type-docx { background: #dbeafe; color: #1e40af; }
.file-type-xlsx { background: #d1fae5; color: #065f46; }
.file-type-txt { background: #f3f4f6; color: #374151; }
.file-type-img { background: #fef3c7; color: #92400e; }

.image-card .delete-btn {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  background: rgba(239, 68, 68, 0.9);
  color: var(--color-text-inverse);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition-base);
  z-index: 2;
  backdrop-filter: blur(4px);
}

.image-card:hover .delete-btn { opacity: 1; }
.image-card .delete-btn:hover { background: #dc2626; transform: scale(1.1); }

/* ─── Upload area ──────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: var(--space-2);
  position: relative;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-area.drag-over {
  border-style: solid;
  background: var(--color-primary-bg);
  transform: scale(1.02);
  box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.15);
}

.upload-area input[type="file"] { display: none; }

.upload-area .upload-label {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  cursor: pointer;
  pointer-events: none;
}

.upload-area .upload-label strong { color: var(--color-primary); }

.upload-area .upload-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.upload-progress {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  animation: fadeIn 0.3s ease;
}

.upload-progress.error { color: var(--color-error); }
.upload-progress.success { color: var(--color-success); }

/* ─── Preview overlay ──────────────────────────────────── */
.preview-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-preview);
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.preview-overlay .preview-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

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

.preview-overlay .preview-card img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.preview-overlay .preview-card .preview-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}

.preview-overlay .preview-card .preview-actions button {
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  cursor: pointer;
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-base);
}

.preview-overlay .preview-card .preview-actions .btn-confirm {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.preview-overlay .preview-card .preview-actions .btn-confirm:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.preview-overlay .preview-card .preview-actions .btn-cancel {
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
}

.preview-overlay .preview-card .preview-actions .btn-cancel:hover {
  background: var(--color-border);
}

/* ─── Lightbox ─────────────────────────────────────────── */
/* ─── Lightbox ─────────────────────────────────────────── */
.lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-lightbox);
  cursor: zoom-out;
  user-select: none;
  -webkit-user-select: none;
  animation: fadeIn 0.2s ease;
}

.lightbox .lb-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox .lb-content img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  transition: transform 0.2s ease;
  cursor: grab;
  image-rendering: auto;
}

.lightbox .lb-content img:active { cursor: grabbing; }

.lightbox .lb-content img.zoomed {
  cursor: move;
  max-width: none;
  max-height: none;
}

.lightbox .lb-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: calc(var(--z-lightbox) + 1);
}

.lightbox .lb-close:hover { background: rgba(255,255,255,0.3); }

.lightbox .lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: calc(var(--z-lightbox) + 1);
}

.lightbox .lb-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox .lb-prev { left: 16px; }
.lightbox .lb-next { right: 16px; }

.lightbox .lb-toolbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: calc(var(--z-lightbox) + 1);
}

.lightbox .lb-toolbar button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lightbox .lb-toolbar button:hover { background: rgba(255,255,255,0.3); }

.lightbox .lb-counter {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  z-index: calc(var(--z-lightbox) + 1);
}

/* ─── Тосты (уведомления) ─────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--color-primary);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  font-size: var(--font-size-base);
}

.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error { border-left-color: var(--color-error); }
.toast.toast-warning { border-left-color: var(--color-warning); }
.toast.toast-info { border-left-color: var(--color-info); }

.toast .toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast .toast-msg {
  flex: 1;
  color: var(--color-text);
}

.toast .toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--color-text-muted);
  padding: var(--space-1);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.toast .toast-close:hover { color: var(--color-text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

/* ─── Модальное окно ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

.modal h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.modal p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-5);
}

.modal .modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

.modal .modal-actions button {
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  cursor: pointer;
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-base);
}

.modal .modal-actions .btn-confirm {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.modal .modal-actions .btn-confirm:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.modal .modal-actions .btn-cancel {
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
}

.modal .modal-actions .btn-cancel:hover {
  background: var(--color-border);
}

/* ─── Анимации ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Мобильная адаптация (768px) ──────────────────────── */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-4);
  }

  .filters {
    flex-direction: column;
  }

  .filters .input { width: 100%; }
  .filters .select { width: 100%; }

  .info-grid {
    grid-template-columns: 1fr;
  }

  th, td {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
  }
}

/* ─── Мобильная адаптация (430px) ──────────────────────── */
@media (max-width: 430px) {
  body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    min-height: 100vh;
    min-height: 100dvh;
  }

  .header {
    padding: var(--space-3) var(--space-4);
    padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
    gap: var(--space-3);
  }

  .header h1 {
    font-size: var(--font-size-xl);
  }

  .container {
    padding: var(--space-3);
    padding-left: calc(var(--space-3) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--space-3) + env(safe-area-inset-right, 0px));
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
  }

  .card h2 {
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-3);
  }

  .filters {
    padding: var(--space-3);
    gap: var(--space-2);
    flex-direction: column;
  }

  .filters .input {
    min-width: 0;
    width: 100%;
    font-size: var(--font-size-lg);
    padding: var(--space-3);
    min-height: 44px;
  }

  .filters .select {
    width: 100%;
    font-size: var(--font-size-lg);
    padding: var(--space-3);
    min-height: 44px;
  }

  .filters .btn {
    width: 100%;
    text-align: center;
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-lg);
    min-height: 44px;
  }

  /* Превращаем таблицу в карточки */
  .table-wrap {
    border-radius: var(--radius-lg);
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody tr {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-3);
    padding: var(--space-3) var(--space-4);
    position: relative;
    animation: none;
  }

  .table-wrap tbody tr:hover {
    background-color: #d0e2ff;
  }

  .table-wrap tbody tr:hover td {
    background: transparent;
  }

  .table-wrap td {
    border: none;
    padding: var(--space-1) 0;
    font-size: var(--font-size-base);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    min-height: 28px;
  }

  .table-wrap td::before {
    content: attr(data-label);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
    flex-shrink: 0;
    min-width: 70px;
  }

  .table-wrap td:first-child {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    padding-top: 0;
  }

  .table-wrap td:first-child::before {
    content: "№ заявки";
  }

  .table-wrap td:nth-child(2)::before {
    content: "Статус";
  }

  .table-wrap td:nth-child(3)::before {
    content: "Инв. номер";
  }

  .table-wrap td:nth-child(4)::before {
    content: "Кабинет";
  }

  .table-wrap td:nth-child(5)::before {
    content: "Обновлено";
  }

  .status-badge {
    font-size: var(--font-size-sm);
    padding: var(--space-1) var(--space-3);
    min-height: 28px;
    display: inline-flex;
    align-items: center;
  }

  .ticket-link {
    font-size: var(--font-size-lg);
    display: inline-block;
    padding: var(--space-1) 0;
    min-height: 44px;
    line-height: 44px;
  }

  .pagination {
    padding: var(--space-3) 0;
    gap: var(--space-1);
    flex-wrap: wrap;
  }

  .page-btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-base);
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .loading, .empty {
    padding: var(--space-8) var(--space-4);
    font-size: var(--font-size-base);
  }

  .error-msg {
    font-size: var(--font-size-base);
    padding: var(--space-3) var(--space-4);
  }

  /* Детали заявки на мобильных */
  .info-item .value {
    font-size: var(--font-size-base);
  }

  .info-item .label {
    font-size: 10px;
  }

  .status-badge {
    font-size: var(--font-size-sm);
    padding: var(--space-1) var(--space-3);
    min-height: 28px;
  }

  .soglasovano-line {
    font-size: var(--font-size-sm);
    padding: var(--space-1) var(--space-3);
    word-break: break-word;
  }

  .history-item {
    padding: var(--space-3) 0;
  }

  .history-item .comment {
    font-size: var(--font-size-sm);
  }

  .history-item .date {
    font-size: var(--font-size-xs);
  }

  .change-tag {
    font-size: var(--font-size-xs);
    padding: 2px var(--space-2);
  }

  .back-link {
    font-size: var(--font-size-base);
    padding: var(--space-2) 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .loading, .error {
    padding: var(--space-8) var(--space-4);
    font-size: var(--font-size-base);
  }

  /* Изображения на мобильных */
  .images-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }

  .image-card .preview-wrap {
    height: 100px;
  }

  .image-card .image-info {
    padding: var(--space-1) var(--space-2);
    font-size: 9px;
  }

  .image-card .image-info .filename {
    font-size: 10px;
  }

  .image-card .delete-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    opacity: 1;
    top: var(--space-1);
    right: var(--space-1);
  }

  .upload-area {
    padding: var(--space-4);
  }

  .upload-area .upload-label {
    font-size: var(--font-size-sm);
  }

  /* Lightbox на мобильных */
  .lightbox .lb-close {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .lightbox .lb-nav {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .lightbox .lb-prev { left: 8px; }
  .lightbox .lb-next { right: 8px; }

  .lightbox .lb-toolbar button {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
  }

  .lightbox .lb-counter {
    font-size: var(--font-size-xs);
    bottom: 52px;
  }

  /* Тосты на мобильных */
  .toast-container {
    top: auto;
    bottom: var(--space-4);
    right: var(--space-3);
    left: var(--space-3);
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  /* Модальные окна на мобильных */
  .modal {
    padding: var(--space-5);
    max-width: none;
    width: 92%;
  }

  .modal .modal-actions {
    flex-direction: column;
  }

  .modal .modal-actions button {
    width: 100%;
    text-align: center;
    padding: var(--space-3);
    min-height: 44px;
  }
}

/* ─── Мобильная адаптация (360px) ──────────────────────── */
@media (max-width: 360px) {
  .header h1 {
    font-size: var(--font-size-lg);
  }

  .table-wrap tbody tr {
    padding: var(--space-2) var(--space-3);
  }

  .table-wrap td {
    font-size: var(--font-size-sm);
  }

  .table-wrap td::before {
    min-width: 60px;
    font-size: 10px;
  }

  .card {
    padding: var(--space-3);
  }

  .info-item .value {
    font-size: var(--font-size-sm);
  }
}

/* ─── Адаптация для планшетов (600px) ──────────────────── */
@media (max-width: 600px) {
  .images-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-2);
  }

  .image-card .preview-wrap {
    height: 120px;
  }

  .image-card .image-info {
    padding: var(--space-1) var(--space-2);
    font-size: 10px;
  }

  .image-card .delete-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    opacity: 1;
    top: var(--space-1);
    right: var(--space-1);
  }

  .upload-area {
    padding: var(--space-4);
  }

  .upload-area .upload-label {
    font-size: var(--font-size-sm);
  }

  .lightbox .lb-close {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .lightbox .lb-nav {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .lightbox .lb-prev { left: 8px; }
  .lightbox .lb-next { right: 8px; }

  .lightbox .lb-toolbar button {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
  }

  .lightbox .lb-counter {
    font-size: var(--font-size-xs);
    bottom: 52px;
  }
}
