/* Аукцион — сдержанная тёмная тема, без градиентов и декоративных излишеств */
:root {
  --bg: #101214;
  --panel: #16181b;
  --panel2: #1c1f23;
  --line: #272b30;
  --text: #e6e6e3;
  --muted: #8b929a;
  --accent: #d3a04a;       /* плоский, без градиента */
  --accent-hover: #e0b05e;
  --accent-ink: #191307;
  --green: #6dbb8a;
  --red: #e5736f;
  --yellow: #d9bd6b;
  --blue: #6fa8dc;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: inherit;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
h1 { font-size: 21px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.mono, .timer { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* --- панели и карточки --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.panel2 { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

main { max-width: 1020px; margin: 0 auto; padding: 14px 16px 90px; }

/* --- шапка --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.user-info { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.user-info .name { font-weight: 600; }
.balance { color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- чипы: цветная точка + текст --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip.green { color: var(--green); }
.chip.red { color: var(--red); }
.chip.yellow { color: var(--yellow); }
.chip.blue { color: var(--blue); }
.chip.gold { color: var(--accent); }

button.chip { cursor: pointer; }

/* --- кнопки --- */
.btn {
  font: inherit;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #23272c; }
.btn:active { background: #1f2328; }
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border-color: transparent;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--red); border-color: rgba(229, 115, 111, 0.35); }
.btn.danger:hover { background: rgba(229, 115, 111, 0.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* --- формы --- */
input, select {
  font: inherit;
  font-size: 16px; /* иначе iOS зумит */
  color: var(--text);
  background: #0c0e10;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; letter-spacing: 0.02em; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 130px; }
.error { color: var(--red); min-height: 20px; margin-top: 8px; font-size: 14px; }

/* --- таймер --- */
.timer { font-size: 30px; letter-spacing: 1px; color: var(--text); }
.timer.warn { color: var(--red); animation: pulse 1s infinite; }
.timer.paused { color: var(--yellow); }
@keyframes pulse { 50% { opacity: 0.45; } }

.progress { height: 6px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.3s; }
.progress.paused > div { background: var(--yellow); }

/* --- таблицы --- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.won { box-shadow: inset 3px 0 0 var(--green); }

.lot-img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); }
.lot-cell { display: flex; gap: 12px; align-items: center; }
.lot-text { min-width: 0; }
.lot-title { font-weight: 600; }
.lot-desc { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.lot-hint { color: var(--muted); font-size: 12px; font-style: italic; }

.bid-form { display: flex; gap: 8px; }
.bid-form input { width: 110px; text-align: center; }

.mybid { font-family: ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }

/* --- пилюли ставок (админ) --- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 14px;
  white-space: nowrap;
}
.pill b { color: var(--accent); font-variant-numeric: tabular-nums; }
.pill.top { border-color: rgba(109, 187, 138, 0.5); }

/* --- история --- */
.history { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.history button.chip { padding: 6px 12px; }

/* --- баннер связи --- */
.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(217, 189, 107, 0.12);
  border-bottom: 1px solid rgba(217, 189, 107, 0.4);
  color: var(--yellow);
  text-align: center;
  padding: 8px 12px;
  font-size: 14px;
}

/* --- тосты --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 50;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s;
  max-width: 100%;
}
.toast.err { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* --- вход --- */
.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-panel { width: 100%; max-width: 360px; text-align: center; }
.login-panel input { margin: 12px 0; text-align: center; font-size: 17px; }
.login-panel .btn { width: 100%; }
.login-panel a { display: inline-block; margin-top: 16px; font-size: 13px; }

/* --- вкладки админки --- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 14px 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tabs button {
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  padding: 7px 12px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.preview-img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.summary { font-size: 16px; color: var(--green); font-weight: 600; margin: 12px 0; }
.node-line { color: var(--muted); font-size: 13px; margin: 6px 0; font-variant-numeric: tabular-nums; }

.round-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.round-head h2 { margin: 0; }
.round-head .timer { margin-left: auto; }

.draft-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- мобильная версия ≤700px: лоты → маркетплейс-сетка, 2 карточки в ряд --- */
@media (max-width: 700px) {
  main { padding: 10px 10px 90px; }

  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 12px;
    margin: 12px 0;
  }
  table.cards tr.won { box-shadow: inset 3px 0 0 var(--green); }
  table.cards td { border: none; padding: 6px 2px; }
  table.cards td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 3px;
  }
  table.cards td.lot-td { padding: 0; }
  table.cards td.lot-td::before { content: none; }
  table.cards .lot-cell { flex-direction: column; align-items: stretch; gap: 8px; }
  table.cards .lot-img { width: 100%; height: 160px; }
  table.cards .bid-form { width: 100%; }
  table.cards .bid-form input { flex: 1; width: auto; }

  /* сетка лотов: 2 карточки на одной линии, как в маркетплейсах */
  table.cards.lots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  table.cards.lots tbody { display: contents; }
  table.cards.lots tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 8px;
    margin: 0;
    padding: 24px 10px 10px;
  }
  table.cards.lots td { grid-column: 1 / -1; padding: 2px 0; }
  table.cards.lots td:nth-child(1) {
    position: absolute;
    top: 8px;
    right: 10px;
    padding: 0;
    font-size: 11px;
    color: var(--muted);
  }
  table.cards.lots td:nth-child(1)::before { content: none; }
  table.cards.lots td[data-label="Мин."],
  table.cards.lots td[data-label="Моя ставка"] { grid-column: auto; }
  table.cards.lots td[data-label="Мин."],
  table.cards.lots td[data-label="Моя ставка"] { font-size: 13px; }
  table.cards.lots td[data-label="Мин."]::before,
  table.cards.lots td[data-label="Моя ставка"]::before { font-size: 10px; }
  table.cards.lots .lot-img { height: 110px; }
  table.cards.lots .lot-title { font-size: 14px; }
  table.cards.lots .lot-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
  }
  table.cards.lots .lot-hint { font-size: 11px; }
  table.cards.lots .bid-form input { min-width: 0; padding: 8px 6px; }

  #toast { width: calc(100vw - 20px); }
  .toast { width: 100%; text-align: center; }
  .timer { font-size: 26px; }
}
