:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 { font-size: 20px; margin: 0; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 28px 80px; }

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

section h2 {
  margin: 0 0 14px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

/* ---- сворачиваемые секции ---- */

section > details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
section > details > summary::-webkit-details-marker { display: none; }
section > details > summary h2 { margin: 0; }
section > details > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-bottom: 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
section > details[open] > summary::before { transform: rotate(45deg); }
section > details[open] > summary { margin-bottom: 14px; }
section > details > summary:hover h2,
section > details > summary:hover::before { color: var(--text); border-color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok    { background: rgba(34,197,94,.15);  color: var(--accent-2); }
.badge.error { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge.warn  { background: rgba(245,158,11,.15); color: var(--warn); }

.totals { display: flex; gap: 28px; margin-bottom: 16px; flex-wrap: wrap; }
.totals .stat { min-width: 140px; }
.totals .stat .value { font-size: 26px; font-weight: 700; }
.totals .stat .label { color: var(--muted); font-size: 12px; }

button, input, select {
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

button { cursor: pointer; background: var(--accent); color: #fff; border: none; font-weight: 600; }
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.btn-link:hover { color: var(--text); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none; color: var(--muted); border: none;
  border-bottom: 2px solid transparent; border-radius: 0;
  padding: 10px 4px; font-weight: 600;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabpanel { display: none; }
.tabpanel.active { display: block; }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.hint b { color: var(--warn); }

pre.result {
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12.5px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---- навигация ---- */

.mainnav { display: flex; gap: 16px; margin-top: 8px; }
.mainnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.mainnav a:hover { color: var(--text); }
.mainnav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- прогресс загрузки и выгрузки ---- */

.progress-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-top: 14px;
}
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progress-track {
  height: 8px;
  background: #0b0d11;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

/* ---- таблица объявлений ---- */

.table-scroll {
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 1;
}
#items-table td { vertical-align: top; }
#items-table a { color: var(--accent); text-decoration: none; }
#items-table a:hover { text-decoration: underline; }

tr.row-changed { background: rgba(79,140,255,.08); }
tr.row-changed td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.bid-cell { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.bid-cell .cur { font-size: 13px; }
.bid-input { padding: 4px 8px; font-size: 13px; width: 100%; }

/* ---- закреплённая панель действий ---- */

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px;
  margin-top: 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.sticky-actions span { margin-right: auto; }

/* ---- страница входа ---- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-box h1 { margin: 0; font-size: 20px; }
.login-box p { margin: 0; }
.login-box .field { width: 100%; }
.login-box input { width: 100%; }
.login-error { color: var(--danger); font-size: 13px; }

/* ---- setup ---- */

.setup-box {
  max-width: 720px;
  margin: 40px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.setup-box code, .setup-box pre {
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  display: block;
  overflow-x: auto;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}
