:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --text: #17212b;
  --muted: #667280;
  --line: #d9e0e7;
  --accent: #0f676e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --positive: #0f676e;
  --positive-soft: #dff7ea;
  --danger-soft: #ffe5e1;
  --shadow: 0 14px 36px rgba(19, 33, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 28px;
  display: grid;
  gap: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.auth-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: linear-gradient(145deg, #e7f6ef, #ffffff);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  bottom: 7px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.brand-mark::before {
  left: 8px;
  height: 8px;
}

.brand-mark span {
  left: 13px;
  height: 13px;
}

.brand-mark::after {
  left: 18px;
  height: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-link {
  margin-left: 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.topbar-link:hover {
  border-bottom-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.checkbox-row input {
  margin-top: 2px;
  width: auto;
  flex: 0 0 auto;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
}

.status-pill,
.live-pill,
.icon-link,
button {
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.live-pill {
  width: 14px;
  height: 14px;
  min-height: 14px;
  flex: 0 0 14px;
  border-radius: 50%;
  padding: 0;
  color: transparent;
  background: var(--positive);
  border-color: #b9e4cf;
}

.live-pill.live {
  background: var(--positive);
  border-color: #b9e4cf;
  box-shadow: 0 0 0 3px #e7f6ef;
}

.live-pill.stale {
  color: transparent;
  background: #c1373d;
  border-color: #e4a0a4;
  box-shadow: 0 0 0 3px #f8e7e8;
}

.status-pill.on {
  color: var(--positive);
  background: #e7f6ef;
  border-color: #b9e4cf;
}

.status-pill.off {
  color: var(--danger);
  background: #fff0ee;
  border-color: #ffd2cc;
}

.icon-link {
  background: var(--panel);
  color: var(--muted);
}

.topbar .live-pill,
.topbar .icon-link {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}

.topbar .live-pill {
  min-height: 14px;
  padding: 0;
}

.brand-lockup .live-pill {
  width: 11px;
  height: 11px;
  min-height: 11px;
  flex: 0 0 11px;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: var(--panel);
  color: var(--text);
}

.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.toolbar-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 42px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 24px;
}

.tab-button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.account-strip {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(110px, 132px));
  align-items: center;
  justify-self: end;
  gap: 6px;
}

.account-strip div {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  text-align: center;
}

.account-strip span {
  display: block;
  color: var(--text);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  white-space: nowrap;
}

.account-strip strong {
  display: block;
  margin-top: 1px;
  border-radius: 5px;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.pair-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.pair-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pair-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.pair-title.enabled {
  color: var(--accent);
}

.pair-title.disabled {
  color: var(--danger);
}

.pair-card header strong {
  border-radius: 5px;
  font-size: 17px;
  line-height: 1.1;
  text-align: right;
}

.pair-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.pair-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.pair-card dd {
  margin: 2px 0 0;
  border-radius: 5px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

.pair-card footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trade-overview-card {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
  padding: 12px 16px 10px;
}

.settings-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.settings-card h2 {
  margin: 0;
  font-size: 18px;
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.settings-allocation-usdt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.settings-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

button.danger {
  border-color: #f1a1a1;
  background: #fff3f3;
  color: #9f1d1d;
}

.settings-menu {
  position: relative;
}

.settings-menu summary {
  display: grid;
  place-items: center;
  gap: 3px;
  width: 22px;
  min-height: 28px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  list-style: none;
}

.settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-menu summary span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
}

.settings-menu-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 5;
  min-width: 112px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-menu-popover button {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
  text-align: left;
}

.settings-menu-popover form + form {
  margin-top: 4px;
}

/* Меню «три точки» у правого края карточки Track, по вертикали — по центру (кнопка «Купить»). */
.overview-menu {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 6;
}

/* Резервируем угол под точки, чтобы они не наезжали на цену в правой колонке. */
.trade-overview-card section:last-of-type {
  padding-right: 22px;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 20px;
}

.settings-form label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.field-loader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: none;
}

.field-loader[hidden] {
  display: none;
}

.field-loader i {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.split-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 6px;
}

.save-button {
  grid-column: 1 / -1;
}

.save-all-button {
  width: calc(100% - 32px);
  min-height: 30px;
  justify-self: center;
  padding: 6px 10px;
  font-size: 12px;
}

.add-pair-card {
  min-height: 0;
}

.add-pair-card h2 {
  margin-bottom: 20px;
}

.pair-search-field {
  position: relative;
  grid-column: 1 / -1;
}

.pair-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 6px;
  max-height: 178px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.pair-search-results[hidden] {
  display: none;
}

.pair-search-results button {
  min-height: 30px;
  padding: 5px 7px;
  border-color: #d8e1e5;
  background: #fff;
  color: #182129;
  font-size: 12px;
  font-weight: 900;
  text-align: left;
}

.pair-search-results button:hover,
.pair-search-results button.selected {
  border-color: rgba(13, 132, 120, 0.42);
  background: #edf8f6;
  color: var(--accent);
}

.pair-search-empty {
  padding: 4px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
}

.trade-overview-card section {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.trade-overview-card section:last-of-type {
  justify-self: end;
  justify-items: start;
  text-align: left;
  width: min(17ch, 100%);
  max-width: 100%;
  min-width: 0;
}

.trade-overview-card h2 {
  margin: 0 0 4px;
  border-radius: 5px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.08;
  white-space: nowrap;
}

.trade-overview-card h2.pair-title {
  font-size: 18px;
}

.trade-overview-card section:last-of-type h2 {
  color: #05070a;
}

.trade-overview-card p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
}

.trade-overview-card strong {
  display: block;
  border-radius: 5px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}

.trade-overview-card span {
  margin-top: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.trade-overview-card span b {
  color: #05070a;
  font-weight: inherit;
}

.trade-overview-card .overview-profit {
  margin-top: 0;
  color: #05070a;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}

.trade-overview-card .overview-profit b.positive {
  color: var(--accent);
}

.trade-overview-card .overview-profit b.negative {
  color: var(--danger);
}

.trade-overview-card .overview-block-reason {
  margin-top: 0;
  color: #C1373D;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.summary-grid,
.content-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  border-radius: 10px;
  margin: -4px;
  padding: 4px;
  transition: background-color 0.5s ease, color 0.5s ease;
}

.metric-trend {
  display: inline-flex;
  margin-top: 8px;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.panel {
  padding: 16px;
  overflow: auto;
}

.panel.wide {
  margin-bottom: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel-heading h2 {
  margin: 0;
}

.panel-heading.compact {
  align-items: flex-start;
}

.profit-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.orders-stack {
  display: grid;
  gap: 12px;
}

.orders-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  overflow: hidden;
}

.orders-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.08;
}

.orders-card table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 6px;
}

.orders-card th,
.orders-card td {
  padding: 0;
  border-bottom: 0;
  color: #05070a;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
}

.orders-card th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.orders-card td {
  font-size: 10px;
}

.orders-card th:first-child,
.orders-card td:first-child {
  width: 30%;
}

.orders-card th:nth-child(2),
.orders-card td:nth-child(2),
.orders-card th:nth-child(3),
.orders-card td:nth-child(3),
.orders-card th:nth-child(4),
.orders-card td:nth-child(4) {
  width: 23.333%;
  padding-left: 6px;
}

.profit-card-head,
.latest-cycles-head {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.profit-card-head.with-select,
.latest-cycles-head {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.profit-card-head h2,
.latest-cycles-head h2 {
  grid-column: 1 / 3;
}

.profit-card-head h2,
.latest-cycles-head h2 {
  margin: 0;
  color: var(--accent);
  font-size: 18px;
  line-height: 1.2;
}

.profit-filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  margin-bottom: 26px;
}

.profit-filter-row .profit-controls {
  grid-column: 3 / 5;
  margin-left: 0;
}

.pair-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background-color: var(--accent);
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: calc(100% - 11px) 12px, calc(100% - 7px) 12px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  color: #fff;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  padding: 5px 22px 5px 10px;
  text-overflow: ellipsis;
}

.period-chip {
  width: 100%;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  background: var(--panel-soft);
  color: var(--muted);
}

.period-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.profit-controls input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 400;
  color: var(--text);
  background: var(--panel);
  text-align: right;
}

.profit-date-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}

.profit-controls.all-time input {
  background: #edf1f4;
  color: var(--muted);
}

.profit-table-scroll {
  max-height: 214px;
  overflow: auto;
  border: 0;
  border-radius: 0;
}

.profit-table-scroll table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.profit-card {
  padding: 16px 16px 14px;
  overflow: hidden;
}

.profit-card table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 14px;
}

.profit-card th,
.profit-card td {
  border-bottom: 0;
  padding: 0;
  line-height: 1.2;
}

#tab-profit table th,
#tab-profit table td {
  text-align: left;
}

.profit-summary-card th {
  font-size: 12px;
}

.profit-summary-card td {
  font-size: 11px;
}

.profit-summary-table tbody tr:last-child td {
  padding-bottom: 30px;
}

.profit-summary-card th:first-child,
.profit-summary-card td:first-child {
  width: 26%;
}

.profit-summary-card th:nth-child(2),
.profit-summary-card td:nth-child(2),
.profit-summary-card th:nth-child(3),
.profit-summary-card td:nth-child(3),
.profit-summary-card th:nth-child(4),
.profit-summary-card td:nth-child(4) {
  width: 24.666%;
}

.trading-cycles-card th {
  font-size: 12px;
}

.trading-cycles-card td {
  font-size: 11px;
}

.trading-cycles-card th:first-child,
.trading-cycles-card td:first-child {
  width: 15%;
}

.trading-cycles-card th:nth-child(2),
.trading-cycles-card td:nth-child(2),
.trading-cycles-card th:nth-child(3),
.trading-cycles-card td:nth-child(3) {
  width: 28%;
}

.trading-cycles-card th:nth-child(4),
.trading-cycles-card td:nth-child(4) {
  width: 10%;
}

.trading-cycles-card th:nth-child(5),
.trading-cycles-card td:nth-child(5) {
  width: 19%;
}

.trading-cycles-card td span {
  display: block;
}

.profit-table-scroll tfoot td {
  position: sticky;
  bottom: 0;
  border-top: 0;
  background: var(--panel);
  font-weight: 800;
}

.mini-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.mini-pill.ready {
  background: var(--danger-soft);
  border-color: #f5b5ad;
  color: var(--danger);
}

.rebuy-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rebuy-grid div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.rebuy-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.rebuy-grid strong {
  display: block;
  border-radius: 10px;
  margin: -3px;
  padding: 3px;
  font-size: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

td,
strong {
  transition: background-color 0.5s ease, color 0.5s ease;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.positive {
  color: var(--positive);
  font-weight: 800;
}

.negative {
  color: var(--danger);
  font-weight: 800;
}

.active-order td:first-child {
  color: inherit;
  font-weight: inherit;
}

.empty {
  color: var(--muted);
  text-align: center !important;
}

.notice,
.alert {
  border: 1px solid #f4c37d;
  background: #fff8eb;
  color: #6b4700;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

/* ── Страница ключей MEXC ─────────────────────────────────────────────── */
.keys-panel {
  gap: 14px;
  padding: 22px;
}

.keys-head {
  display: grid;
  gap: 6px;
}

.keys-head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.keys-back {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.keys-back:hover {
  text-decoration: underline;
}

.keys-head .muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.keys-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.keys-status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--muted);
}

.keys-status.ok {
  background: #e7f6ef;
  border-color: #b9e4cf;
}

.keys-status.ok .keys-status-dot {
  background: var(--positive);
  box-shadow: 0 0 0 3px #d5f0e2;
}

.keys-status.off,
.keys-status.none {
  background: #fff0ee;
  border-color: #ffd2cc;
}

.keys-status.off .keys-status-dot,
.keys-status.none .keys-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px #ffdcd7;
}

.keys-status b {
  display: block;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-all;
}

.keys-status small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.keys-msg {
  margin: 0;
  font-size: 13px;
  padding: 10px 13px;
}

.keys-form {
  display: grid;
  gap: 12px;
}

.keys-field {
  display: grid;
  gap: 5px;
}

.keys-field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.keys-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
}

.keys-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 103, 110, 0.14);
}

.keys-form .checkbox-row {
  font-size: 12px;
}

.keys-submit {
  width: 100%;
  min-height: 44px;
}

.keys-help {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.keys-help > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 13px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.keys-help > summary::-webkit-details-marker {
  display: none;
}

.keys-help[open] > summary {
  border-bottom: 1px solid var(--line);
}

.keys-help ol {
  margin: 10px 0;
  padding: 0 13px 0 30px;
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.4;
}

.keys-help > .muted {
  margin: 0;
  padding: 0 13px 12px;
  font-size: 12px;
  line-height: 1.4;
}

.keys-delete {
  display: grid;
}

.keys-delete button {
  width: 100%;
  min-height: 40px;
}

/* ── Админка: серверные метрики (htop-стиль) + список пользователей ──── */
.admin-page {
  display: grid;
  gap: 16px;
}

.admin-page .panel h2 {
  margin: 0 0 4px;
}

.sys-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.sys-status .muted {
  margin: 0;
}

.sys-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.sys-metric {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sys-metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sys-metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sys-metric-pct {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sys-bar {
  height: 10px;
  border-radius: 999px;
  background: #e3e9ee;
  overflow: hidden;
}

.sys-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.45s ease, background-color 0.45s ease;
}

.sys-bar.warn i {
  background: #d98a00;
}

.sys-bar.crit i {
  background: var(--danger);
}

.sys-metric-value {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sys-load {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sys-load[hidden] {
  display: none;
}

.sys-load-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sys-load-values {
  display: flex;
  gap: 18px;
}

.sys-load-values span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.sys-load-values b {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.sys-load-values b.warn {
  color: #d98a00;
}

.sys-load-values b.crit {
  color: var(--danger);
}

.admin-add-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.admin-add-form > label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.admin-add-form input[type="text"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 8px 12px;
}

/* checkbox-row внутри grid-формы должен остаться flex (иначе чекбокс и подпись разъезжаются). */
.admin-add-form > label.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.admin-add-form button {
  justify-self: start;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.user-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.user-card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.user-id {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.user-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge.admin,
.badge.ok {
  background: #e7f6ef;
  border-color: #b9e4cf;
  color: var(--accent);
}

.badge.blocked {
  background: #fff0ee;
  border-color: #ffd2cc;
  color: var(--danger);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-actions form {
  display: inline;
}

.user-actions button {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12px;
}

@media (max-width: 880px) {
  .summary-grid,
  .content-grid,
  .rebuy-grid {
    grid-template-columns: 1fr;
  }

  .sys-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar {
    grid-template-columns: minmax(108px, 1fr) minmax(188px, auto);
    gap: 5px;
    margin-bottom: 10px;
  }

  .auth-panel h1 {
    font-size: 26px;
  }

  .brand-lockup {
    gap: 3px;
  }

  .brand-mark {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .brand-mark::before {
    left: 6px;
    bottom: 5px;
    height: 6px;
    width: 3px;
  }

  .brand-mark span {
    left: 10px;
    bottom: 5px;
    height: 10px;
    width: 3px;
  }

  .brand-mark::after {
    left: 14px;
    bottom: 5px;
    height: 13px;
    width: 3px;
  }

  .eyebrow {
    font-size: clamp(13px, 4.8vw, 18px);
  }

  .account-strip {
    grid-template-columns: repeat(2, minmax(0, 92px));
    width: auto;
    gap: 4px;
    justify-self: end;
  }

  .account-strip div {
    padding: 5px 4px;
  }

  .account-strip span {
    font-size: 10px;
  }

  .account-strip strong {
    font-size: 10px;
  }

  .topbar .icon-link {
    min-height: 30px;
    padding: 6px 6px;
    font-size: clamp(10px, 2.8vw, 12px);
  }

  .topbar .live-pill {
    width: 10px;
    height: 10px;
    min-height: 10px;
    flex-basis: 10px;
  }

  .tabs {
    gap: 6px;
  }

  .tab-button {
    min-height: 38px;
    padding: 6px 4px;
    font-size: clamp(13px, 4.4vw, 24px);
  }

  .pair-grid {
    grid-template-columns: 1fr;
  }

  .overview-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .trade-overview-card {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 14px 10px;
  }

  .settings-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .trade-overview-card section:last-of-type h2 {
    text-align: left;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-meta {
    margin-left: 0;
  }
}

/* ── Лендинг (страница входа) и онбординг ─────────────────────────────── */
.landing-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.landing-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 32px;
  display: grid;
  gap: 22px;
}

.landing-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.landing-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--positive-soft);
  color: var(--accent-strong);
  border: 1px solid #b9e4cf;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.landing-lead h1 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.12;
}

.landing-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.landing-features li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
  gap: 10px;
  font-size: 15px;
  line-height: 1.4;
}

.landing-feature-ico {
  font-size: 20px;
  line-height: 1.2;
}

.landing-referral {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.landing-referral-title {
  margin: 0;
  font-weight: 800;
  font-size: 16px;
}

.landing-referral-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.landing-code {
  color: var(--muted);
  font-size: 14px;
}

.landing-code b {
  color: var(--text);
  letter-spacing: 0.5px;
}

.landing-login {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.landing-login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Кнопка-ссылка (анкор в стиле основной кнопки) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 16px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.onboarding-question {
  display: grid;
  gap: 14px;
}

.onboarding-q-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.onboarding-options {
  display: grid;
  gap: 12px;
}

.onboarding-options form {
  margin: 0;
}

.onboarding-option {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  min-height: 64px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.onboarding-option:hover {
  border-color: var(--accent);
  background: var(--panel-soft);
}

.onboarding-option-ico {
  font-size: 24px;
}

.onboarding-option-text {
  display: grid;
  gap: 2px;
  font-weight: 700;
}

.onboarding-option-text .muted {
  margin: 0;
  font-weight: 400;
  font-size: 13px;
}

.onboarding-next {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--accent);
}
