/* ─── TOKENS ─────────────────────────────────────────── */
:root {
  --bg:      #0d0f18;
  --bg2:     #13162100;
  --surface: #161b2a;
  --surface2:#1d2338;
  --border:  rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --text:    #dde1f0;
  --text2:   #7e86a8;
  --text3:   #464d6a;
  --accent:  #00d4aa;
  --accent2: #00b894;
  --danger:  #ff4f72;
  --warn:    #ffb347;
  --info:    #5b9cf6;
  --r:   8px;
  --r2: 12px;
  --r3: 16px;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ─── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ─── NAVBAR ─────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}
.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}
.brand-name em { color: var(--accent); font-style: normal; }

.nav-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}
.nav-tab {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: var(--r);
  transition: background 0.15s, color 0.15s;
}
.nav-tab:hover { background: var(--surface2); color: var(--text); }
.nav-tab.active { background: var(--surface2); color: var(--accent); }

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 2.4s ease-in-out infinite;
}
.status-dot.busy  { background: var(--warn); animation: none; }
.status-dot.error { background: var(--danger); animation: none; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ─── VIEWS ──────────────────────────────────────────── */
main { max-width: 1180px; margin: 0 auto; padding: 36px 28px 80px; }
.view { display: none; }
.view.active { display: block; }

.view-header { margin-bottom: 28px; }
.view-header h1 {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.4px; margin-bottom: 5px;
}
.subtitle { color: var(--text2); font-size: 14px; }

/* ─── DROP ZONE ──────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--r3);
  padding: 40px 32px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.18s, background 0.18s;
  user-select: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0,212,170,0.04);
}
.drop-zone.small { padding: 22px 16px; }
.drop-zone p { pointer-events: none; }

.drop-icon { margin-bottom: 14px; display: flex; justify-content: center; }
.drop-text { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.drop-hint { font-size: 12px; color: var(--text3); }

.link-btn {
  background: none; border: none;
  color: var(--accent); font-size: 15px;
  text-decoration: underline; cursor: pointer;
  padding: 0;
  pointer-events: all;
}

/* ─── FILE LIST ──────────────────────────────────────── */
#file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  animation: slide-in 0.18s ease;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.file-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.badge-xlsx, .badge-xls { background: rgba(0,212,170,0.14); color: var(--accent); }
.badge-csv  { background: rgba(91,156,246,0.14); color: var(--info); }
.badge-pdf  { background: rgba(255,79,114,0.14); color: var(--danger); }

.file-name { flex: 1; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-family: var(--mono); font-size: 11px; color: var(--text3); flex-shrink: 0; }
.file-status {
  font-size: 11px; font-family: var(--mono);
  padding: 2px 8px; border-radius: 4px;
  flex-shrink: 0;
}
.file-status.loading { background: rgba(255,179,71,0.14); color: var(--warn); }
.file-status.ready   { background: rgba(0,212,170,0.12); color: var(--accent); }
.file-status.error   { background: rgba(255,79,114,0.14); color: var(--danger); }
.file-remove {
  background: none; border: none;
  color: var(--text3); font-size: 18px; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
  transition: color 0.14s;
}
.file-remove:hover { color: var(--danger); }

/* ─── ACTION BAR ─────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.action-left { display: flex; gap: 10px; }
.compare-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-left: auto;
}
.opt-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.opt-label input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ─── BUTTONS ────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #0d0f18;
  border: none; font-size: 14px; font-weight: 700;
  padding: 9px 20px; border-radius: var(--r);
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary.full-width { width: 100%; }

.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border2);
  font-size: 14px; font-weight: 500;
  padding: 8px 18px; border-radius: var(--r);
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent; border: none;
  color: var(--text2); font-size: 14px;
  padding: 9px 14px; border-radius: var(--r);
  transition: background 0.14s, color 0.14s;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ─── RESULTS ────────────────────────────────────────── */
.results-section { margin-top: 32px; animation: fade-in 0.25s ease; }
@keyframes fade-in { from{opacity:0} to{opacity:1} }

.section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h2 { font-size: 17px; font-weight: 700; }
.header-actions { display: flex; gap: 10px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 15px 18px;
  transition: border-color 0.14s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-label {
  font-size: 11px; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 8px;
}
.stat-value { font-family: var(--mono); font-size: 30px; font-weight: 700; }
.stat-value.c-danger  { color: var(--danger); }
.stat-value.c-warn    { color: var(--warn); }
.stat-value.c-info    { color: var(--info); }
.stat-value.c-accent  { color: var(--accent); }

/* Filter pills */
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill {
  padding: 5px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.14s;
}
.pill-all      { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.pill-all.on   { border-color: var(--text2); }
.pill-dup      { background: rgba(255,79,114,0.1); color: var(--danger); }
.pill-dup.on   { border-color: var(--danger); }
.pill-price    { background: rgba(255,179,71,0.1); color: var(--warn); }
.pill-price.on { border-color: var(--warn); }
.pill-desc     { background: rgba(91,156,246,0.1); color: var(--info); }
.pill-desc.on  { border-color: var(--info); }
.pill-miss     { background: rgba(126,134,168,0.1); color: var(--text2); }
.pill-miss.on  { border-color: var(--text2); }

/* Issues table */
.issues-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  overflow-x: auto;
}
table.issues-tbl {
  width: 100%; border-collapse: collapse;
  font-size: 13px; min-width: 640px;
}
table.issues-tbl th {
  background: var(--surface2); color: var(--text3);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.7px;
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.issues-tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-family: var(--mono); font-size: 12px;
}
table.issues-tbl tbody tr:last-child td { border-bottom: none; }
table.issues-tbl tbody tr:hover td { background: rgba(255,255,255,0.02); }

.sev {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase;
}
.sev-critical { background: rgba(255,79,114,0.18); color: var(--danger); }
.sev-warn     { background: rgba(255,179,71,0.18); color: var(--warn); }
.sev-info     { background: rgba(91,156,246,0.18); color: var(--info); }

.source-chip {
  display: inline-block; padding: 2px 7px;
  background: var(--surface2); border-radius: 4px;
  font-size: 11px; color: var(--text2); margin: 2px 2px 2px 0;
}

/* ─── PDF LAYOUT ─────────────────────────────────────── */
.pdf-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  margin-bottom: 28px;
}
.pdf-sidebar { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
}
.panel-head {
  padding: 11px 16px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.pdf-preview-panel { min-height: 440px; }

.config-body {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--text2); }
.field-hint  { font-size: 11px; color: var(--text3); }
.field-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text);
  font-size: 12px; padding: 8px 10px;
  transition: border-color 0.14s;
  width: 100%;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.field-input.mono { font-family: var(--mono); }

.pdf-file-info { padding: 10px 14px; border-top: 1px solid var(--border); }

.pdf-preview {
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; max-height: 540px;
}
.pdf-page-canvas {
  width: 100%; border-radius: var(--r);
  border: 1px solid var(--border);
  display: block;
}
.pdf-page-label {
  font-size: 11px; color: var(--text3);
  font-family: var(--mono); text-align: center;
  margin-bottom: 4px;
}

/* ─── CARDS GRID ─────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
  animation: fade-in 0.2s ease;
}
.article-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.article-card.selected { border-color: var(--accent); }

.card-img {
  width: 100%; height: 130px;
  object-fit: contain;
  background: var(--surface2); padding: 10px;
  display: block;
}
.card-img-placeholder {
  width: 100%; height: 130px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.card-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.card-code  { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 600; }
.card-desc  {
  font-size: 13px; font-weight: 500; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.card-price { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--accent); margin-top: 4px; }
.card-price.nd { color: var(--text3); font-size: 12px; }
.card-actions { display: flex; gap: 6px; margin-top: 10px; }
.card-actions .btn-outline,
.card-actions .btn-primary { padding: 6px 0; flex: 1; font-size: 12px; text-align: center; }

/* ─── CATALOG TOOLBAR ────────────────────────────────── */
.catalog-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.search-box {
  flex: 1; position: relative;
}
.search-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--text3);
  pointer-events: none;
}
#catalog-search {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); font-size: 14px;
  padding: 10px 14px 10px 34px;
  transition: border-color 0.14s;
}
#catalog-search:focus { outline: none; border-color: var(--accent); }
.toolbar-actions { display: flex; gap: 10px; flex-shrink: 0; }

.badge {
  display: inline-block;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  margin-left: 5px; vertical-align: middle;
}

/* ─── QUOTE DRAWER ───────────────────────────────────── */
.quote-drawer {
  position: fixed;
  right: 0; top: 58px; bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border2);
  display: flex; flex-direction: column;
  z-index: 150;
  box-shadow: -12px 0 40px rgba(0,0,0,0.35);
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { font-size: 14px; font-weight: 700; }
.drawer-meta  { display: flex; gap: 8px; flex: 1; }
.meta-input {
  flex: 1; background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text);
  font-size: 12px; padding: 5px 9px;
}
.meta-input:focus { outline: none; border-color: var(--accent); }
.drawer-close {
  background: none; border: none;
  color: var(--text3); font-size: 15px;
  padding: 4px 6px; border-radius: 4px;
  transition: color 0.14s; flex-shrink: 0;
}
.drawer-close:hover { color: var(--danger); }

.quote-items { flex: 1; overflow-y: auto; padding: 10px 14px; }
.drawer-empty { font-size: 13px; color: var(--text3); text-align: center; padding: 24px; }

.quote-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.qi-thumb {
  width: 42px; height: 42px; object-fit: cover; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border); flex-shrink: 0;
}
.qi-thumb-placeholder { background: linear-gradient(135deg, var(--surface2), rgba(255,255,255,0.02)); }
.quote-item:last-child { border-bottom: none; }
.qi-code  { font-family: var(--mono); font-size: 11px; color: var(--accent); width: 80px; flex-shrink: 0; }
.qi-desc  { flex: 1; font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-qty input {
  width: 46px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-family: var(--mono); font-size: 12px;
  padding: 4px 6px; text-align: center;
}
.qi-qty input:focus { outline: none; border-color: var(--accent); }
.qi-price { font-family: var(--mono); font-size: 13px; font-weight: 600; width: 72px; text-align: right; color: var(--text); }
.qi-del {
  background: none; border: none;
  color: var(--text3); font-size: 16px;
  padding: 2px 4px; transition: color 0.14s;
}
.qi-del:hover { color: var(--danger); }

.drawer-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.totals { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.total-row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text2);
}
.total-row strong { font-family: var(--mono); color: var(--text); }
.total-grand { font-size: 15px; color: var(--text); }
.total-grand strong { color: var(--accent); font-size: 16px; }
.drawer-actions { display: flex; gap: 8px; }
.drawer-actions .btn-outline,
.drawer-actions .btn-primary { flex: 1; }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 56px 20px;
  color: var(--text3); text-align: center;
}
.empty-state p { font-size: 14px; }
.empty-state .hint { font-size: 12px; }

/* ─── PROGRESS ───────────────────────────────────────── */
.progress-wrap { margin-top: 8px; height: 3px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }

/* ─── TOAST ──────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r2); padding: 11px 20px;
  font-size: 13px; z-index: 500; opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none; max-width: 380px; text-align: center;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error   { border-color: var(--danger); color: var(--danger); }
.toast.warn    { border-color: var(--warn);   color: var(--warn); }

/* ─── SCROLLBAR ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 780px) {
  main { padding: 20px 14px 80px; }
  .pdf-layout { grid-template-columns: 1fr; }
  .quote-drawer { width: 100%; right: 0; }
  .compare-opts { display: none; }
}

/* ─── PRINT ──────────────────────────────────────────── */
@media print {
  .navbar, .action-bar, .header-actions, .catalog-toolbar,
  .quote-drawer, .card-actions, .filter-pills { display: none !important; }
  body { background: #fff; color: #000; }
  .stat-value { color: inherit !important; }
}
