/* Окна арбитража — рабочий стол трейдера: сверху сводка и фильтры, ниже лента сделок по убыванию прибыли.
   Палитра: чернильно-синие нейтрали, кобальт — действие, зелёный/красный/янтарный — только смысл (плюс, закрыто, неизвестно). */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #5b6880;
  --line: #dfe4ee;
  --accent: #2552d0;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfb;
  --good: #11804a;
  --good-soft: #e3f4ea;
  --bad: #c0352b;
  --bad-soft: #fbe8e6;
  --warn: #a8670a;
  --warn-soft: #fbf0dc;
  --open: #0f7a57;
  --open-soft: #dcf3ea;
  --fresh: #fff4c7;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1420; --panel: #152033; --ink: #e6ecf5; --muted: #93a1b8; --line: #26344b;
    --accent: #6f95ff; --accent-ink: #0b1220; --accent-soft: #1d2b4a;
    --good: #4cd38c; --good-soft: #143425; --bad: #ff7b70; --bad-soft: #3a1c1c;
    --warn: #f0b552; --warn-soft: #3a2c12; --open: #52d6a6; --open-soft: #123628; --fresh: #3a3413;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1420; --panel: #152033; --ink: #e6ecf5; --muted: #93a1b8; --line: #26344b;
  --accent: #6f95ff; --accent-ink: #0b1220; --accent-soft: #1d2b4a;
  --good: #4cd38c; --good-soft: #143425; --bad: #ff7b70; --bad-soft: #3a1c1c;
  --warn: #f0b552; --warn-soft: #3a2c12; --open: #52d6a6; --open-soft: #123628; --fresh: #3a3413;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font-ui);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.wrap { max-width: 1320px; margin: 0 auto; }

/* ── шапка ── */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg);
  padding-block: 12px 10px; border-bottom: 1px solid var(--line);
  display: grid; gap: 10px;
}
.headline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.headline h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.late { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.dead { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.headline .spacer { flex: 1; }
.counts { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.counts b { color: var(--ink); font-size: 15px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; color: var(--muted); }
.ghost:hover { color: var(--ink); border-color: var(--muted); }
.ghost[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.filters { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--muted); user-select: none;
}
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.chip[aria-pressed="false"] { opacity: .55; }
.chip .age { font-family: var(--font-num); font-size: 12px; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.field input[type="number"], .field input[type="search"], .field select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-width: 0;
}
.field input[type="number"] { width: 5.5em; }
.field input[type="search"] { width: 9em; }
.field input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

.banner { border-radius: var(--r); padding: 10px 14px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--ink); border: 1px solid var(--bad); }

/* ── лента ── */
main { display: grid; gap: 22px; padding-top: 14px; }
.list { display: grid; gap: 8px; }
.colhead, .row-main {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 2.2rem minmax(8rem, 1.1fr) minmax(12rem, 2fr) 6.5rem 7.5rem minmax(9rem, 1.2fr) auto;
}
.colhead { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 14px; }
.colhead .r { text-align: right; }
.row { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); transition: background-color 1.2s; }
.row.open { border-color: var(--open); box-shadow: inset 4px 0 0 var(--open); }
.row.fresh { background: var(--fresh); }
.row.stale { opacity: .6; }
.row-main { padding: 10px 14px; }
.rank { font-family: var(--font-num); color: var(--muted); font-size: 13px; }
.coin { min-width: 0; }
.coin b { font-size: 17px; letter-spacing: .01em; display: block; overflow-wrap: anywhere; }
.coin small, .route small { color: var(--muted); font-size: 12.5px; display: block; overflow-wrap: anywhere; }
.route { min-width: 0; font-size: 14px; }
.route .leg { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.route .arrow { color: var(--muted); }
.route .venue { font-weight: 600; }
.pct, .usd { text-align: right; }
.pct b { font-size: 17px; font-family: var(--font-num); }
.usd b { font-size: 19px; font-family: var(--font-num); }
.pct small, .usd small { display: block; color: var(--muted); font-size: 12px; font-family: var(--font-num); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.status { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 2px 7px; font-size: 12.5px; white-space: nowrap; }
.pill.open { background: var(--open-soft); color: var(--open); font-weight: 600; }
.pill.live { background: var(--accent-soft); color: var(--accent); }
.pill.est { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.no { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.pill.unk { background: var(--line); color: var(--muted); }
.acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; font-weight: 600;
  color: var(--ink); background: var(--panel); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.main { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.main:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.swap { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
details.more { border-top: 1px dashed var(--line); }
details.more summary { cursor: pointer; padding: 6px 14px; font-size: 12.5px; color: var(--muted); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸ "; }
details.more[open] summary::before { content: "▾ "; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; padding: 2px 14px 12px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); padding: 26px; text-align: center; color: var(--muted); }

h2 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.tablebox { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
.foot { color: var(--muted); font-size: 12.5px; }

/* ── телефон: строка → карточка ── */
@media (max-width: 900px) {
  .colhead { display: none; }
  .row-main {
    grid-template-columns: 1fr auto; grid-template-areas: "coin usd" "route pct" "status status" "acts acts";
    gap: 8px 12px;
  }
  .rank { display: none; }
  .coin { grid-area: coin; } .route { grid-area: route; } .pct { grid-area: pct; } .usd { grid-area: usd; }
  .status { grid-area: status; } .acts { grid-area: acts; justify-content: stretch; }
  .acts .btn { flex: 1; min-height: 40px; }
  .field input[type="search"] { width: 7.5em; }
}

/* ── вход ── */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; }
.login .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: min(380px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login .lbl { font-size: 13px; color: var(--muted); margin-bottom: -8px; }
.login input[type="text"] { width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
.login button { padding: 12px; border-radius: 9px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px; cursor: pointer; }
.login button:disabled { opacity: .6; cursor: wait; }
.login .err { color: var(--bad); font-size: 14px; }
.login .ok { color: var(--good); font-size: 14px; }
.login .go-link { font-weight: 600; }

@media (prefers-reduced-motion: reduce) { .row { transition: none; } }
