/* ─────────────────────────────────────────────────────────────────────────
   LOGISTICS CRM — visual system, modern & lightweight
   Primary: #0046ad (corporate blue), Inter font, Material Symbols Outlined
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --primary: #0046ad;
  --primary-hover: #003785;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --surface: #ffffff;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 20px 60px rgba(15, 23, 42, 0.18);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text);
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at top right, rgba(0, 70, 173, 0.04), transparent 30%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  min-height: 100vh;
}

/* Material Symbols configuration */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  vertical-align: middle;
}

/* Sidebar nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 70, 173, 0.25);
}
.nav-item.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; }
.nav-item .material-symbols-outlined { font-size: 20px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .material-symbols-outlined { font-size: 20px; color: var(--primary); }
.card-body { padding: 16px 20px; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title .material-symbols-outlined { font-size: 26px; color: var(--primary); }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 70, 173, 0.25); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn .material-symbols-outlined { font-size: 18px; }

/* Inputs */
.input {
  width: 100%;
  /* Паддинг/радиус/кегль — медиана Attio (10/13, r10, 16px), Linear (12/14, r6,
     13.3px) и Flexport (14/18, r4, 16px). Разбор — design-research.md. */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:hover:not(:disabled):not(:focus) { border-color: var(--text-soft); }
.input:focus {
  border-color: var(--primary);
  /* Было захардкожено синим: в зелёной и оранжевой темах поле в фокусе
     светилось чужим цветом. */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.input::placeholder { color: var(--text-soft); }
.input-sm { padding: 6px 10px; font-size: 12px; }
.input-search { padding-left: 36px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}
.table th:hover { background: #f1f5f9; }
.table th.dragging { opacity: 0.4; }
.table th.drag-over { border-left: 3px solid var(--primary); }
.table th .th-content { display: inline-flex; align-items: center; gap: 4px; }
.table th .sort-icon { font-size: 14px; color: var(--text-soft); transition: color var(--transition); }
.table th.sort-asc .sort-icon, .table th.sort-desc .sort-icon { color: var(--primary); }
.table th .drag-handle {
  cursor: grab;
  opacity: 0;
  margin-left: 4px;
  font-size: 16px;
  color: var(--text-soft);
  transition: opacity var(--transition);
}
.table th:hover .drag-handle { opacity: 1; }
.table th .col-menu-btn {
  cursor: pointer;
  opacity: 0;
  margin-left: 2px;
  font-size: 16px;
  color: var(--text-soft);
  border-radius: 4px;
  padding: 0 2px;
  transition: opacity var(--transition);
}
.table th:hover .col-menu-btn { opacity: 1; }
.table th .col-menu-btn:hover { background: var(--primary-soft); color: var(--primary); }
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table tr:hover td { background: #f9fafb; }
.table tr.selected td { background: var(--primary-soft); }
.table tr.row-link { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-col { text-align: right; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: 12px; }

/* Column filter popover */
.col-filter-pop {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  min-width: 220px;
  z-index: 50;
  margin-top: 4px;
}
.col-filter-pop .filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.col-filter-pop .filter-row select,
.col-filter-pop .filter-row input {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
.col-filter-pop .filter-row select:focus,
.col-filter-pop .filter-row input:focus { border-color: var(--primary); }
.col-filter-pop .filter-actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 4px; }

/* Column chooser popover */
.col-chooser {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 240px;
  z-index: 50;
  margin-top: 4px;
  max-height: 400px;
  overflow-y: auto;
}
.col-chooser .col-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.col-chooser .col-item:hover { background: var(--primary-soft); }
.col-chooser .col-item input { margin: 0; accent-color: var(--primary); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-gray    { background: #f1f5f9; color: var(--text-muted); }
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon .material-symbols-outlined { font-size: 24px; }
.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 4px;
}
.kpi-blue   .kpi-icon { background: #dbeafe; color: #1d4ed8; }
.kpi-rose   .kpi-icon { background: #fee2e2; color: #b91c1c; }
.kpi-amber  .kpi-icon { background: #fef3c7; color: #b45309; }
.kpi-emerald .kpi-icon { background: #d1fae5; color: #047857; }
.kpi-slate  .kpi-icon { background: #e2e8f0; color: #475569; }
.kpi-violet .kpi-icon { background: #ede9fe; color: #6d28d9; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.toolbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* Toast notifications */
.toast {
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-error   .toast-icon { color: var(--danger); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.toast-msg { font-size: 12px; color: var(--text-muted); word-wrap: break-word; }
.toast-close { color: var(--text-soft); cursor: pointer; padding: 2px; }
.toast-close:hover { color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.fade-out { animation: toastOut 0.2s forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* Modals */
.modal-backdrop { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Form layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row.required .form-label::after { content: ' *'; color: var(--danger); }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 2px;
}
.form-help { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 70, 173, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-soft);
}
.empty-state .material-symbols-outlined { font-size: 48px; color: #cbd5e1; }
.empty-state p { margin-top: 8px; font-size: 14px; }

/* Status indicator (online/offline) */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-online { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); animation: pulse 1.5s ease-in-out infinite; }
.status-offline { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Live update pulse for new data */
@keyframes flashNew {
  0% { background: rgba(16, 185, 129, 0.2); }
  100% { background: transparent; }
}
.row-new { animation: flashNew 1.5s ease-out; }

/* Drag indicator */
.dragging-row { opacity: 0.5; }
.drop-target-top { box-shadow: inset 0 2px 0 var(--primary); }
.drop-target-bottom { box-shadow: inset 0 -2px 0 var(--primary); }

/* Sticky table header */
.table thead.sticky th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}

/* Multi-select dropdown */
.multi-select {
  position: relative;
  display: inline-block;
}
.multi-select-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 4px;
}

/* Section */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* Chart container */
.chart-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 200px;
}

/* SLA indicator */
.sla-overdue { background: #fee2e2 !important; color: #b91c1c; font-weight: 700; }
.sla-soon { background: #fef3c7 !important; color: #b45309; }
.sla-ok { color: var(--success); }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  border-radius: 6px;
  height: 16px;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Print: hide nav, show content */
@media print {
  #sidebar, header, .toolbar, .page-actions, .actions-col { display: none !important; }
  main { background: #fff !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Mobile responsive table */
@media (max-width: 768px) {
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 10px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 18px; }
}

/* Connection status (top right) */
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.connection-pill.online { background: #dcfce7; color: #166534; }
.connection-pill.offline { background: #fee2e2; color: #991b1b; }
.connection-pill.syncing { background: #dbeafe; color: #1e40af; }

/* Hover lift utility */
.hover-lift {
  transition: transform var(--transition), box-shadow var(--transition);
}
.hover-lift:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Detail view grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
}
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.detail-field-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.detail-field-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}
.detail-field-value.empty { color: var(--text-soft); font-style: italic; font-weight: 400; }

/* Reference picker */
.ref-picker {
  position: relative;
}
.ref-picker-input {
  width: 100%;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.ref-picker-clear {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-soft);
  display: none;
  font-size: 18px;
  line-height: 1;
}
.ref-picker.has-value .ref-picker-clear { display: block; }
.ref-picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}
.ref-picker-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f8fafc;
}
.ref-picker-item:hover { background: var(--primary-soft); color: var(--primary); }
.ref-picker-item:last-child { border-bottom: none; }

/* Status colors for documents (Отгрузка) */
.status-Черновик     { background: #f1f5f9; color: #475569; }
.status-ВРаботе      { background: #dbeafe; color: #1d4ed8; }
.status-ОжидаетОплаты{ background: #fef3c7; color: #b45309; }
.status-ВПути        { background: #ddd6fe; color: #6d28d9; }
.status-Таможня      { background: #fce7f3; color: #be185d; }
.status-Прибыл       { background: #d1fae5; color: #047857; }
.status-Завершён     { background: #dcfce7; color: #15803d; }
.status-Отменён      { background: #fee2e2; color: #b91c1c; }

/* ─────────────────────────────────────────────────────────────────────────
   MOTION & POLISH LAYER
   Чистая «плавность»: переходы страниц, микро-анимации, плавный скролл,
   тонкий скроллбар, GPU-хинты. Дизайн (цвета/отступы/типографика) не
   меняется — слой влияет только на движение.
   ───────────────────────────────────────────────────────────────────────── */

/* Плавный скролл по всему документу (anchor/scrollIntoView) */
html { scroll-behavior: smooth; }

/* Глобальная переменная-curve для всего motion-слоя */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);  /* быстрый старт, мягкий финиш */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --motion-fast: 160ms;
  --motion-base: 240ms;
}

/* Тонкий, ненавязчивый скроллбар (Chrome/Edge/Safari) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  transition: background var(--motion-base) var(--ease-out);
}
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: padding-box; }
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* Главная область — инерционный скролл на тач-устройствах */
main {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Crossfade страниц при навигации.
   .page-enter ставит JS на новый узел content-inner после очистки. */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.992); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#content-inner.page-enter {
  /* Чуть длиннее и с микро-масштабом — премиальное «эппловское» проявление вкладки */
  animation: pageEnter 360ms var(--ease-out) both;
  will-change: opacity, transform;
}
/* Сразу после анимации убираем will-change, чтобы не держать слой в GPU */
#content-inner.page-enter-done { will-change: auto; }

/* Командный центр: каскадное появление виджетов (fade + подъём + микро-масштаб).
   Задержку задаёт JS через --dw-i (порядковый номер видимого виджета). */
@keyframes dwEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.dash-widget.dw-enter {
  animation: dwEnter 520ms var(--ease-out) both;
  animation-delay: calc(var(--dw-i, 0) * 70ms);
  will-change: opacity, transform;
}
/* KPI-плитки (.g4 > .card) внутри виджета — лёгкий внутренний каскад поверх.
   Класс dw-enter снимается JS после завершения, поэтому hover-lift плиток
   (transform) не конфликтует с animation-fill. */
@keyframes kpiEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dash-widget.dw-enter .g4 > .card {
  animation: kpiEnter 440ms var(--ease-out) both;
}
.dash-widget.dw-enter .g4 > .card:nth-child(1) { animation-delay: 160ms; }
.dash-widget.dw-enter .g4 > .card:nth-child(2) { animation-delay: 215ms; }
.dash-widget.dw-enter .g4 > .card:nth-child(3) { animation-delay: 270ms; }
.dash-widget.dw-enter .g4 > .card:nth-child(4) { animation-delay: 325ms; }

/* View Transitions API (Chrome 111+, Safari 18+, Firefox 129+).
   Если браузер поддерживает — используем нативный crossfade страницы. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-base);
  animation-timing-function: var(--ease-out);
}

/* Sidebar nav — мягче подсветка активного пункта */
.nav-item {
  transition:
    background var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out);
}
.nav-item:active { transform: scale(0.98); }
.nav-item .material-symbols-outlined {
  transition: font-variation-settings var(--motion-base) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.nav-item:hover .material-symbols-outlined { transform: scale(1.06); }

/* Кнопки — лёгкий ripple-эффект через box-shadow + press */
.btn {
  transition:
    background var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out);
  will-change: transform;
}
.btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }

/* Карточки — мягкая «парящая» анимация при ховере */
.card, .kpi-card, .chart-wrap {
  transition:
    transform var(--motion-base) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out),
    border-color var(--motion-base) var(--ease-out);
}
.card:hover { box-shadow: var(--shadow); }

/* Таблица — fade-in каждой строки при первом рендере */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.table tbody tr {
  animation: rowFadeIn var(--motion-base) var(--ease-out) both;
  /* staggered delay по первым 20 строкам — дальше мгновенно */
  animation-delay: calc(var(--row-index, 0) * 14ms);
}
/* Если строк > 20, JS может выставлять --row-index=20 для остальных,
   но и без этого max-delay ограничен 14ms * 30 = 0.42s. */
.table tr:hover td {
  transition: background var(--motion-fast) var(--ease-out);
}

/* Поповеры/дропдауны — единый fade+scale из точки клика */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.col-filter-pop,
.col-chooser,
.multi-select-menu,
.ref-picker-dropdown,
#user-menu:not(.hidden),
#quick-search-results {
  animation: popIn var(--motion-fast) var(--ease-out) both;
  transform-origin: top right;
  will-change: opacity, transform;
}

/* Toast — мягче въезд (переопределяем встроенный) */
.toast {
  animation: toastIn var(--motion-base) var(--ease-out) both;
}

/* Модалки — overshoot убираем, оставляем мягкий ease-out */
.modal-card { animation: modalIn var(--motion-base) var(--ease-out) both; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-backdrop { animation: fadeIn var(--motion-fast) var(--ease-out) both; }

/* Sidebar mobile slide-in — убираем дёрганье */
#sidebar { transition: transform var(--motion-base) var(--ease-out); }

/* Badges — мягкая смена цвета при изменении статуса */
.badge { transition: background var(--motion-base) var(--ease-out), color var(--motion-base) var(--ease-out); }

/* Inputs — focus ring оживает плавно */
.input, .ref-picker-input, .col-filter-pop input, .col-filter-pop select {
  transition:
    border-color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out),
    background var(--motion-fast) var(--ease-out);
}

/* Спиннер — чуть мягче кривая */
.spinner { animation: spin 0.8s linear infinite; }

/* Ссылки/строки таблицы как кнопки — единый press-feedback */
.table tr.row-link { transition: background var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out); }
.table tr.row-link:active { transform: scale(0.998); }

/* content-visibility:auto на img УБРАН: браузер пропускал рендеринг картинки,
   и loading="lazy" из-за этого никогда не стартовал — аватары сотрудников
   и иконки ТГ в списках оставались пустыми (complete=false, currentSrc=""). */

/* Render-производительность: тяжёлые секции — изоляция layout/paint */
.card, .kpi-card, .chart-wrap, .toast, .modal-card { contain: layout paint; }

/* «Уменьшить движение» — теперь управляется приложением, а не напрямую ОС.
   ПРИЧИНА: WebView2 в desktop-клиенте (Wails) наследует системную настройку
   Windows «Показывать анимацию в Windows». На многих рабочих/RDP-машинах она
   выключена → браузер репортит prefers-reduced-motion: reduce → раньше это
   ПОЛНОСТЬЮ убивало анимации и плавный скролл именно в клиенте.
   Теперь kill-switch срабатывает только если на <html> явно стоит класс
   `reduce-motion` (его можно выставить настройкой/доступностью). По умолчанию —
   полноценная премиальная моушн-механика во всех окружениях. */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   TILE GRID (страница «Сервис», админ-главная)
   Современные карточки-плитки с тонкой границей, мягким hover-подъёмом
   и явной иконкой-чипом. Сетка адаптивна без media-queries (auto-fill).
   ───────────────────────────────────────────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 18px 0 10px;
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.tile-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition:
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out);
  will-change: transform;
}
.tile-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-border);
}
.tile-card:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tile-icon .material-symbols-outlined { font-size: 24px; }

/* Skeleton-loader для таблиц и виджетов */
@keyframes skeletonPulse {
  0%   { background-color: #e2e8f0; }
  50%  { background-color: #f1f5f9; }
  100% { background-color: #e2e8f0; }
}
.skeleton {
  background-color: #e2e8f0;
  border-radius: 6px;
  animation: skeletonPulse 1.4s ease-in-out infinite;
  display: inline-block;
}
.skeleton-line { height: 12px; width: 100%; margin: 4px 0; }
.skeleton-line.short { width: 60%; }

/* Loader (inline spinner) — для кнопок и подгрузки */
.loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Бейджи — расширение существующих под админку */
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-rose { background: #fee2e2; color: #b91c1c; }
.badge-success { background: #d1fae5; color: #047857; }

/* Доводка модалок — мягче backdrop + clamp по высоте на mobile */
#modal-container {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#modal-card {
  animation: modalIn var(--motion-base) var(--ease-out) both;
}

/* «Пустое состояние» — единый паттерн */
.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-soft);
}
.empty-state .material-symbols-outlined {
  font-size: 48px;
  display: block;
  margin: 0 auto 12px;
  color: #cbd5e1;
}
.empty-state .empty-title { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.empty-state .empty-hint  { font-size: 12px; margin-top: 4px; }

/* Section-headers внутри карточек */
.card-section {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Реестр отгрузок: плотность строк + закрепление 1-й колонки ──────────── */
.registry-card.density-transitioning .table th,
.registry-card.density-transitioning .table td { transition: padding var(--transition); }
.registry-card.density-compact .table th,
.registry-card.density-compact .table td {
  padding: 5px 10px;
  font-size: 12px;
}
/* Закрепляем колонку «Номер заявки» (2-я th/td — после чекбокса) при гориз. скролле. */
.registry-card .table thead.sticky th:nth-child(2),
.registry-card .table tbody td:nth-child(2) {
  position: sticky;
  left: 36px;   /* ширина col1 (чекбокс) из colgroup — иначе «Номер» наезжает на чекбокс при гориз. скролле */
  z-index: 4;
  background: #fff;
  box-shadow: 1px 0 0 var(--border);
}
.registry-card .table thead.sticky th:nth-child(2) { z-index: 6; background: var(--bg); }
.registry-card .table tr:hover td:nth-child(2) { background: #f9fafb; }
.registry-card .table tr.selected td:nth-child(2) { background: var(--primary-soft); }

/* ════════════════════════════════════════════════════════════════════════
   Реестр отгрузок 2.0 — аддитивные стили (2026-06).
   Все классы со скоупом .registry-* / .rv-* и опции таблицы (sticky-first,
   group-row, table-totals). Не затрагивают остальные страницы.
   ════════════════════════════════════════════════════════════════════════ */

/* — Сохранённые виды (чипы) — */
.rv-views { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.rv-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 600; line-height: 1;
  color: var(--text-muted); background: var(--surface);
  border: 1px solid var(--border); transition: all var(--transition);
  white-space: nowrap;
}
.rv-chip:hover { border-color: var(--primary-border); color: var(--primary); background: var(--primary-soft); }
.rv-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(0,70,173,0.22); }
.rv-chip .rv-count {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); min-width: 18px; text-align: center;
}
.rv-chip.active .rv-count { background: rgba(255,255,255,0.25); color: #fff; }
.rv-chip.rv-alert .rv-count { background: #fee2e2; color: #b91c1c; }
.rv-chip.active.rv-alert .rv-count { background: rgba(255,255,255,0.3); color: #fff; }

/* — KPI-полоска реестра (использует .kpi-card из app.css, чуть плотнее) — */
.registry-kpis { margin-bottom: 14px; }
.registry-kpis .kpi-card { padding: 14px 16px; cursor: default; }
.registry-kpis .kpi-value { font-size: 22px; }

/* — Bulk-тулбар (появляется при выделении строк) — */
.rv-bulkbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 10px 16px; border-radius: var(--radius, 12px);
  background: var(--primary-soft); border: 1px solid var(--primary-border);
  animation: rv-slidein var(--motion-base, .18s) var(--ease-out, ease);
}
@keyframes rv-slidein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.rv-bulkbar .rv-bulk-count { font-weight: 700; color: var(--primary); display: inline-flex; align-items: center; gap: 6px; }
.rv-bulkbar .rv-bulk-sum { font-size: 13px; color: var(--text-muted); }
.rv-bulkbar .rv-bulk-sum b { color: var(--text); }
.rv-bulkbar .rv-bulk-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

/* — Этап-пилюля (производная колонка) — */
.stage-pill { font-weight: 600; }

/* — ETA-дельта — */
.eta-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.eta-ok    { background: #f1f5f9; color: #475569; }
.eta-soon  { background: #fef3c7; color: #b45309; }
.eta-late  { background: #fee2e2; color: #b91c1c; }
.eta-fact  { background: #d1fae5; color: #047857; }

/* — Подсветка строк по SLA — */
.table tr.row-sla > td { background: #fff7f7 !important; }
.table tr.row-sla:hover > td { background: #ffeef0 !important; }
.table tr.row-sla > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* — Залипающая первая колонка (выбор + НомерЗаявки) — */
.table.sticky-first th:nth-child(1), .table.sticky-first td:nth-child(1) {
  position: sticky; left: 0; z-index: 3; background: var(--surface);
}
.table.sticky-first th:nth-child(2), .table.sticky-first td:nth-child(2) {
  position: sticky; left: 44px; z-index: 3; background: var(--surface);
  box-shadow: inset -1px 0 0 var(--border);
}
.table.sticky-first thead th:nth-child(1), .table.sticky-first thead th:nth-child(2) { z-index: 5; }
.table.sticky-first th:first-child { width: 44px; min-width: 44px; }
/* зебра/выделение/наведение для залипающих ячеек должны оставаться непрозрачными */
.table.sticky-first tbody tr:hover td:nth-child(1),
.table.sticky-first tbody tr:hover td:nth-child(2) { background: var(--surface-2); }
.table.sticky-first tbody tr.selected td:nth-child(1),
.table.sticky-first tbody tr.selected td:nth-child(2) { background: var(--primary-soft); }
.table.sticky-first tbody tr.row-sla td:nth-child(1),
.table.sticky-first tbody tr.row-sla td:nth-child(2) { background: #fff7f7; }

/* — Строка-группировка колонок — */
.table thead tr.group-row th.group-cell {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); background: var(--surface-2);
  text-align: center; padding: 4px 8px; border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.table thead tr.group-row th.group-empty { background: var(--surface); border-left: none; }
.table thead tr.group-row th.group-cell-sel { background: var(--surface); border-left: none; }
.table.sticky-first thead tr.group-row th:nth-child(1),
.table.sticky-first thead tr.group-row th:nth-child(2) { position: sticky; z-index: 6; }

/* — Подвал с итогами — */
.table tfoot.table-totals td {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--surface-2); border-top: 2px solid var(--border);
  font-size: 13px; padding: 8px 12px; color: var(--text);
}
.table tfoot.table-totals td.tot-label { font-weight: 700; color: var(--text-muted); }
.table.sticky-first tfoot.table-totals td:nth-child(1),
.table.sticky-first tfoot.table-totals td:nth-child(2) { z-index: 4; background: var(--surface-2); }
