:root{
  --bg:#0b1117;
  --panel:#0f1620;
  --panel-2:#111b27;
  --text:#e6edf3;
  --muted:#9fb1c1;
  --brand:#3b82f6;
  --brand-2:#2563eb;
  --ok:#22c55e;
  --warn:#f59e0b;
  --danger:#ef4444;
  --line:#1e293b;
  --chip:#182230;
  --shadow: 0 8px 24px rgba(2,6,23,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:linear-gradient(180deg,#0a0f14,#0b1117 40%,#0b1117);
  color:var(--text);
}
a{color:var(--brand); text-decoration:none}
a:hover{color:var(--brand-2)}
.hidden{display:none !important}

.app{min-height:100%; display:flex; flex-direction:column}

/* Topbar */
.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 20px; background:rgba(11,17,23,.7); backdrop-filter: blur(6px);
  border-bottom:1px solid var(--line);
}
.brand{display:flex; align-items:center; gap:10px}
.logo-dot{width:10px; height:10px; border-radius:50%; background:linear-gradient(135deg,#60a5fa,#22d3ee)}
.brand-title{font-weight:700; letter-spacing:.3px}

.topbar-actions{display:flex; align-items:center; gap:10px}
.link{color:var(--muted)}
.link:hover{color:var(--text)}
.divider{opacity:.35}

.btn{
  appearance:none; border:none; background:linear-gradient(180deg,#3b82f6,#2563eb);
  color:#fff; padding:10px 14px; border-radius:10px; font-weight:600; cursor:pointer;
  box-shadow:var(--shadow); transition: transform .06s ease, filter .15s;
}
.btn:hover{filter:brightness(1.08)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.5; cursor:not-allowed}
.btn-ghost{
  background:transparent; color:var(--text); border:1px solid var(--line);
  padding:8px 12px; border-radius:10px;
}

/* Опасная кнопка (удаления и т.п.) */
.btn-danger{
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover,
.btn-danger:focus-visible{
  background: rgba(239, 68, 68, 0.08); /* лёгкая красная подложка */
}

.main{width:100%; max-width:1100px; margin:24px auto; padding:0 16px; flex:1}

.card{
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  border:1px solid var(--line); border-radius:14px; padding:18px 18px 20px;
  box-shadow:var(--shadow);
}
.card-emphasis{border-color:#22406b}
.card-danger{border-color:#522; background:linear-gradient(180deg,#1a0e0e,#170e0e)}
.card-header{margin-bottom:12px}
.card-title{margin:0; font-size:18px; font-weight:700}
.card-subtitle{margin:6px 0 0; color:var(--muted); font-size:14px}

.grid{display:grid; gap:16px}
.grid-2{grid-template-columns:repeat(2, minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3, minmax(0,1fr))}
.full{grid-column:1 / -1}

.form-row{display:flex; flex-direction:column; gap:6px}
.label{font-weight:600}
.input, select{
  background:#0b1522; color:var(--text);
  border:1px solid var(--line); border-radius:10px; padding:10px 12px;
}
.help{color:var(--muted); font-size:12px}

.client-select-row{
  display:flex;
  flex-direction:row;
  gap:8px;
}

.client-code-input{
  max-width:90px;
  padding-inline:10px;
}

.file{
  display:flex; align-items:center; gap:10px; border:1px dashed #2a3b53;
  padding:10px 12px; border-radius:10px; background:#0b1522;
}
.file input[type=file]{display:none}
.file-cta{
  display:inline-flex; align-items:center; gap:8px; padding:8px 10px;
  background:#162334; border:1px solid #223243; border-radius:8px;
  cursor: pointer;
}
.file-name{color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}

.segmented{display:inline-flex; gap:8px}
.segmented-item{
  display:flex; align-items:center; gap:8px; padding:8px 12px; border:1px solid var(--line);
  border-radius:999px; background:#0c1522
}
.segmented-item input{accent-color:#3b82f6}

.manual{
  padding:12px; border:1px dashed #334; border-radius:12px; background:#0b1522;
}

.form-actions{display:flex; align-items:center; gap:14px}

.loader{display:flex; align-items:center; gap:10px; color:var(--muted)}
.spinner{
  display:inline-block;              /* 🔑 стало блочным элементом */
  width:16px;
  height:16px;
  border-radius:50%;
  border:2px solid #27415f;
  border-top-color:#4ea3ff;
  animation:spin 0.8s linear infinite;
}

/* опционально, чтобы чуть отступал от текста кнопки */
.spinner-inline{
  margin-left:6px;
}

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

/* Summary chips */
.summary{margin-top:6px}
.summary .chip{
  background:var(--chip); border:1px solid var(--line); padding:10px 12px; border-radius:12px;
}
.chip .h{display:block; font-size:13px; color:var(--muted)}
.chip .v{display:block; font-weight:700; margin-top:4px}

/* Table */
.table-wrap{
  margin-top:12px; overflow:auto; border:1px solid var(--line); border-radius:12px;
}
table{width:100%; border-collapse:separate; border-spacing:0}
thead th{
  position:sticky; top:0; z-index:1;
  background:#0f1723; color:#c7d6e5; text-align:left; font-weight:700; padding:12px;
  border-bottom:1px solid var(--line);
}
tbody td{
  padding:10px 12px; border-bottom:1px solid #142033; color:#dbe7f3;
}
tbody tr:hover{background:#0f1725}
td .badge{display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px}
.badge-ok{background:rgba(34,197,94,.15); color:#34d399}
.badge-warn{background:rgba(245,158,11,.12); color:#fbbf24}
.badge-err{background:rgba(239,68,68,.12); color:#f87171}

/* Footer */
.footer{
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 20px; color:var(--muted); border-top:1px solid var(--line);
}

/* Responsive */
@media (max-width: 880px){
  .grid-2{grid-template-columns:1fr}
  .grid-3{grid-template-columns:1fr}
}
/* === имя выбранного файла рядом с input[type=file] === */
.file-name {
  display: inline-block;
  margin-left: 8px;
  font-size: 14px;
  color: var(--muted); /* было #555 — на тёмной теме бледно */
}

/* === TOASTS (уведомления) === */
#toastContainer {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  background: #333;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  min-width: 240px;
  max-width: 420px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(10px);
  animation: toastIn .22s ease-out forwards;
}
.toast.success { background: #2a7a2a; }
.toast.error   { background: #b02a2a; }
.toast.info    { background: #2a4a7a; }
.toast .title { font-weight: 700; margin-bottom: 2px; }
.toast .actions { margin-top: 8px; display: flex; gap: 8px; }
.toast .actions a, .toast .actions button {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.toast .actions a:hover, .toast .actions button:hover {
  background: rgba(255,255,255,.25);
}
@keyframes toastIn { to { opacity: 1; transform: translateY(0); } }

/* === ПРОГРЕСС-МОДАЛКА === */
.progress-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}
.progress-modal {
  background: #fff; padding: 18px 20px; border-radius: 10px; width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.progress-modal h4 { margin: 0 0 8px; font-size: 16px; }
.progress-bar {
  height: 8px; background: #eee; border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: #4CAF50;
  transition: width .2s ease;
}
.progress-note { font-size: 12px; color: #666; margin-top: 6px; }

.send-summary { margin-top: 16px; }
.send-summary .chip .v { font-size: 18px; }

/* === Drawer (правое выезжающее окно) === */
.drawer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; justify-content: flex-end; align-items: stretch;
  z-index: 9997;
}
.drawer-panel {
  width: min(900px, 92vw);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.drawer-body { padding: 12px 14px; overflow: auto; max-height: calc(100vh - 56px); }


/* контейнер секции ответов поставщиков */
#quotesSection {
  overflow-x: auto;               /* <— главное: если не влезло — скролл */
}

/* сама таблица: не фиксируем layout, даём браузеру жить */
#quotesTable table {
  width: max-content;             /* ширина = по содержимому, можно скроллить */
  border-collapse: collapse;
}

/* базовые ячейки */
#quotesTable th,
#quotesTable td {
  padding: 4px 6px;
  /* white-space: nowrap;             чтобы даты, валюты и статусы не переносились */
}

/* ДВЕ одинаковые колонки для сравнения артикулов */
#quotesTable th.col-article,
#quotesTable td.col-article {
  min-width: 200px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* колонку "Комментарий" можно сделать пошире */
#quotesTable td:nth-child(10),
#quotesTable th:nth-child(10) {
  max-width: 240px;
}

/* Зона drag & drop под общий тёмный стиль */
.dropzone {
  margin-top: 6px;
  padding: 12px 12px;   /* было 8px 10px — увеличили вертикальный отступ */
  width: 100%;

  border: 1px dashed #2a3b53;
  border-radius: 10px;
  background: #050b16;

  color: var(--muted);

  font-size: 12px;
  line-height: 1.5;
  text-align: left;

  /* добавим минимальную высоту, чтобы было проще попадать мышкой */
  min-height: 44px;

  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.dropzone.is-dragover {
  border-color: var(--brand);
  background: #111b27;
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(59,130,246,.35);
}

@media (max-width: 640px) {
  .dropzone {
    font-size: 11px;
    padding: 10px 10px;  /* чуть меньше, но всё ещё комфортно */
    min-height: 40px;
  }
}

/* Входящие запросы: чипы-агрегаты в одну строку */
#inquiriesSection #inquiriesSummary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Пагинация в списке запросов */
#inquiriesPager{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
  margin-top:8px;
  font-size:13px;
  color:var(--muted);
}
#inquiriesPager button[disabled]{
  opacity:.4;
  cursor:default;
}

/* Подкарточка в разделе запросов */
.subcard{
  margin-top:12px;
  padding:10px 12px 12px;
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--panel-2);
}
.subcard-header{
  margin-bottom:8px;
}
.subcard-header .card-title{
  margin-bottom:2px;
}

/* Пагинация под таблицами (реестр запросов, последние КП) */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.pager-info {
  font-size: 12px;
  color: var(--muted);
}

