/* Тёмная панель: чёрный фон, карточки с тонкой рамкой, белый акцент. */
:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #171717;
  --border: #222222;
  --line: #1c1c1c;
  --text: #ededed;
  --muted: #8b8b8b;
  --faint: #5c5c5c;
  --hint: var(--muted);
  --accent: #ededed;
  --accent-text: #0a0a0a;
  --link: #ededed;
  --danger: #f26d6d;
  --pos: #4ade80;
  --neg: #f26d6d;
  --field: #161616;

  --st-bought: #7aa2f7;
  --st-transferred: #e0af68;
  --st-accepted: #73daca;
  --st-sold: #bb9af7;
  --st-failed: #f26d6d;
  --st-deleted: #5c5c5c;

  --r: 12px;
  --pad: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body { font: 400 14px/1.45 "Geist", "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px solid var(--muted); outline-offset: 2px; }
a { color: inherit; }

/* ---------- шапка ---------- */
header#top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 var(--pad); }
.bar { display: flex; align-items: center; gap: 8px; height: 56px; }
.pill { background: var(--text); color: var(--bg); font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; }
.who { color: var(--muted); font-size: 13px; }
.bar .grow { flex: 1; }
.tools { display: flex; align-items: center; gap: 10px; }
.linkbtn { border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 2px; }
.linkbtn:hover { color: var(--text); }
nav#tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
nav#tabs::-webkit-scrollbar { display: none; }
nav#tabs[hidden] { display: none; }
nav#tabs a { padding: 10px 0 11px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav#tabs a:hover { color: var(--text); }
nav#tabs a.on { color: var(--text); border-bottom-color: var(--text); }

.crumb { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; }
.crumb[hidden] { display: none; }
.crumb h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.crumb .sub { color: var(--muted); font-size: 13px; }
button.back { border: 0; background: none; color: var(--muted); padding: 0; cursor: pointer; font-size: 13px; }
button.back:hover { color: var(--text); }
main { max-width: 960px; margin: 0 auto; padding: 18px var(--pad) 40px; }

/* ---------- карточки и метрики ---------- */
.card, .group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.card { padding: 16px; }
.card-h, .gh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.card-h { margin-bottom: 14px; }
.card-h .r { text-transform: none; letter-spacing: 0; font-size: 12px; }
.gh { margin: 22px 2px 8px; }
.gh:first-child { margin-top: 0; }
.gh button { text-transform: none; letter-spacing: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; min-width: 0; }
.metric .label { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.metric .num { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 10px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .subt { font-size: 12px; color: var(--muted); }
.delta { font-size: 11px; font-weight: 600; letter-spacing: 0; }
.cols { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; margin-top: 12px; }

/* столбчатый график */
.chart { position: relative; height: 170px; display: flex; align-items: flex-end; justify-content: space-around; gap: 4px; border-bottom: 1.5px solid var(--text); }
.chart .gl { position: absolute; left: 0; right: 0; border-top: 1px dashed #1f1f1f; font-size: 9px; color: var(--faint); }
.chart .gl span { position: absolute; top: -6px; left: 0; background: var(--surface); padding-right: 4px; }
.chart .b { flex: 1; min-width: 2px; max-width: 42px; background: #262626; border-radius: 3px 3px 0 0; position: relative; z-index: 1; }
.chart .b:hover { background: #3f3f3f; }
.chart .b[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 11px; padding: 4px 7px; border-radius: 6px; white-space: nowrap; z-index: 3; }
.xl { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: #262626; }

/* разбивка по этапам */
.flow { display: flex; height: 8px; gap: 2px; border-radius: 4px; overflow: hidden; background: var(--surface-2); margin-bottom: 8px; }
.flow i { display: block; background: var(--c); min-width: 3px; }
.brk { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.brk:last-child { border-bottom: 0; }
.brk:hover .nm { color: #fff; }
.brk .nm { flex: 1; font-weight: 500; }
.brk .ct { font-weight: 600; }
.brk .pc { color: var(--muted); width: 46px; text-align: right; font-size: 12px; }
.brk .sm { color: var(--muted); font-size: 12px; min-width: 64px; text-align: right; }

/* ---------- строки списков ---------- */
.pad { padding: 14px var(--pad); }
.note { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }
.line { display: flex; align-items: center; gap: 12px; padding: 12px var(--pad); min-height: 46px; position: relative; }
.line + .line { border-top: 1px solid var(--line); }
.line .k { flex: 1; min-width: 0; }
.line .v { text-align: right; white-space: nowrap; font-weight: 500; }
.dim, .line .v.dim { color: var(--muted); font-weight: 400; }
a.line, button.line { width: 100%; border: 0; background: none; text-align: left; text-decoration: none; color: inherit; cursor: pointer; }
a.line + a.line { border-top: 1px solid var(--line); }
a.line:hover { background: var(--surface-2); }
.chev::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-top: 1.5px solid var(--faint); transform: rotate(45deg); flex: none; }
.line .k > .title, .line .k > .meta { display: block; }
.line .v > .st { margin-top: 3px; }
.title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money { font-weight: 600; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }
.st-bought { --c: var(--st-bought); } .st-transferred { --c: var(--st-transferred); } .st-accepted { --c: var(--st-accepted); }
.st-sold { --c: var(--st-sold); } .st-failed { --c: var(--st-failed); } .st-deleted { --c: var(--st-deleted); }

/* ---------- кнопки ---------- */
.acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 16px; font-weight: 500; font-size: 14px; background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #ffffff; }
.btn.quiet { background: var(--surface-2); }
.btn.danger { background: none; border-color: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.lot-acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.lot-acts > * { flex: 1 1 180px; }
.lot-acts:empty { display: none; }

/* ---------- поля ---------- */
.field { display: block; padding: 10px var(--pad); position: relative; }
.group > .field + .field, .group > .pair + .field, .group > .field + .pair, .group > .pair + .pair,
.group > .line + .field, .group > .field + .line, .group > .pair + .line { border-top: 1px solid var(--line); }
.pair { display: grid; grid-template-columns: 1fr 1fr; }
.pair.three { grid-template-columns: 1fr 1fr 1fr; }
.pair .field + .field { border-left: 1px solid var(--line); }
.field > span { display: block; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.field input, .field select, .field textarea { width: 100%; border: 0; background: none; padding: 2px 0; font-size: 15px; outline: none; border-radius: 0; }
.field select { -webkit-appearance: none; appearance: none; }
.field select option { background: var(--surface); }
.field textarea { min-height: 44px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="date"], input[type="time"] { color-scheme: dark; }
.search { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px 14px; font-size: 14px; outline: none; margin-bottom: 12px; }
.search:focus { border-color: #333; }

/* сегменты (как Day / Week / Month) */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button { border: 0; background: none; border-radius: 7px; padding: 5px 11px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px #2a2a2a; }
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; font-size: 13px; background: var(--surface); color: var(--muted); cursor: pointer; }
.filters button:hover { color: var(--text); }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* этапы в карточке лота */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 14px var(--pad) 12px; }
.steps button { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--muted); font-size: 12px; }
.steps button i { display: block; height: 3px; border-radius: 2px; background: var(--surface-2); margin-bottom: 7px; }
.steps button.done i { background: var(--c); }
.steps button.cur { color: var(--text); font-weight: 600; }
.failed-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 var(--pad) 12px; }

/* копирование */
.copy { display: flex; align-items: center; gap: 12px; padding: 12px var(--pad); cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.copy:hover { background: var(--surface-2); }
.copy + .copy { border-top: 1px solid var(--line); }
.copy .k { flex: 1; min-width: 0; }
.copy .meta { display: block; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; white-space: normal; }
.copy .val { display: block; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; margin-top: 2px; }
.copy .act { color: var(--muted); font-size: 12px; flex: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; }

/* скрины */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 140px;
  border: 1px dashed #333; border-radius: var(--r); background: var(--surface); cursor: pointer; text-align: center; padding: 20px; }
.drop.over { border-color: var(--text); background: var(--surface-2); }
.drop input { display: none; }
.drop b { font-weight: 600; }
.drop .meta { white-space: normal; max-width: 340px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; display: inline-block; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: var(--text); color: var(--bg); font-size: 14px; line-height: 20px; padding: 0; cursor: pointer; }

/* история */
.tl { list-style: none; margin: 0; padding: 6px 0; }
.tl li { display: grid; grid-template-columns: 14px 1fr; gap: 0 10px; padding: 8px var(--pad); }
.tl li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); margin: 6px 0 0 3px; }
.tl .what { font-weight: 500; }
.tl .when { color: var(--muted); font-size: 12px; }
.tl .det { grid-column: 2; font-size: 13px; color: var(--muted); }

/* таблицы */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 500; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; padding: 12px 8px 8px; }
table.t td { padding: 10px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
table.t th:first-child, table.t td:first-child { padding-left: var(--pad); }
table.t th:last-child, table.t td:last-child { padding-right: var(--pad); }
table.t .n { text-align: right; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }

/* шторка */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-body { width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 16px 16px 0 0; padding: 10px var(--pad) calc(18px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
.sheet-body::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: #333; margin: 0 auto 14px; }
.sheet-body h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.sheet-body .lead { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.sheet-body .seg { display: flex; } .sheet-body .seg button { flex: 1; padding: 8px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-body { border-radius: 16px; border-bottom: 1px solid var(--border); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 500; max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); color: #fff; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .7s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sheet-body, .spin { animation: none; } }

/* ---------- узкий экран ---------- */
@media (max-width: 720px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cols { grid-template-columns: 1fr; }
  .metric .num { font-size: 21px; }
  .acts { grid-template-columns: 1fr 1fr; }
  .acts .btn.primary { grid-column: 1 / -1; }
  nav#tabs { gap: 18px; }
}
@media (max-width: 360px) { .pair.three { grid-template-columns: 1fr 1fr; } }

/* ---------- узкий экран: ничего не прячется за краем ---------- */
/* фильтры и периоды — переносом строк, без горизонтальной прокрутки */
.filters { flex-wrap: wrap; overflow: visible; }
/* вкладки: затухание и стрелка у края, за которым есть ещё вкладки */
.tabs-wrap { position: relative; }
.tabs-wrap::before, .tabs-wrap::after { position: absolute; top: 0; bottom: 1px; width: 44px; display: flex; align-items: center;
  font-size: 18px; color: var(--muted); pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 1; }
.tabs-wrap::before { content: "‹"; left: 0; justify-content: flex-start; background: linear-gradient(to left, transparent, var(--bg) 60%); }
.tabs-wrap::after { content: "›"; right: 0; justify-content: flex-end; background: linear-gradient(to right, transparent, var(--bg) 60%); }
.tabs-wrap.more-left::before, .tabs-wrap.more-right::after { opacity: 1; }
@media (max-width: 480px) { nav#tabs { gap: 16px; } nav#tabs a { font-size: 13.5px; } }

.acts.top { margin: 0 0 12px; }

/* «Лоты»: заголовки дней */
.dayh { display: flex; justify-content: space-between; gap: 10px; margin: 16px 2px 8px; font-size: 13px; font-weight: 600; }
.dayh span + span { color: var(--muted); font-weight: 400; font-size: 12px; }
.gh + .dayh { margin-top: 6px; }
