@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root, [data-theme="dark"] {
  /* Поверхні (найглибша → найвища) */
  --bg-sunken:   oklch(0.145 0.012 256);
  --bg-app:      oklch(0.171 0.013 256);
  --bg-panel:    oklch(0.208 0.014 256);
  --bg-elevated: oklch(0.245 0.015 256);
  --bg-overlay:  oklch(0.275 0.016 256);
  --bg-input:    oklch(0.232 0.015 256);

  /* Бордери */
  --border-subtle: oklch(0.262 0.013 256);
  --border:        oklch(0.318 0.015 256);
  --border-strong: oklch(0.418 0.018 256);

  /* Текст */
  --fg:        oklch(0.971 0.004 256);
  --fg-muted:  oklch(0.725 0.012 256);
  --fg-subtle: oklch(0.565 0.013 256);
  --fg-faint:  oklch(0.432 0.011 256);

  /* Бренд / сигнальний зелений */
  --brand:        oklch(0.792 0.166 159);
  --brand-strong: oklch(0.722 0.162 159);
  --brand-fg:     oklch(0.175 0.045 159);
  --brand-muted:  oklch(0.470 0.090 159);
  --brand-tint:   oklch(0.272 0.052 159);

  /* Семантика */
  --positive: oklch(0.792 0.166 159); --positive-tint: oklch(0.272 0.052 159); --positive-border: oklch(0.402 0.082 159);
  --negative: oklch(0.712 0.178 24);  --negative-tint: oklch(0.285 0.072 24);  --negative-border: oklch(0.432 0.108 24);
  --warning:  oklch(0.832 0.148 82);  --warning-tint:  oklch(0.305 0.058 82);
  --info:     oklch(0.748 0.128 236); --info-tint:     oklch(0.300 0.058 236);

  /* Тінти активів */
  --usdt: oklch(0.778 0.122 176); --usdt-tint: oklch(0.290 0.046 176);
  --uah:  oklch(0.748 0.118 236); --uah-tint:  oklch(0.295 0.052 236);

  --ring: oklch(0.792 0.166 159 / 0.45);
  --row-hover: oklch(0.232 0.015 256);
  --row-match: var(--positive-tint);

  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --glow: 0 0 0 1px oklch(0.792 0.166 159 / .35), 0 4px 18px oklch(0.792 0.166 159 / .22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* перекриває display з класів (.stale-hint, .error-banner) */

html { background: var(--bg-app); }
body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.wrap { max-width: 84rem; margin: 0 auto; padding: 24px; }

/* ───────── Topbar ───────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--brand);
  box-shadow: var(--glow);
}
.logo-text .name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.logo-text .sub { font-size: 12px; color: var(--fg-subtle); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-elevated);
}
.chip .dot { width: 7px; height: 7px; border-radius: 999px; }
.chip-pair { font-family: var(--font-mono); letter-spacing: 0.02em; }
.chip-pair .usdt { color: var(--usdt); }
.chip-pair .uah  { color: var(--uah); }
.spacer { flex: 1; }
.chip-status { color: var(--fg-muted); }
.chip-status.idle .dot { background: var(--fg-faint); }
.chip-status.loading .dot { background: var(--info); animation: pulse 1s infinite; }
.chip-status.live .dot { background: var(--positive); box-shadow: 0 0 8px var(--positive); }
.chip-status.err { color: var(--negative); border-color: var(--negative-border); background: var(--negative-tint); }
.chip-status.err .dot { background: var(--negative); }
@keyframes pulse { 50% { opacity: .35; } }

/* Банер помилки */
.error-banner {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 16px 16px; padding: 12px 14px; border-radius: 10px;
  background: var(--negative-tint); border: 1px solid var(--negative-border); color: var(--fg);
}
.error-banner svg { color: var(--negative); flex-shrink: 0; margin-top: 1px; }
.error-banner .et { font-size: 13px; }
.error-banner .et b { color: var(--negative); }
.error-banner .detail { color: var(--fg-muted); font-family: var(--font-mono); font-size: 12px; word-break: break-word; margin-top: 3px; }

/* ───────── Controls ───────── */
.controls {
  display: grid; grid-template-columns: auto auto auto 1fr auto; gap: 16px; align-items: end;
  margin-top: 20px; padding: 16px;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 10px;
}
.field-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--fg-muted);
  margin-bottom: 7px; letter-spacing: 0.01em;
}

/* Toggle */
.toggle {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 9px;
}
.toggle button {
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border: none; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--fg-muted);
  transition: all .18s var(--ease); white-space: nowrap;
}
.toggle button:hover { color: var(--fg); }
.toggle button.active { background: var(--brand); color: var(--brand-fg); box-shadow: var(--glow); }
.toggle button:active { transform: scale(0.97); }

/* Авто-оновлення */
.refresh-cell { display: flex; flex-direction: column; gap: 8px; }
.auto-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auto-label { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.toggle-sm { padding: 3px; }
.toggle-sm button { padding: 5px 9px; font-size: 12px; }
.auto-next {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-subtle);
  display: inline-block; width: 88px; flex: none;   /* фіксована ширина під найдовший текст — інтерфейс не скаче */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Дропдаун методів оплати */
.paydd { position: relative; }
.paydd-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; color: var(--fg);
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; white-space: nowrap; transition: border-color .15s var(--ease);
}
.paydd-btn:hover { border-color: var(--brand-muted); }
.pay-count {
  display: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; font-family: var(--font-mono); align-items: center; justify-content: center;
  background: var(--brand); color: var(--brand-fg);
}
.pay-count.on { display: inline-flex; }
.paydd-panel {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 240px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 40px oklch(0 0 0 / .45); padding: 8px;
}
.paydd-actions { display: flex; justify-content: flex-end; padding: 2px 4px 6px; }
.paydd-actions button {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--fg-muted);
  background: none; border: none; cursor: pointer;
}
.paydd-actions button:hover { color: var(--brand); }
.paydd-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.paydd-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 13px; color: var(--fg); cursor: pointer;
}
.paydd-opt:hover { background: var(--bg-overlay); }
.paydd-opt input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

/* Ринкова панель: спред + графік */
.market-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 20px; padding: 12px 16px;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 10px;
}
.mkt-spread { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mkt-item { display: flex; flex-direction: column; gap: 2px; }
.mkt-k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-faint); }
.mkt-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600; color: var(--fg); }
.mkt-v.pos { color: var(--positive); }
.mkt-v.neg { color: var(--negative); }
.mkt-sep { width: 1px; align-self: stretch; background: var(--border-subtle); }
.mkt-spark { display: flex; align-items: center; gap: 10px; }
.mkt-spark .mkt-k { white-space: nowrap; }
.sparkline { width: 200px; height: 40px; display: block; }

/* Telegram-алерти */
.alert-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px; }
.al-select {
  height: 40px; padding: 0 12px; border-radius: 7px; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; color: var(--fg);
  background: var(--bg-input); border: 1px solid var(--border);
}
.al-select:focus { outline: none; border-color: var(--brand-muted); box-shadow: 0 0 0 3px var(--ring); }
.alert-form .textfield input { width: 130px; }
.alert-form .al-note input { width: 200px; font-family: var(--font-sans); }
.alert-list { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.al-empty { color: var(--fg-subtle); font-size: 13px; padding: 6px 2px; }
.al-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--bg-sunken);
  border: 1px solid var(--border-subtle); border-radius: 9px;
}
.al-rule { font-size: 14px; color: var(--fg); }
.al-rule b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.al-note-txt { color: var(--fg-subtle); }
.al-del {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  color: var(--fg-muted); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: all .15s var(--ease);
}
.al-del:hover { color: var(--negative); border-color: var(--negative-border); background: var(--negative-tint); }

/* TextField */
.textfield { position: relative; display: flex; align-items: center; }
.textfield .prefix, .textfield .suffix {
  position: absolute; color: var(--fg-subtle); font-family: var(--font-mono);
  font-size: 14px; pointer-events: none;
}
.textfield .prefix { left: 12px; }
.textfield .suffix { right: 12px; font-size: 12px; }
.textfield input {
  width: 100%; height: 40px; padding: 0 12px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px;
  background: var(--bg-input); color: var(--fg);
  border: 1px solid var(--border); border-radius: 7px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textfield.has-prefix input { padding-left: 26px; }
.textfield.has-suffix input { padding-right: 64px; }
.textfield input::placeholder { color: var(--fg-faint); font-family: var(--font-sans); }
.textfield input:focus {
  outline: none; border-color: var(--brand-muted); box-shadow: 0 0 0 3px var(--ring);
}

/* Button */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 40px; padding: 0 18px; border-radius: 7px; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s var(--ease); white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: var(--brand-fg); box-shadow: var(--glow); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:disabled { opacity: .6; cursor: default; box-shadow: none; }
.btn-secondary { background: var(--bg-elevated); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-overlay); }

.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Stat cards ───────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 20px; }
.stat-card {
  position: relative; overflow: hidden;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 14px;
  padding: 16px;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent, var(--brand));
}
.stat-card.c-brand { --accent: var(--brand); }
.stat-card.c-info  { --accent: var(--info); }
.stat-card.c-warn  { --accent: var(--warning); }
.stat-overline {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-subtle); display: flex; align-items: center; gap: 7px;
}
.stat-overline svg { color: var(--accent, var(--brand)); }
.stat-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 32px; font-weight: 600; line-height: 1.2; margin-top: 10px; letter-spacing: -0.01em;
}
.stat-value .unit { font-size: 16px; color: var(--fg-subtle); margin-left: 4px; }
.stat-sub { font-size: 12px; color: var(--fg-subtle); margin-top: 6px; }
.stat-fee-sub { display: flex; align-items: center; gap: 6px; }
.stat-fee-input {
  width: 56px; padding: 3px 6px; border-radius: 6px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px;
  background: var(--bg-input); color: var(--fg); border: 1px solid var(--border);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.stat-fee-input:focus { outline: none; border-color: var(--brand-muted); box-shadow: 0 0 0 3px var(--ring); }
.stat-card.info-card .stat-value { font-size: 22px; }
.stat-card.info-card .big { color: var(--positive); }

/* ───────── Panel / Table ───────── */
.panel {
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 10px;
  margin-top: 20px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-subtle);
}
.panel-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-count { font-size: 12px; color: var(--fg-subtle); font-family: var(--font-mono); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
thead th {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-subtle); text-align: left; padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle); white-space: nowrap; background: var(--bg-panel);
}
thead th.num { text-align: right; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .18s var(--ease), box-shadow .18s var(--ease); }
tbody tr:hover { background: var(--row-hover); }

/* Підходящі ордери — чітко виділені: сильніший тінт, зелена смужка зліва, зелені бордери */
tbody tr.match { background: var(--row-match); }
tbody tr.match:hover { background: oklch(0.318 0.062 159); }
tbody tr.match td { border-bottom-color: var(--positive-border); }
tbody tr.match td:first-child { box-shadow: inset 3px 0 0 0 var(--positive); }

/* Непідходящі — приглушені, щоб виділені «вистрілювали» */
tbody tr.nomatch td { color: var(--fg-subtle); }

td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.num .cur { color: var(--fg-subtle); font-size: 12px; margin-left: 3px; }
tr.match td.price-cell { color: var(--positive); font-weight: 700; }
tr.nomatch td.price-cell { color: var(--fg-subtle); }

.trader { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  font-family: var(--font-mono);
}
.trader-meta .nick { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.trader-meta .stat-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--fg-subtle); font-family: var(--font-mono); }
.trader-meta .stat-line .stat-nums { font-family: var(--font-mono); }

/* Бейдж статусу продавця */
.seller-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.seller-user   { color: var(--fg-subtle); background: var(--bg-elevated); border-color: var(--border-subtle); }
.tier-bronze   { color: oklch(0.78 0.10 60);  background: oklch(0.30 0.05 60);  border-color: oklch(0.45 0.08 60); }
.tier-silver   { color: oklch(0.86 0.02 256); background: oklch(0.34 0.01 256); border-color: oklch(0.50 0.01 256); }
.tier-gold     { color: oklch(0.86 0.14 95);  background: oklch(0.33 0.07 95);  border-color: oklch(0.52 0.11 95); }
.seller-block  { color: var(--info); background: var(--info-tint); border-color: var(--info); }

/* Колонка «у статистиці» + чекбокс */
.col-incl { width: 36px; text-align: center; padding-left: 8px !important; padding-right: 8px !important; }
th.col-incl { color: var(--fg-subtle); font-weight: 600; }
.incl-cb {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; margin: 0; cursor: pointer; vertical-align: middle;
  background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: 4px;
  display: inline-grid; place-content: center;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.incl-cb:hover { border-color: var(--brand-muted); }
.incl-cb:checked, .incl-cb:indeterminate { background: var(--brand); border-color: var(--brand); }
.incl-cb:checked::after {
  content: ""; width: 4px; height: 8px; margin-top: -2px;
  border: solid var(--brand-fg); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.incl-cb:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--brand-fg); border-radius: 1px; }
.incl-cb:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
/* Виключений рядок — приглушений, без зеленого підсвічування */
tr.excluded { opacity: 0.42; }
tr.excluded td.price-cell { color: var(--fg-subtle) !important; font-weight: 500 !important; }
tr.excluded.match { background: transparent; }

/* Кнопка «відкрити на Binance» в рядку */
.col-open { width: 44px; text-align: center; }
.open-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  color: var(--fg-muted); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 8px;
  text-decoration: none; transition: all .15s var(--ease);
}
.open-btn:hover { color: var(--brand); border-color: var(--brand-muted); background: var(--bg-overlay); }
.open-btn:active { transform: scale(0.94); }

.match-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--positive);
  background: var(--positive-tint); border: 1px solid var(--positive-border);
  padding: 1px 6px 1px 4px; border-radius: 999px;
}

.methods { display: flex; flex-wrap: wrap; gap: 6px; }
.method {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--fg-muted);
  white-space: nowrap;
}
.method .sq { width: 8px; height: 8px; border-radius: 2px; }

/* Skeleton */
.skel {
  height: 14px; border-radius: 5px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-overlay) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
.skel.circle { width: 32px; height: 32px; border-radius: 999px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 16px; color: var(--fg-subtle);
}

.stale-hint {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  color: var(--warning); background: var(--warning-tint); border: 1px solid var(--warning);
}

.load-more-wrap { padding: 14px 16px; border-top: 1px solid var(--border-subtle); text-align: center; }
.all-loaded { font-size: 13px; color: var(--fg-subtle); font-family: var(--font-mono); }

/* ───────── Calculator ───────── */
.calc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px; }
.calc-results {
  border-top: 1px solid var(--border-subtle);
  padding: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px;
}
.result-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.result-row .label { font-size: 13px; color: var(--fg-muted); }
.result-row .val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; }
.result-row.profit .val.pos { color: var(--positive); }
.result-row.profit .val.neg { color: var(--negative); }
.calc-divider { grid-column: 1 / -1; height: 1px; background: var(--border-subtle); margin: 2px 0; }
.calc-note { grid-column: 1 / -1; font-size: 12px; color: var(--fg-subtle); display: flex; align-items: center; gap: 7px; }
.field-hint { font-size: 11px; color: var(--fg-faint); font-weight: 400; margin-left: 6px; }

footer { text-align: center; color: var(--fg-faint); font-size: 12px; padding: 24px 0 8px; }

/* ───────── Адаптив ───────── */
@media (max-width: 920px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .calc-grid { grid-template-columns: 1fr; }
  .calc-results { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 16px; }
  .controls { grid-template-columns: 1fr; }
  .toggle { width: 100%; }
  .toggle button { flex: 1; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
}

/* ───────── Сторінка історії ордерів ───────── */
a.btn { text-decoration: none; }

.key-body { padding: 16px; }
.key-hint { font-size: 13px; color: var(--fg-muted); margin-bottom: 12px; }
.key-hint b { color: var(--fg); }
.key-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.key-row .textfield { flex: 1; min-width: 220px; }
.key-row .textfield input { width: 100%; font-family: var(--font-mono); }

.hist-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; }

.hist-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; margin-top: 20px; align-items: start; }
.hist-stats { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; }

.ord-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; max-height: 74vh; overflow-y: auto; }
.ord-empty { padding: 18px 4px; color: var(--fg-subtle); font-size: 14px; }
.ord-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  background: var(--bg-sunken); border: 1px solid var(--border-subtle); border-radius: 9px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.ord-item:hover { border-color: var(--border); }
.ord-item.sel { border-color: var(--brand-muted); background: var(--positive-tint); }
.ord-item .incl-cb { margin-top: 2px; flex: none; }
.ord-main { flex: 1; min-width: 0; }
.ord-line1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ord-side { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent; }
.side-buy { color: var(--positive); background: var(--positive-tint); border-color: var(--positive-border); }
.side-sell { color: var(--info); background: var(--info-tint); border-color: var(--info); }
.ord-price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.ord-price .cur { color: var(--fg-subtle); font-size: 12px; }
.ord-date { margin-left: auto; color: var(--fg-subtle); font-size: 12px; font-family: var(--font-mono); }
.ord-line2 { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 5px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--fg-muted); }
.ord-pm { color: var(--fg-subtle); }

@media (max-width: 860px) {
  .hist-grid { grid-template-columns: 1fr; }
  .hist-stats { position: static; }
}

/* Розбивка Купівля/Продаж на сторінці історії */
.split-tbl { width: 100%; border-collapse: collapse; margin-top: 10px; }
.split-tbl th, .split-tbl td { padding: 5px 4px; text-align: right; font-size: 13px; }
.split-tbl th:first-child, .split-tbl td:first-child { text-align: left; color: var(--fg-muted); font-weight: 500; }
.split-tbl thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.split-tbl .th-buy { color: var(--positive); }
.split-tbl .th-sell { color: var(--info); }
.split-tbl tbody td:not(:first-child) { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.split-tbl tbody tr + tr td { border-top: 1px solid oklch(0.262 0.013 256 / .5); }

/* Історія: картки в ряд, адаптивно */
.stat-card.c-pos { --accent: var(--positive); }
.stat-card.c-neg { --accent: var(--negative); }
#histStats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (max-width: 560px) { #histStats { grid-template-columns: 1fr; } }

/* ───────── Сторінка входу ───────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; padding: 28px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 60px oklch(0 0 0 / .4);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-card .field-label { margin-bottom: 6px; }
.login-card .textfield input { width: 100%; }
.login-err {
  margin-top: 12px; padding: 9px 12px; border-radius: 8px; font-size: 13px;
  color: var(--negative); background: var(--negative-tint); border: 1px solid var(--negative-border);
}
