:root {
  --bg-base:       #0d0f14;
  --bg-surface:    #13161e;
  --bg-card:       #181c27;
  --bg-card-hover: #1e2333;
  --bg-input:      #0f1219;
  --accent:        #4f8ef7;
  --accent-dim:    #2a4d9e;
  --accent-glow:   rgba(79,142,247,0.18);
  --success:       #34c97a;
  --warning:       #f5a623;
  --danger:        #e85555;
  --text-primary:  #e8eaf0;
  --text-secondary:#8a90a4;
  --text-muted:    #4a5068;
  --border:        rgba(255,255,255,0.07);
  --border-accent: rgba(79,142,247,0.35);
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,0.45);
  --font:          'Inter', system-ui, sans-serif;
  --mono:          'JetBrains Mono', 'Fira Code', monospace;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.wrapper {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

main {
  padding: 40px 0 80px;
}

/* ── Header ── */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.site-header .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.header-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Footer ── */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
}

.site-footer .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Page title ── */
.page-title {
  margin-bottom: 32px;
}

.page-title h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-title p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ── Grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  align-items: start;
}
/* Дополнительные функции */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all .2s;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(79,142,247,.05);
}
.btn-ghost:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,142,247,0.04);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
  opacity: 1;
}

.drop-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  background: var(--bg-input);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 1px solid var(--border);
  transition: transform 0.2s, border-color 0.2s;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  transform: scale(1.08) translateY(-2px);
  border-color: var(--accent-dim);
}

.drop-zone h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.drop-zone p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── File preview ── */
.file-preview {
  margin-top: 18px;
  display: none;
  background: var(--bg-input);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  gap: 12px;
  align-items: center;
  animation: fadeIn 0.25s ease;
}

.file-preview.show { display: flex; }

.file-preview-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.file-preview-info { flex: 1; min-width: 0; }
.file-preview-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.file-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.file-preview-remove:hover { color: var(--danger); background: rgba(232,85,85,0.1); }

/* ── Submit button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%);
  pointer-events: none;
}

.btn-primary:hover { background: #6da0fa; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,142,247,0.35); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--border-accent); color: var(--accent); background: var(--accent-glow); }

/* ── Progress bar ── */
.progress-wrap {
  margin-top: 14px;
  display: none;
}
.progress-wrap.show { display: block; }

.progress-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7ab4ff);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Status badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--mono);
}

.badge-pending  { background: rgba(245,166,35,0.12); color: var(--warning); }
.badge-done     { background: rgba(52,201,122,0.12); color: var(--success); }
.badge-error    { background: rgba(232,85,85,0.12);  color: var(--danger); }
.badge-new      { background: rgba(79,142,247,0.12); color: var(--accent); }

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── History table ── */
.history-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.history-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.history-table tr:last-child td { border-bottom: none; }

.history-table tr:hover td { background: rgba(255,255,255,0.02); }

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

.file-type-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.ftype-pdf { background: rgba(232,85,85,0.15); color: #e85555; }
.ftype-img { background: rgba(79,142,247,0.15); color: var(--accent); }

.file-name-text {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.85rem;
}

/* ── Alerts / flash ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.alert-success { background: rgba(52,201,122,0.1); border: 1px solid rgba(52,201,122,0.25); color: var(--success); }
.alert-error   { background: rgba(232,85,85,0.1);  border: 1px solid rgba(232,85,85,0.25);  color: var(--danger); }

/* ── Step indicator (for future pipeline stages) ── */
.steps {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  position: relative;
}

.step:last-child { border-right: none; }

.step.active {
  color: var(--accent);
  background: rgba(79,142,247,0.06);
}

.step.done { color: var(--success); }

.step-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: 6px;
  height: 14px;
}
/* Стили для select производителя */
.manufacturer-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: .8rem;
  padding: 4px 6px;
  width: 100%;
  cursor: pointer;
  appearance: auto;
}

.manufacturer-select:focus {
  outline: none;
  border-color: var(--accent);
}

.manufacturer-select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 4px 8px;
}

.manufacturer-select option:hover {
  background: var(--bg-card-hover);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.animate-in {
  animation: fadeIn 0.35s ease both;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Tooltip ── */
[data-tip] { position: relative; cursor: default; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2d3e;
  color: var(--text-primary);
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--border);
  z-index: 50;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── OCR Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.modal-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.modal-meta-item {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.modal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-search {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-primary);
  width: 200px;
  transition: border-color 0.15s;
}

.modal-search:focus {
  outline: none;
  border-color: var(--accent);
}

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

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

.ocr-text-wrap {
  padding: 20px 24px;
}

.ocr-text {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

.ocr-text mark {
  background: rgba(245,166,35,0.3);
  color: var(--warning);
  border-radius: 2px;
  padding: 0 1px;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.modal-footer-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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