/* ==========================================================================
   Маршрутный лист и Поставщики - Мобильный и Десктопный интерфейс
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #243248;
  --bg-input: #0f172a;
  --bg-header: #1e293b;
  
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Акцентный зелёный для выполненных маршрутов */
  --success-bg: rgba(34, 197, 94, 0.16);
  --success-border: #22c55e;
  --success-text: #4ade80;
  --success-solid: #22c55e;
  
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overscroll-behavior-y: none;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Pull to Refresh Indicator */
.pull-to-refresh-indicator {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -60px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  transition: transform 0.15s ease-out, border-color 0.2s, color 0.2s;
}

.pull-to-refresh-indicator.ready {
  border-color: var(--border-focus);
  color: var(--border-focus);
}

.pull-to-refresh-indicator.refreshing .ptr-spinner {
  display: inline-block;
  animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: var(--radius-md);
}

.brand-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-title .subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.status-badge:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.status-dot.syncing {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: pulse 1s infinite alternate;
}

.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.icon-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--border-color);
}

/* Tabs */
.tabs-nav {
  display: flex;
  padding: 0 16px;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

.badge {
  background: var(--border-color);
  color: var(--text-primary);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.tab-btn.active .badge {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

/* ==========================================================================
   Main Container & Sections
   ========================================================================== */
.main-container {
  flex: 1;
  padding: 16px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Controls Bar & Calendar Picker */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.date-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.date-range-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-sublabel {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.range-input {
  min-width: 120px !important;
  width: 130px !important;
  padding: 7px 34px 7px 10px !important;
  font-size: 13px !important;
}

.btn-filter-apply {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-filter-apply:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

/* Calendar Input with visual button */
.calendar-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.calendar-input-wrapper.flex-1 {
  flex: 1;
}

.date-calendar-picker {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 7px 38px 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 145px;
}

.date-calendar-picker:focus {
  border-color: var(--border-focus);
}

.calendar-trigger-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #38bdf8;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
  min-width: 240px;
}

.search-box.flex-1 {
  flex: 1;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.search-suggestions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 260px;
  background: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.15);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0;
}

.suggestion-section-title {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  gap: 8px;
}

.suggestion-item:hover, .suggestion-item.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
}

.suggestion-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.suggestion-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  flex-shrink: 0;
}

.suggestion-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

.view-buttons {
  display: flex;
  gap: 4px;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.action-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.action-checkbox-label:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-hover);
  color: var(--text-primary);
}

.action-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3b82f6;
  margin: 0;
}

.action-checkbox-label.active,
.action-checkbox-label:has(input:checked) {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

.stats-summary {
  font-size: 14px;
  color: var(--text-secondary);
}

.stats-summary strong {
  color: var(--success-text);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  border: none;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-ghost.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 16px;
  padding: 6px 10px;
}

.btn-icon.active {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-color: #38bdf8;
}

/* ==========================================================================
   Table Styling & Row Green Highlight Requirement
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: #172033;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.data-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* ТРЕБОВАНИЕ: ЕСЛИ ЧЕКБОКС ОТМЕЧЕН, ВСЯ СТРОКА ПОДСВЕЧИВАЕТСЯ ЗЕЛЕНЫМ! */
.data-table tbody tr.row-completed,
.route-card.row-completed {
  background-color: var(--success-bg) !important;
  border-left: 4px solid var(--success-border) !important;
}

.data-table tbody tr.row-completed td {
  border-bottom-color: rgba(34, 197, 94, 0.25);
}

.data-table tbody tr.row-completed:hover {
  background-color: rgba(34, 197, 94, 0.22) !important;
}

/* Интерактивный чекбокс */
.status-checkbox-cell {
  text-align: center;
}

.checkbox-custom-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.checkbox-custom-wrap input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: #22c55e;
  border-radius: 4px;
}

/* ==========================================================================
   КОЛОНКА «СЧЁТ» (Множественные счета любых форматов)
   ========================================================================== */
.invoices-cell-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  max-width: 270px;
}

.route-card .invoices-cell-wrapper {
  max-width: 100%;
}

.invoice-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  max-width: 100%;
  box-sizing: border-box;
}

.invoice-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-chip:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: #22c55e;
  transform: translateY(-1px);
}

/* Все типы файлов (Excel, Word, Фото, PDF) оформлены в едином зеленом цвете */
.invoice-chip.excel,
.invoice-chip.word,
.invoice-chip.photo,
.invoice-chip.pdf {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.add-invoice-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.add-invoice-mini-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.no-invoices-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  cursor: pointer;
}

.no-invoices-hint:hover {
  color: #38bdf8;
}

/* Поставщик в таблице */
.table-supplier-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  word-break: break-word;
  max-width: 150px;
}

.route-proxy-badge {
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1px;
  margin-bottom: 3px;
  letter-spacing: 0.2px;
}

.table-supplier-details {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  word-break: break-word;
  max-width: 170px;
}

.table-supplier-details a {
  color: #38bdf8;
  text-decoration: none;
}

/* Заметки в таблице: компактная ширина с автопереносом строк */
.notes-text {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-width: 190px;
  line-height: 1.4;
}

.notes-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}

/* Действия в таблице */
.table-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn-mini {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn-mini:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.action-btn-mini.delete:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* ==========================================================================
   МНОЖЕСТВЕННЫЕ СЧЕТА В МОДАЛЬНОМ ОКНЕ
   ========================================================================== */
.modal-dialog-lg {
  max-width: 940px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.count-pill {
  font-size: 11px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.invoices-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 150px;
  overflow-y: auto;
}

.invoice-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: all 0.2s;
}

.invoice-item-row:hover {
  border-color: #475569;
}

.invoice-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: #000;
  border: 1px solid var(--border-color);
  cursor: pointer;
  flex-shrink: 0;
}

.invoice-item-thumb.icon-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: #1e293b;
}

.invoice-item-thumb.icon-thumb.excel {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
}

.invoice-item-thumb.icon-thumb.word {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
}

.invoice-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.invoice-item-name-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  outline: none;
}

.invoice-item-name-input:focus {
  background: #1e293b;
  border-color: var(--border-focus);
}

.invoice-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.format-tag {
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 10px;
}

.format-tag.excel { background: #14532d; color: #86efac; }
.format-tag.word { background: #1e3a8a; color: #93c5fd; }
.format-tag.photo { background: #78350f; color: #fde047; }
.format-tag.pdf { background: #7f1d1d; color: #fca5a5; }

.invoice-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.btn-icon-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Multi-upload dropzone */
.multi-upload-box {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.5);
  transition: all 0.2s;
}

.multi-upload-box:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

.upload-box-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.upload-icons-row {
  display: flex;
  gap: 12px;
  font-size: 24px;
  margin-bottom: 2px;
}

.upload-text-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-subtext {
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-note {
  font-size: 11px;
  color: #38bdf8;
  margin-top: 2px;
}

.converting-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  font-size: 13px;
  color: #38bdf8;
}

.spinner-ring {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Cards View (Mobile driver friendly)
   ========================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.route-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.card-date-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.card-date-badge:has(.table-date-wrap),
.card-date-badge:has(.table-date-cell-container) {
  padding: 0;
  background: transparent;
  border: none;
}

.card-supplier-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.card-meta-row a {
  color: #38bdf8;
  text-decoration: none;
}

.card-invoices-section {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 10px 0;
}

.card-invoices-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.card-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
  margin-top: 10px;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  overflow-y: auto;
}

.modal-backdrop.open {
  display: flex !important;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.25s ease-out;
  overflow: hidden;
}

.modal-dialog.modal-dialog-lg {
  width: 95vw;
  max-width: 1080px;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-form {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.modal-body {
  padding: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--border-focus);
}

.input-with-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-actions .btn-sm {
  flex-shrink: 0;
  white-space: nowrap;
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.supplier-preview {
  margin-top: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
}

.preview-item {
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.checkbox-label-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.checkbox-label-custom input {
  width: 18px;
  height: 18px;
  accent-color: #22c55e;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  z-index: 10;
}

/* Сетка для компактного отображения маршрутов на десктопе */
.route-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.route-modal-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal-dialog-lg .route-type-toggle-bar {
  margin: 0 0 12px 0;
  padding: 8px 14px;
}

.modal-dialog-lg .form-group {
  margin-bottom: 12px;
}

/* ==========================================================================
   PHOTO / INVOICE VIEWER MODAL
   ТРЕБОВАНИЕ: ОТКРЫТИЕ ЛЮБОГО СЧЕТА В ВИДЕ ФОТО
   ========================================================================== */
.photo-viewer-backdrop {
  z-index: 200;
  padding: 0;
  background: rgba(0, 0, 0, 0.94);
}

.photo-viewer-dialog {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  background: transparent;
  border: none;
  box-sizing: border-box;
}

.photo-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
  flex-wrap: nowrap;
  gap: 16px;
  flex-shrink: 0;
  height: 60px;
  box-sizing: border-box;
}

.photo-viewer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.viewer-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  flex-shrink: 0;
}

/* Левая часть: Поставщик и кнопки действий (Печать, Скачать, Удалить) */
.photo-viewer-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.photo-viewer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  flex-shrink: 0;
}

/* Правая часть: Навигация вправо/влево и кнопка закрытия документа */
.photo-viewer-right {
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.action-btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.action-btn-pill.print {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.action-btn-pill.print:hover {
  background: rgba(56, 189, 248, 0.3);
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.action-btn-pill.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.action-btn-pill.danger:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  transform: translateY(-1px);
}

.action-btn-pill.download {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}

.action-btn-pill.download:hover {
  background: rgba(52, 211, 153, 0.3);
  border-color: #34d399;
  transform: translateY(-1px);
}

.action-btn-pill.share {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
}

.action-btn-pill.share:hover {
  background: rgba(168, 85, 247, 0.3);
  border-color: #a855f7;
  transform: translateY(-1px);
}

/* На десктопе скрыта мобильная кнопка "Поделиться" */
.mobile-only-btn {
  display: none !important;
}

/* Название файла в шапке просмотрщика (сразу после кнопки «Удалить счёт») */
.viewer-file-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  max-width: min(260px, calc(22ch + 42px));
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-sizing: border-box;
}

.viewer-file-name > span:first-child {
  flex-shrink: 0;
}

.viewer-file-name-text {
  min-width: 0;
  max-width: 20ch;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* На мобильных устройствах в вертикальном режиме шапка просмотрщика прижата к верху с учетом safe-area */
@media (max-width: 1024px) and (pointer: coarse) and (orientation: portrait), (max-width: 768px) and (orientation: portrait) {
  .photo-viewer-dialog {
    padding-top: max(env(safe-area-inset-top, 0px), 0px) !important;
  }
}

/* На мобильных устройствах и планшетах */
@media (max-width: 1024px) and (pointer: coarse), (max-width: 768px), (max-height: 550px) {

  .photo-viewer-header {
    height: auto;
    min-height: 48px;
    padding: 6px 12px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .photo-viewer-left {
    gap: 8px;
  }

  .photo-viewer-info {
    max-width: 130px;
  }

  .viewer-subtitle {
    font-size: 13px;
  }

  .desktop-only-btn {
    display: none !important;
  }
  
  .mobile-only-btn {
    display: inline-flex !important;
  }

  .photo-viewer-actions {
    gap: 6px;
  }

  .action-btn-pill {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
  }

  .viewer-file-name {
    max-width: min(240px, calc(22ch + 38px));
    font-size: 11px;
    padding: 5px 8px;
    gap: 4px;
  }

  .viewer-file-name-text {
    max-width: 20ch;
  }

  .icon-btn-viewer {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .pagination-badge {
    padding: 4px 8px;
    font-size: 12px;
    min-width: 48px;
  }

  .close-viewer-btn {
    /* На мобильных кнопка закрытия не улетает за пределы экрана */
    margin-left: 10px !important;
  }
}

.pagination-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pagination-badge {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  min-width: 58px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
}

.icon-btn-viewer {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 16px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn-viewer:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.icon-btn-viewer.danger:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: #ef4444;
}

.close-viewer-btn {
  margin: 0;
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  font-size: 15px;
  font-weight: bold;
}

.close-viewer-btn:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}

/* ВЕРТИКАЛЬНЫЙ РЕЖИМ НА МОБИЛЬНЫХ: все элементы в один ряд.
   1. Закрыть (первая кнопка слева)
   2. Название файла
   3. Прокрутка влево и вправо (пагинация)
   4. Пропуск размером как пол-кнопки «Поделиться» (48px)
   5. Кнопка «Поделиться»
   6. Пробел размером как пол-кнопки «Поделиться» (48px)
   7. Кнопка «Удалить счёт»
*/
@media (max-width: 850px) and (orientation: portrait) {
  .photo-viewer-dialog {
    padding-top: max(env(safe-area-inset-top, 0px), 0px) !important;
    margin-top: 0 !important;
  }

  .photo-viewer-header {
    position: relative !important;
    top: 0 !important;
    margin-top: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 4px 10px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .photo-viewer-header::-webkit-scrollbar {
    display: none !important;
  }

  .photo-viewer-header .photo-viewer-left,
  .photo-viewer-header .photo-viewer-actions,
  .photo-viewer-header .photo-viewer-right {
    display: contents !important;
  }

  /* 1. Первая кнопка слева: Закрыть */
  .photo-viewer-header .close-viewer-btn {
    order: 1 !important;
    position: static !important;
    margin: 0 !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    font-size: 15px !important;
    flex-shrink: 0 !important;
    z-index: 10 !important;
  }

  /* 2. Потом название файла (вмещает до 20 символов) */
  .photo-viewer-header .viewer-file-name {
    order: 2 !important;
    position: static !important;
    margin: 0 0 0 8px !important;
    max-width: min(240px, calc(22ch + 38px)) !important;
    height: 34px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    box-sizing: border-box !important;
    align-items: center !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
    min-width: 0 !important;
  }

  .photo-viewer-header .viewer-file-name-text {
    min-width: 0 !important;
    max-width: 20ch !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* 3. Потом прокрутка влево и вправо */
  .photo-viewer-header .pagination-buttons-group {
    order: 3 !important;
    position: static !important;
    margin: 0 0 0 8px !important;
    flex-shrink: 0 !important;
    width: auto !important;
    gap: 4px !important;
    display: flex !important;
    align-items: center !important;
  }

  .photo-viewer-header .pagination-badge {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    text-align: center !important;
    padding: 4px 2px !important;
    font-size: 11px !important;
    box-sizing: border-box !important;
  }

  .photo-viewer-header .icon-btn-viewer {
    width: 34px !important;
    height: 34px !important;
  }

  /* В вертикальном режиме название поставщика перенесено вниз в футер */
  .photo-viewer-header .photo-viewer-info {
    display: none !important;
  }

  /* 4. Пропуск размер как пол кнопки поделится (~48px), потом кнопка Поделиться */
  .photo-viewer-header #shareInvoiceBtn {
    order: 4 !important;
    position: static !important;
    margin: 0 0 0 48px !important; /* Пропуск размером как пол-кнопки поделиться */
    height: 34px !important;
    padding: 5px 12px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    white-space: nowrap !important;
  }

  /* 5. Пробел как пол кнопки поделится (~48px), и потом кнопка Удалить счёт */
  .photo-viewer-header #deleteViewerInvoiceBtn {
    order: 5 !important;
    position: static !important;
    margin: 0 0 0 48px !important; /* Пробел размером как пол-кнопки поделиться */
    height: 34px !important;
    padding: 5px 12px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    white-space: nowrap !important;
  }

  /* В вертикальном режиме футер отображает название поставщика */
  .photo-viewer-footer {
    display: block !important;
    padding: 8px 16px max(env(safe-area-inset-bottom, 0px), 8px) 16px !important;
    text-align: center !important;
    background: rgba(15, 23, 42, 0.98) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0 !important;
  }

  .viewer-footer-supplier {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #f8fafc !important;
    letter-spacing: 0.3px !important;
    display: inline-block !important;
    max-width: 90vw !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* В вертикальном режиме счет не накладывается на верхнее меню и футер */
  .photo-viewer-body {
    padding: 8px 10px !important;
    overflow: hidden !important;
    flex: 1 1 auto !important;
  }

  .photo-zoom-wrapper {
    max-width: 96vw !important;
    max-height: calc(100vh - 110px) !important;
    max-height: calc(100dvh - (env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 110px)) !important;
  }

  .viewer-img {
    max-width: 100% !important;
    max-height: calc(100vh - 114px) !important;
    max-height: calc(100dvh - (env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 114px)) !important;
  }

  .viewer-doc-view {
    max-width: 96vw !important;
    max-height: calc(100vh - 114px) !important;
    max-height: calc(100dvh - (env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 114px)) !important;
  }
}

/* ГОРИЗОНТАЛЬНЫЙ РЕЖИМ (ландшафт и десктоп):
   Кнопки «Удалить счёт» и «Закрыть» поменяны местами.
   Между кнопками пролистать вправо и новым расположением удалить счёт — расстояние как пол кнопки поделиться (48px).
*/
@media (orientation: landscape), (min-width: 851px) and (min-height: 551px) {
  .photo-viewer-dialog {
    padding-top: max(env(safe-area-inset-top, 0px), 0px) !important;
    margin-top: 0 !important;
  }

  .photo-viewer-header {
    height: 38px !important;
    min-height: 38px !important;
    padding: 2px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    overflow-y: hidden !important;
    margin-top: 0 !important;
    top: 0 !important;
  }

  .photo-viewer-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 1 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .photo-viewer-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
  }

  .photo-viewer-right {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }

  /* В десктопном / горизонтальном режиме кнопка закрытия справа, сдвинута левее от края */
  .photo-viewer-header .close-viewer-btn {
    position: static !important;
    margin: 0 48px 0 0 !important;
    left: auto !important;
    top: auto !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
  }

  /* Кнопка «Удалить счёт» слева в начале панели действий */
  .photo-viewer-header #deleteViewerInvoiceBtn {
    position: static !important;
    margin: 0 !important;
    left: auto !important;
    top: auto !important;
    height: 30px !important;
    font-size: 11px !important;
    padding: 3px 10px !important;
    flex-shrink: 0 !important;
  }

  .photo-viewer-header #shareInvoiceBtn {
    position: static !important;
    margin: 0 !important;
    left: auto !important;
    top: auto !important;
    height: 30px !important;
    font-size: 11px !important;
    padding: 3px 10px !important;
  }

  .action-btn-pill {
    padding: 3px 10px !important;
    font-size: 11px !important;
    height: 30px !important;
  }

  .viewer-file-name {
    height: 30px !important;
    padding: 3px 10px !important;
    font-size: 11px !important;
    max-width: min(240px, calc(22ch + 38px)) !important;
  }

  .photo-viewer-header .viewer-file-name-text,
  .viewer-file-name-text {
    min-width: 0 !important;
    max-width: 20ch !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .icon-btn-viewer {
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
  }

  .pagination-badge {
    padding: 3px 6px !important;
    font-size: 11px !important;
    min-width: 44px !important;
    height: 30px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* В горизонтальном режиме счет не накладывается на верхнее меню */
  .photo-viewer-body {
    padding: 8px 10px !important;
    overflow: hidden !important;
  }

  .photo-zoom-wrapper {
    max-width: 96vw !important;
    max-height: calc(100vh - 52px) !important;
    max-height: calc(100dvh - 52px) !important;
  }

  .viewer-img {
    max-width: 100% !important;
    max-height: calc(100vh - 54px) !important;
    max-height: calc(100dvh - 54px) !important;
  }

  .viewer-doc-view {
    max-width: 96vw !important;
    max-height: calc(100vh - 54px) !important;
    max-height: calc(100dvh - 54px) !important;
  }
}

/* Компактный ландшафтный режим на мобильных устройствах: меню поднято выше, счет четко под меню */
@media (orientation: landscape) and (max-height: 550px), (max-height: 500px) and (orientation: landscape) {
  .photo-viewer-dialog {
    padding-top: max(env(safe-area-inset-top, 0px), 0px) !important;
    margin-top: 0 !important;
  }

  .photo-viewer-header {
    height: 34px !important;
    min-height: 34px !important;
    padding: 1px 10px !important;
    margin-top: 0 !important;
    top: 0 !important;
  }

  .photo-viewer-header .close-viewer-btn {
    width: 26px !important;
    height: 26px !important;
    font-size: 12px !important;
    margin: 0 16px 0 0 !important;
  }

  .photo-viewer-header #deleteViewerInvoiceBtn,
  .photo-viewer-header #shareInvoiceBtn,
  .action-btn-pill {
    height: 26px !important;
    font-size: 10px !important;
    padding: 2px 8px !important;
  }

  .photo-viewer-header .viewer-file-name {
    height: 26px !important;
    padding: 2px 8px !important;
    font-size: 10px !important;
    max-width: min(240px, calc(22ch + 34px)) !important;
  }

  .photo-viewer-header .icon-btn-viewer {
    width: 26px !important;
    height: 26px !important;
    font-size: 12px !important;
  }

  .photo-viewer-header .pagination-badge {
    height: 26px !important;
    min-width: 40px !important;
    padding: 1px 4px !important;
    font-size: 10px !important;
  }

  .photo-viewer-body {
    padding: 5px 8px !important;
  }

  .photo-zoom-wrapper {
    max-height: calc(100vh - 46px) !important;
    max-height: calc(100dvh - 46px) !important;
  }

  .viewer-img,
  .viewer-doc-view {
    max-height: calc(100vh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
  }
}

.photo-viewer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-user-select: none;
  padding: 10px;
}

.photo-zoom-wrapper {
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  touch-action: pan-x pan-y;
  will-change: transform;
}

.viewer-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  background: #ffffff;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.viewer-doc-view {
  width: 100%;
  max-width: 95vw;
  max-height: 85vh;
  overflow: auto;
  background: #ffffff;
  color: #0f172a;
  padding: 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  text-align: left;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.viewer-doc-view table {
  border-collapse: collapse;
  font-size: 12px;
  color: #000000;
  background: #ffffff;
  min-width: 100%;
}

.viewer-doc-view th, .viewer-doc-view td {
  padding: 3px 6px;
  text-align: left;
  vertical-align: top;
  color: #000000;
  /* Границы ячеек по умолчанию отсутствуют: отображаются только там, где есть обводка */
  border: none;
}

.viewer-doc-view th {
  font-weight: 700;
  color: #0f172a;
}

.photo-viewer-footer {
  display: none;
  text-align: center;
  padding: 10px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   OFFSCREEN EXCEL/WORD RENDER CONTAINER (Стилизация под фото документа)
   ========================================================================== */
.doc-render-sandbox {
  box-sizing: border-box;
  padding: 30px;
  font-family: Arial, sans-serif;
  line-height: 1.4;
  background: #ffffff;
  color: #111827;
}

.doc-render-sandbox table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 15px;
}

.doc-render-sandbox th,
.doc-render-sandbox td {
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  text-align: left;
}

.doc-render-sandbox th {
  background: #f1f5f9;
  font-weight: bold;
}

/* ==========================================================================
   Toast Notifications (Отключены по требованию пользователя)
   ========================================================================== */
.toast-container {
  display: none !important;
}

/* ==========================================================================
   PDF Pages Viewer (Отображение PDF как фото)
   ========================================================================== */
.pdf-pages-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 16px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.pdf-page-canvas {
  max-width: 100%;
  height: auto !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  background: #ffffff;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastFadeIn 0.3s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  border-color: #22c55e;
  background: #14532d;
  color: #bbf7d0;
}

.toast.error {
  border-color: #ef4444;
  background: #7f1d1d;
  color: #fecaca;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-secondary);
}

.fab-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  border: none;
  font-size: 24px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.5);
  cursor: pointer;
  z-index: 40;
}

.tip-box {
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-top: 10px;
}

.tip-box a {
  color: #38bdf8;
}

.tip-box code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* ==========================================================================
   Flatpickr Dark Theme Customizations
   ========================================================================== */
.flatpickr-calendar {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6) !important;
  border-radius: 12px !important;
}

.flatpickr-day.selected {
  background: #2563eb !important;
  border-color: #2563eb !important;
}

.flatpickr-day:hover {
  background: #334155 !important;
}

/* ==========================================================================
   Mobile, Touch, Tablet & Landscape Responsive Styles
   - Covers mobile phones (portrait & landscape up to 1100px), 
     touch devices (hover: none, pointer: coarse), and short viewports (height <= 650px).
   - Entire top block (Header, Tabs, Controls-bar) scrolls vertically with the page,
     never getting stuck or taking up the whole screen.
   - Header, Tabs, Controls-bar, and Action-bar freely scroll horizontally on swipe/drag.
   ========================================================================== */
@media (max-width: 1100px), (max-height: 650px), (hover: none) and (pointer: coarse) {
  /* Шапка больше не прилипает намертво на мобильных/горизонтальных экранах, а свободно прокручивается со страницей вверх-вниз */
  .app-header {
    position: relative !important;
    top: auto !important;
  }

  /* Шапка: содержимое не обрезается, прокручивается горизонтально при нехватке ширины */
  .header-content {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
    gap: 12px;
  }
  .brand, .header-actions {
    flex-shrink: 0 !important;
  }

  /* Навигация табов свободно прокручивается горизонтально без переноса строк */
  .tabs-nav {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
  }
  .tab-btn {
    flex-shrink: 0 !important;
  }

  /* Панель фильтров даты и поиска (Controls bar) — горизонтальная прокрутка свайпом, ничего не обрезается */
  .controls-bar {
    display: flex !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
    touch-action: pan-x pan-y !important;
    gap: 12px !important;
    justify-content: flex-start !important;
  }
  .date-filter-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
    align-items: center !important;
  }
  .view-toggle-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
    align-items: center !important;
  }
  .search-box {
    flex-shrink: 0 !important;
    min-width: 180px !important;
    width: 220px !important;
  }
  .view-buttons {
    flex-shrink: 0 !important;
    display: flex !important;
  }

  /* Панель кнопок действий */
  .action-bar {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    justify-content: flex-start !important;
  }
  .action-bar-left {
    display: flex !important;
    flex-shrink: 0 !important;
    flex-wrap: nowrap !important;
  }
  .stats-summary {
    flex-shrink: 0 !important;
  }

  .fab-btn { display: flex; }
  .data-table th, .data-table td { padding: 10px 8px; font-size: 13px; }
  .hide-on-mobile { display: none !important; }

  /* Аккуратные полосы прокрутки для тач-скролла на смартфонах */
  .controls-bar::-webkit-scrollbar,
  .action-bar::-webkit-scrollbar,
  .tabs-nav::-webkit-scrollbar,
  .header-content::-webkit-scrollbar {
    height: 4px;
  }
  .controls-bar::-webkit-scrollbar-thumb,
  .action-bar::-webkit-scrollbar-thumb,
  .tabs-nav::-webkit-scrollbar-thumb,
  .header-content::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.4);
    border-radius: 4px;
  }
}

/* Настоящий десктоп: монитор от 1101px, высота более 650px и мышь */
@media (min-width: 1101px) and (min-height: 651px) and (hover: hover) {
  .app-header {
    position: sticky;
    top: 0;
  }
  .data-table { font-size: 14px; width: 100%; }
  .data-table th, .data-table td { padding: 14px 16px; }
  .table-responsive { overflow-x: auto; }
}

/* ==============================================================================
   РАЗДЕЛЕНИЕ МАРШРУТНОГО ЛИСТА: ЗАБОР ТОВАРА И ДОСТАВКА
   ============================================================================== */
.route-tables-container {
  width: 100%;
}

.route-section-block {
  margin-bottom: 24px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Обертка для плавного свайпа/протаскивания таблиц влево и вправо на мобильных */
.route-table-scroll {
  width: 100%;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
  display: block;
  background: transparent;
  border-radius: 0 0 12px 12px;
}

#routesTable {
  min-width: 820px;
}

#deliveryRoutesTable {
  min-width: 960px;
}

.route-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-color);
}

.route-block-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.route-block-title h2 {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  letter-spacing: -0.2px;
}

.route-block-icon {
  font-size: 20px;
  line-height: 1;
}

.route-block-badge {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.delivery-header {
  background: rgba(30, 27, 75, 0.45);
}

.delivery-header .route-block-badge {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.table-empty-row-hint {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  background: rgba(15, 23, 42, 0.2);
}

/* Статистика в шапке */
.stat-badge-pickup {
  color: #38bdf8;
  font-weight: 600;
}

.stat-badge-delivery {
  color: #fbbf24;
  font-weight: 600;
}

.stat-divider {
  color: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

/* Переключатель Забор / Доставка в модальном окне */
.route-type-toggle-bar {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.75);
  border-radius: 10px;
  margin: 4px 16px 16px 16px;
  border: 1px solid var(--border-color);
}

.route-type-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.route-type-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.route-type-tab-btn.active#typePickupTabBtn {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.route-type-tab-btn.active#typeDeliveryTabBtn {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
}

.route-type-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex: 1;
}

.route-type-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.route-type-pill {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.route-type-checkbox-label input[type="checkbox"]:checked + .route-type-pill {
  color: #38bdf8;
  font-weight: 700;
}

#typeDeliveryCheckboxLabel input[type="checkbox"]:checked + .route-type-pill {
  color: #fbbf24;
}

/* Чипы поставщиков для доставки */
.delivery-suppliers-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
  align-items: center;
}

.supplier-chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.supplier-chip-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.65;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.supplier-chip-remove:hover {
  opacity: 1;
  color: #ef4444;
}

/* Колонки в доставке */
.delivery-suppliers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.delivery-supplier-item {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  font-size: 12px;
  color: #e2e8f0;
  border-left: 2px solid #38bdf8;
  word-break: break-word;
}

.table-recipient-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recipient-address {
  font-weight: 600;
  color: #f8fafc;
  word-break: break-word;
}

.recipient-client-name {
  font-size: 12px;
  color: #94a3b8;
}

.payment-cell-text {
  font-size: 13px;
  font-weight: 500;
  color: #fbbf24;
  word-break: break-word;
}

/* Телефон на десктопе: простой текст, без ссылок и звонков */
.phone-text-desktop {
  font-size: 13px;
  color: #e2e8f0;
  cursor: text;
  user-select: text;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.route-card .phone-text-desktop {
  font-size: 13px;
  color: #e2e8f0;
  cursor: text;
  user-select: text;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
}

/* Телефон на мобильной версии: активная кнопка в таблице */
.phone-btn-mobile {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
  border: 1px solid rgba(22, 163, 74, 0.4);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  width: fit-content;
  margin-top: 2px;
}

/* Кнопка звонка в карточках для смартфона водителя */
.route-card .phone-btn-mobile {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  width: fit-content;
  margin-top: 2px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.route-card .phone-btn-mobile:hover {
  background: rgba(34, 197, 94, 0.32);
  border-color: #22c55e;
  transform: translateY(-1px);
}

/* Десктопная версия: строго простой текст, кнопка вызова скрыта */
body.is-desktop-device .phone-btn-mobile {
  display: none !important;
}

body.is-desktop-device .phone-text-desktop {
  display: inline-flex !important;
}

/* Мобильная версия водителя: простой текст скрыт, активна кнопка вызова */
body.is-mobile-device .phone-text-desktop {
  display: none !important;
}

body.is-mobile-device .phone-btn-mobile {
  display: inline-flex !important;
}

@media (max-width: 1024px) and (pointer: coarse), (max-width: 850px) {
  body:not(.is-desktop-device) .phone-text-desktop {
    display: none !important;
  }
  body:not(.is-desktop-device) .phone-btn-mobile {
    display: inline-flex !important;
  }
}
  .route-type-toggle-bar {
    margin: 4px 10px 12px 10px;
    padding: 10px 12px;
  }
  .route-modal-grid {
    display: block;
  }
  .modal-dialog-lg {
    max-width: 100%;
  }
}

/* ==========================================================================
   АУТЕНТИФИКАЦИЯ (ЭКРАН ВХОДА)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.auth-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: authCardIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authCardIn {
  from {
    transform: translateY(18px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.auth-card-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-icon-badge {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px auto;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 16px -4px rgba(37, 99, 235, 0.45);
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-size: 13px;
  color: #94a3b8;
}

.auth-error-box {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.4;
  animation: shakeError 0.3s ease;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.75;
}

.auth-input {
  width: 100%;
  height: 46px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0 42px 0 42px;
  font-size: 15px;
  color: #f8fafc;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.auth-toggle-pwd-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: #94a3b8;
  transition: opacity 0.15s ease;
}

.auth-toggle-pwd-btn:hover {
  opacity: 1;
}

.auth-checkbox-group {
  margin-top: 4px;
  margin-bottom: 6px;
}

.auth-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}

.auth-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  cursor: pointer;
}

.auth-submit-btn {
  height: 48px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}

.auth-submit-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.auth-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.auth-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ==============================================================================
   РАЗГРАНИЧЕНИЕ ПРАВ: АДМИНИСТРАТОР vs ВОДИТЕЛЬ
   ============================================================================== */
body.is-driver-role .admin-only,
body.is-driver-role #deleteViewerInvoiceBtn,
body.is-driver-role .photo-viewer-header #deleteViewerInvoiceBtn,
body.is-driver-role .add-invoice-mini-btn,
body.is-driver-role .no-invoices-hint,
body.is-driver-role [data-action="quick-add-invoice"],
body.is-driver-role [data-action="remove-modal-invoice"],
body.is-driver-role .invoice-item-actions {
  display: none !important;
}

body.is-driver-role .driver-view-only {
  display: block !important;
}

/* Стили колонки даты в таблице */
.col-date {
  width: 130px;
  min-width: 130px;
  max-width: 145px;
  vertical-align: middle;
  white-space: nowrap;
}

.table-date-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 126px;
  min-width: 126px;
  max-width: 126px;
}

.table-date-input {
  width: 100%;
  height: 28px;
  padding: 2px 22px 2px 24px;
  background-color: rgba(15, 23, 42, 0.75);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3e%3c/rect%3e%3cline x1='16' y1='2' x2='16' y2='6'%3e%3c/line%3e%3cline x1='8' y1='2' x2='8' y2='6'%3e%3c/line%3e%3cline x1='3' y1='10' x2='21' y2='10'%3e%3c/line%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: left 6px center;
  background-size: 13px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.15px;
  color: #38bdf8;
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
  text-align: left;
}

.table-date-input:hover {
  border-color: #38bdf8;
  background-color: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.table-date-input:focus {
  border-color: #0284c7;
  background-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.table-date-input.is-empty {
  border-color: rgba(148, 163, 184, 0.25);
  color: #94a3b8;
  font-style: italic;
  font-weight: 500;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3e%3c/rect%3e%3cline x1='16' y1='2' x2='16' y2='6'%3e%3c/line%3e%3cline x1='8' y1='2' x2='8' y2='6'%3e%3c/line%3e%3cline x1='3' y1='10' x2='21' y2='10'%3e%3c/line%3e%3c/svg%3e");
}

.table-date-input.is-empty::placeholder {
  color: #94a3b8;
  font-style: italic;
  opacity: 0.9;
}

.table-date-clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  z-index: 2;
}

.table-date-clear-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

/* Стили колонки водителя в таблице */
.col-driver {
  color: #38bdf8;
  font-weight: 500;
  min-width: 130px;
  max-width: 175px;
  vertical-align: middle;
}

.table-driver-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-block;
  width: 100%;
  max-width: 165px;
  height: 28px;
  padding: 2px 24px 2px 8px;
  background-color: rgba(15, 23, 42, 0.75);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #38bdf8;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.table-driver-select:hover {
  border-color: #38bdf8;
  background-color: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.18);
}

.table-driver-select:focus {
  border-color: #0284c7;
  background-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.table-driver-select.is-unassigned {
  border-color: rgba(148, 163, 184, 0.22);
  color: #94a3b8;
  font-style: italic;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

.table-driver-select option {
  background-color: #0f172a;
  color: #f1f5f9;
  font-size: 13px;
  font-style: normal;
  padding: 6px;
}

.driver-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  font-size: 12px;
  color: #38bdf8;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-pill.unassigned {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  font-style: italic;
}

.default-driver-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 4px;
  font-size: 11px;
  color: #fbbf24;
  font-weight: 600;
}

/* Строки пар марка/номер в модалке водителя */
.vehicle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vehicle-row .vehicle-brand-input {
  flex: 1.2;
}

.vehicle-row .vehicle-number-input {
  flex: 1;
}

.vehicle-delete-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.vehicle-delete-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Список авто в таблице водителей */
.vehicles-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.vehicle-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.vehicle-tag strong {
  color: var(--text-primary);
  font-weight: 600;
}





/* ==========================================================================
   Табличная пагинация (Забор и Доставка)
   ========================================================================== */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-bottom: 20px;
  flex-wrap: wrap;
  font-size: 13px;
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 13px;
}

.pagination-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-page {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-page:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-light);
  background-color: var(--bg-card-hover);
}

.btn-page.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: default;
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-color);
}

.btn-page-dots {
  min-width: 24px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  user-select: none;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-size .size-label {
  color: var(--text-muted);
  font-size: 12px;
}

.pagination-size .size-buttons {
  display: flex;
  gap: 4px;
}

.btn-size {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-size:hover {
  border-color: var(--primary);
  color: var(--text-primary);
}

.btn-size.active {
  background-color: rgba(37, 99, 235, 0.2);
  border-color: var(--primary);
  color: #60a5fa;
  font-weight: 600;
}

.cards-pagination-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 25px;
}

.cards-pagination-container .pagination-bar {
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.card-pagination-bar {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pagination-info {
    text-align: center;
  }
  .pagination-controls {
    justify-content: center;
  }
  .pagination-size {
    justify-content: center;
  }
}
