:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f3f3f3;
  --ink: #0a0c0c;
  --text: #141414;
  --muted: #6b6b6b;
  --border: #e4e4e4;
  --border-strong: #d0d0d0;
  --red: #f01f01;
  --red-hover: #d41a01;
  --red-soft: rgba(240, 31, 1, 0.08);
  --sidebar-bg: #0a0c0c;
  --sidebar-text: #f5f5f5;
  --sidebar-muted: #a3a3a3;
  --shadow: 0 1px 3px rgba(10, 12, 12, 0.06), 0 4px 16px rgba(10, 12, 12, 0.04);
  --shadow-lg: 0 8px 32px rgba(10, 12, 12, 0.12);
  --sidebar-w: 232px;
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.nav-open { overflow: hidden; }

#app-screen[hidden],
#auth-screen[hidden],
#reset-screen[hidden] {
  display: none !important;
}

#app-screen {
  height: 100%;
  height: 100dvh;
  display: flex;
}

/* ——— Sidebar (чёрная полоса как на эмблеме) ——— */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: none;
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-brand {
  padding: 4px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.brand-logo {
  display: block;
  width: auto;
  max-width: min(220px, calc(100vw - 4rem));
  height: auto;
  margin: 0 auto 12px;
}

.brand-logo--sidebar {
  max-width: calc(var(--sidebar-w) - 40px);
  margin: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item--action {
  color: var(--sidebar-text);
  font-size: 0.9rem;
}

.nav-item--action[data-enabled="1"] {
  color: #ffb4a8;
}

/* Push toggle — компактная строка в footer */
.push-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.push-toggle__info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.push-toggle__label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--sidebar-text);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.push-toggle__status {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  position: relative;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.push-toggle__status::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 5px;
  height: 9px;
  border: solid transparent;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.6);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.push-toggle.is-on .push-toggle__status {
  border-color: rgba(74, 222, 128, 0.85);
  background: rgba(74, 222, 128, 0.12);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.15);
}

.push-toggle.is-on .push-toggle__status::after {
  border-color: #4ade80;
  opacity: 1;
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.push-toggle.is-off .push-toggle__status {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.push-toggle__btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.push-toggle__btn[hidden] {
  display: none !important;
}

.push-toggle__btn span {
  display: block;
  margin-top: -1px;
}

.push-toggle__btn:active:not(:disabled) {
  transform: scale(0.94);
}

.push-toggle__btn:disabled {
  opacity: 0.45;
  cursor: wait;
}

.push-toggle__btn--off {
  color: #ffb4a8;
  background: rgba(240, 31, 1, 0.12);
}

.push-toggle__btn--off:hover {
  background: rgba(240, 31, 1, 0.22);
  color: #ffd4cc;
}

.push-toggle__btn--on {
  color: #86efac;
  background: rgba(74, 222, 128, 0.12);
}

.push-toggle__btn--on:hover {
  background: rgba(74, 222, 128, 0.22);
  color: #bbf7d0;
}

.push-toggle.is-busy {
  opacity: 0.72;
  pointer-events: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: rgba(240, 31, 1, 0.14);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--red);
}

/* ——— Main area ——— */
.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view-scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.view-scroller-inner {
  will-change: transform;
}

.pull-refresh {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  pointer-events: none;
  transition: height 0.2s ease;
}

.pull-refresh.is-pulling {
  transition: none;
}

.pull-refresh.is-refreshing {
  height: 52px !important;
}

.pull-refresh__spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--red);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s;
}

.pull-refresh.is-ready .pull-refresh__spinner,
.pull-refresh.is-refreshing .pull-refresh__spinner {
  opacity: 1;
}

.pull-refresh.is-refreshing .pull-refresh__spinner {
  animation: pull-spin 0.7s linear infinite;
}

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

.pull-refresh.is-ready .pull-refresh__label {
  color: var(--red);
  font-weight: 600;
}

.pull-refresh.is-refreshing .pull-refresh__label {
  color: var(--muted);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.top-title { flex: 1; min-width: 0; }

.top h1, #page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.top p, #status {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 12, 0.45);
  z-index: 25;
}

.view { flex: 1; min-height: 0; }
.view[hidden] { display: none !important; }

/* ——— Buttons ——— */
button[type="submit"], #auth-submit {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-top: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button[type="submit"]:hover, #auth-submit:hover {
  background: var(--red-hover);
}

button[type="submit"]:active, #auth-submit:active {
  transform: scale(0.99);
}

.link-btn {
  background: none;
  border: none;
  color: var(--red);
  padding: 8px 0;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--red-hover);
  text-decoration: underline;
}

/* ——— Auth ——— */
.auth-screen {
  position: relative;
  z-index: 40;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(240, 31, 1, 0.07), transparent),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1, .auth-card .auth-heading {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.auth-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.auth-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  touch-action: manipulation;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.auth-message {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-message.error { color: var(--red); }

/* ——— TradeBotUI notifications ——— */
.chat {
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: min(100%, calc(100dvh - 120px));
  max-width: 720px;
}

.msg {
  max-width: 92%;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}

.msg__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.msg-push {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.msg-push--delivered {
  background: rgba(46, 204, 113, 0.14);
  color: #1a8f4a;
}

.msg-push--pending {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.msg-push--failed {
  background: rgba(240, 31, 1, 0.12);
  color: var(--red);
}

.msg time {
  display: block;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.msg p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 28vh;
  font-size: 0.95rem;
}

/* ——— Status dashboard ——— */
.status-dashboard {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 960px;
}

.status-dashboard h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.status-dashboard h2 {
  font-size: 1.05rem;
  margin: 28px 0 10px;
  color: var(--ink);
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--red);
  display: inline-block;
}

.status-dashboard h3 {
  font-size: 0.95rem;
  margin: 16px 0 8px;
  color: var(--muted);
  font-weight: 600;
}

.status-dashboard p {
  margin: 8px 0;
  color: var(--text);
}

.status-dashboard blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--red);
  background: var(--surface-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
}

.status-dashboard ul {
  margin: 8px 0;
  padding-left: 1.2rem;
}

.status-dashboard li { margin: 6px 0; }

.status-dashboard code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--ink);
}

.md-table-wrap {
  overflow-x: auto;
  margin: 10px 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 520px;
}

.md-table th,
.md-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.md-table th {
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
}

.md-table tr:last-child td { border-bottom: none; }

.status-raw {
  white-space: pre-wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ——— Balance dashboard ——— */
.balance-dashboard {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 1040px;
}

.bal-dash {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bal-skeleton {
  border-radius: var(--radius-lg);
  background: linear-gradient(
    90deg,
    var(--surface-muted, #ececec) 0%,
    #f8f8f8 45%,
    var(--surface-muted, #ececec) 90%
  );
  background-size: 200% 100%;
  animation: bal-skeleton-shimmer 1.2s ease-in-out infinite;
}

.bal-skeleton--hero {
  min-height: 168px;
}

.bal-skeleton--bar {
  min-height: 56px;
}

@keyframes bal-skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.bal-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1a1d1d 55%, #2a1512 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.bal-hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 31, 1, 0.22), transparent 70%);
  pointer-events: none;
}

.bal-hero--split {
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
}

.bal-hero__equity-groups {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bal-hero__equity {
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 0;
}

.bal-hero__equity--live {
  border-color: rgba(240, 31, 1, 0.35);
}

.bal-hero__equity--paper {
  border-color: rgba(96, 165, 250, 0.35);
}

.bal-hero__equity .bal-hero__value {
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
}

.bal-hero__details {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.58);
  line-height: 1.45;
}

.bal-hero__details li + li {
  margin-top: 4px;
}

.bal-hero__main {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.bal-hero__label {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.bal-hero__value {
  margin: 0;
  font-size: clamp(1.85rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.bal-hero__pnl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.bal-hero__pnl.positive {
  color: #7dffb0;
  background: rgba(46, 204, 113, 0.16);
}

.bal-hero__pnl.negative {
  color: #ff9b8a;
  background: rgba(240, 31, 1, 0.2);
}

.bal-hero__pnl.neutral {
  color: rgba(255, 255, 255, 0.85);
}

.bal-hero__pct {
  opacity: 0.9;
  font-weight: 600;
}

.bal-hero__pct--na {
  opacity: 0.55;
}

.bal-hero__baseline {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
}

.bal-hero__stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.bal-hero__stats-groups {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 280px;
  min-width: 0;
}

.bal-hero__stats-group {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bal-hero__stats-group--live {
  border-color: rgba(240, 31, 1, 0.28);
}

.bal-hero__stats-group--paper {
  border-color: rgba(96, 165, 250, 0.28);
}

.bal-hero__stats-heading {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bal-hero__stats-group--live .bal-hero__stats-heading {
  color: #ff9b8a;
}

.bal-hero__stats-group--paper .bal-hero__stats-heading {
  color: #93c5fd;
}

.bal-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 74px;
  padding: 10px 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

button.bal-stat-pill:hover,
button.bal-stat-pill:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
}

button.bal-stat-pill:active {
  transform: scale(0.97);
}

.bal-stat-pill--live {
  border-color: rgba(240, 31, 1, 0.35);
}

.bal-stat-pill--paper {
  border-color: rgba(96, 165, 250, 0.35);
}

button.bal-stat-pill--live:hover,
button.bal-stat-pill--live:focus-visible {
  border-color: rgba(240, 31, 1, 0.55);
  background: rgba(240, 31, 1, 0.12);
}

button.bal-stat-pill--paper:hover,
button.bal-stat-pill--paper:focus-visible {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(96, 165, 250, 0.12);
}

.bal-subsection {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.bal-subsection:first-of-type {
  margin-top: 0;
}

.bal-subsection--live {
  border-left: 3px solid rgba(240, 31, 1, 0.55);
}

.bal-subsection--paper {
  border-left: 3px solid rgba(37, 99, 235, 0.55);
}

.bal-subsection__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.bal-jump-target.bal-section--highlight {
  animation: bal-section-flash 1.4s ease;
}

@keyframes bal-section-flash {
  0%, 100% {
    box-shadow: var(--shadow);
    border-color: var(--border);
  }
  20%, 45% {
    box-shadow: 0 0 0 3px rgba(240, 31, 1, 0.28);
    border-color: rgba(240, 31, 1, 0.45);
  }
}

.bal-stat-pill__val {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.bal-stat-pill__lbl {
  margin-top: 4px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}

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

.bal-kpi-grid--live .bal-kpi--live {
  border-left: 3px solid rgba(240, 31, 1, 0.45);
}

.bal-kpi-grid--paper .bal-kpi--paper {
  border-left: 3px solid rgba(37, 99, 235, 0.45);
}

.bal-panel--kpi .bal-panel__title {
  margin-bottom: 12px;
}

.bal-kpi {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.bal-kpi__label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bal-kpi__value {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.bal-kpi__hint {
  margin: 6px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.bal-panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.bal-panel__title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--red);
  display: inline-block;
}

.bal-panel__subtitle {
  margin: -6px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.bal-glossary {
  margin-bottom: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.bal-glossary summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  user-select: none;
  list-style: none;
}

.bal-glossary summary::-webkit-details-marker {
  display: none;
}

.bal-glossary summary::before {
  content: "▸ ";
  color: var(--red);
}

.bal-glossary[open] summary::before {
  content: "▾ ";
}

.bal-glossary__body {
  padding: 0 14px 14px;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.5;
}

.bal-glossary__lead {
  margin: 10px 0 6px;
  font-weight: 700;
  color: var(--ink);
}

.bal-glossary__lead:first-child {
  margin-top: 0;
}

.bal-glossary__list {
  margin: 0 0 8px;
  padding-left: 18px;
}

.bal-glossary__list li {
  margin-bottom: 6px;
}

.bal-glossary__note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
}

.bal-hint {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 400;
}

.bal-term {
  min-width: 0;
  flex: 1;
  padding-right: 8px;
}

.bal-mode-pnl__title-wrap {
  min-width: 0;
  flex: 1;
}

.bal-mode-pnl__desc {
  margin: 4px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 400;
}

.bal-panel--pnl {
  border-color: rgba(240, 31, 1, 0.18);
}

.bal-mode-pnl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.bal-mode-pnl {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.bal-mode-pnl--total {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(240, 31, 1, 0.06), rgba(240, 31, 1, 0.02));
  border-color: rgba(240, 31, 1, 0.22);
}

.bal-mode-pnl__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.bal-mode-pnl__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.bal-mode-pnl__rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bal-mode-pnl__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

.bal-mode-pnl__row--now {
  padding-bottom: 8px;
  margin-bottom: 2px;
  border-bottom: 1px dashed var(--border);
}

.bal-mode-pnl__row--now .bal-pnl {
  font-size: 1.05rem;
}

.bal-mode-pnl__lbl {
  color: var(--muted);
  font-weight: 500;
}

.bal-mode-pnl__count {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.bal-pos-card__pnl {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.bal-pos-card__pnl-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.bal-pos-card__pnl-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bal-pos-card__pnl-value {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.bal-pos-card__pnl-main.positive .bal-pos-card__pnl-value {
  color: #1a8f4a;
}

.bal-pos-card__pnl-main.negative .bal-pos-card__pnl-value {
  color: var(--red);
}

.bal-pos-card__pnl-main.neutral .bal-pos-card__pnl-value {
  color: var(--ink);
}

.bal-pos-card__pnl-move {
  font-size: 0.78rem;
  color: var(--muted);
}

.bal-pos-card__pnl-scenarios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bal-pos-card__pnl-scenario {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
}

.bal-pos-card__pnl-scenario-lbl {
  color: var(--muted);
  font-weight: 500;
}

.bal-pos-card__details {
  margin-top: 4px;
}

.bal-pos-card__details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.bal-pos-card__details .bal-pos-card__stats {
  margin-top: 10px;
}

.bal-alloc__bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-muted);
  margin-bottom: 14px;
}

.bal-alloc__seg {
  min-width: 4px;
  transition: width 0.3s ease;
}

.bal-alloc__seg--grid { background: #f01f01; }
.bal-alloc__seg--live { background: #059669; }
.bal-alloc__seg--spot { background: #2563eb; }
.bal-alloc__seg--futures { background: #7c3aed; }

.bal-alloc__legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bal-alloc__item {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 0.88rem;
}

.bal-alloc__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.bal-alloc__dot--grid { background: #f01f01; }
.bal-alloc__dot--spot { background: #2563eb; }
.bal-alloc__dot--futures { background: #7c3aed; }

.bal-alloc__name {
  color: var(--text);
  font-weight: 500;
}

.bal-alloc__val {
  font-weight: 700;
  color: var(--ink);
}

.bal-alloc__pct {
  color: var(--muted);
  font-size: 0.82rem;
  min-width: 3.5rem;
  text-align: right;
}

.bal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bal-meta__item {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.bal-lazy-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  background: var(--surface-muted);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.bal-segment {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.bal-segment__head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.bal-segment__titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bal-segment__title {
  font-weight: 600;
  font-size: 0.95rem;
}

.bal-segment__hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.bal-segment__status {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.bal-segment__chev {
  font-size: 1.2rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.bal-segment.is-open .bal-segment__chev {
  transform: rotate(90deg);
}

.bal-segment__body {
  padding: 0 12px 14px;
  border-top: 1px solid var(--border);
}

.bal-segment__loading {
  margin: 12px 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.bal-segment__body .bal-panel {
  margin-top: 12px;
  box-shadow: none;
  border: none;
  padding-left: 0;
  padding-right: 0;
}

.bal-pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.bal-pos-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.bal-pos-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.bal-pos-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.bal-pos-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0;
}

.bal-pos-card__stats div {
  min-width: 0;
}

.bal-pos-card__stats dt {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bal-pos-card__stats dd {
  margin: 2px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.bal-pair {
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.bal-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bal-badge--mode {
  background: var(--surface-muted);
  color: var(--ink);
}

.bal-badge--live {
  background: rgba(240, 31, 1, 0.12);
  color: var(--red);
}

.bal-badge--paper {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.bal-badge--side-long,
.bal-badge--side-buy {
  background: rgba(46, 204, 113, 0.14);
  color: #1a8f4a;
}

.bal-badge--side-short,
.bal-badge--side-sell {
  background: rgba(240, 31, 1, 0.12);
  color: var(--red);
}

.bal-grid-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bal-grid-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--ink);
}

.bal-grid-chip em {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.bal-grid-chip--grid {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.bal-grid-chip--sell-only {
  background: rgba(234, 88, 12, 0.12);
  color: #c2410c;
}

.bal-panel__count {
  font-weight: 500;
  font-size: 0.85em;
  color: var(--muted);
}

.bal-badge--side-close {
  background: var(--surface-muted);
  color: var(--muted);
}

.bal-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.bal-table-wrap--scroll {
  max-height: 420px;
  overflow-y: auto;
}

.bal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 560px;
}

.bal-table th,
.bal-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.bal-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bal-table tr:last-child td {
  border-bottom: none;
}

.bal-table tbody tr:hover {
  background: rgba(240, 31, 1, 0.03);
}

.bal-ts {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.bal-pnl.positive {
  color: #1a8f4a;
  font-weight: 700;
}

.bal-pnl.negative {
  color: var(--red);
  font-weight: 700;
}

.bal-pnl.neutral {
  color: var(--muted);
}

.bal-empty-inline {
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* ——— Transaction journal ——— */
.journal-dashboard {
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
}

.journal-dash {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.journal-filters {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--surface-2, #f3f4f6);
  border-radius: 12px;
}

.journal-filter {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.journal-filter--active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.journal-filter__count {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.65;
}

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.journal-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.journal-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.journal-card--buy .journal-card__icon {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

.journal-card--sell .journal-card__icon {
  background: rgba(240, 31, 1, 0.1);
  color: #f01f01;
}

.journal-card--close .journal-card__icon {
  background: rgba(107, 114, 128, 0.12);
  color: #6b7280;
}

.journal-card--pending .journal-card__icon {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.journal-card__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.journal-card__row--meta {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
}

.journal-card__coin {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.journal-card__action {
  font-size: 0.875rem;
  color: var(--text);
}

.journal-card__pending {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.journal-card__pnl {
  margin-left: auto;
  font-weight: 600;
}

.journal-card__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 52px;
}

.journal-card__badge {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 6px;
  border-radius: 6px;
}

.journal-card__badge--live {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
}

.journal-card__badge--paper {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.journal-card__time {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.journal-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.journal-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 4px;
  flex-wrap: wrap;
}

.journal-pager__btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.journal-pager__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.journal-pager__btn:not(:disabled):active {
  background: var(--surface-2, #f3f4f6);
}

.journal-pager__info {
  font-weight: 700;
  font-size: 0.9375rem;
  min-width: 4rem;
  text-align: center;
}

.journal-pager__total {
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ——— Успехи (round-trip PnL) ——— */
.wins-dashboard {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
}

.wins-dash {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wins-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.wins-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.wins-summary__item {
  padding: 12px 10px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}

.wins-summary__label {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.wins-summary__value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.wins-summary__value.positive { color: #15803d; }
.wins-summary__value.negative { color: var(--red); }

.wins-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wins-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

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

.wins-filter__count {
  font-size: 0.75rem;
  opacity: 0.85;
}

.wins-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.win-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.win-card--gain {
  border-left: 4px solid #15803d;
}

.win-card--loss {
  border-left: 4px solid var(--red);
}

.win-card__main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.win-card__pnl {
  font-size: 1.375rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.win-card__pnl.positive { color: #15803d; }
.win-card__pnl.negative { color: var(--red); }

.win-card__result {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 600;
}

.win-card__time {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.win-card__meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.wins-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.wins-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 8px;
}

.wins-pager__btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.125rem;
}

.wins-pager__btn:disabled {
  opacity: 0.4;
}

.wins-pager__info {
  font-weight: 700;
  min-width: 4rem;
  text-align: center;
}

.wins-pager__total {
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ——— ML / Neural network dashboard ——— */
.ml-dashboard {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 1040px;
}

.ml-dash {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ml-hero {
  padding: 24px;
  border-radius: var(--radius-lg);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

.ml-hero--excellent {
  background: linear-gradient(135deg, #0f3d2e 0%, #14532d 45%, #166534 100%);
}

.ml-hero--good {
  background: linear-gradient(135deg, #1e3a5f 0%, #1d4ed8 55%, #2563eb 100%);
}

.ml-hero--bad {
  background: linear-gradient(135deg, #713f12 0%, #b45309 55%, #d97706 100%);
}

.ml-hero--very_bad {
  background: linear-gradient(135deg, #450a0a 0%, #991b1b 55%, #dc2626 100%);
}

.ml-hero__eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.ml-hero__verdict {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.15;
}

.ml-hero__emoji {
  margin-right: 8px;
}

.ml-hero__summary,
.ml-hero__training {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  opacity: 0.92;
}

.ml-hero__training {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.88rem;
  opacity: 0.85;
}

.ml-panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--border);
}

.ml-panel__title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
}

.ml-reasons {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
  line-height: 1.5;
}

.ml-reasons li + li {
  margin-top: 8px;
}

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

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

.ml-kpi {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.ml-kpi__label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.ml-kpi__value {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.ml-kpi__hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.ml-trend--ok { color: #15803d; }
.ml-trend--info { color: #1d4ed8; }
.ml-trend--warn { color: #b45309; }

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

.ml-model {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.ml-model--active {
  border-color: #86efac;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15);
}

.ml-model__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ml-model__head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.ml-model__subtitle {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
}

.ml-model__purpose {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
}

.ml-model__goal {
  margin: 0 0 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.ml-model__goal strong {
  color: var(--text);
  font-weight: 600;
}

.ml-model__metric {
  margin: 0 0 6px;
  font-size: 0.92rem;
}

.ml-model__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.ml-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.ml-badge--ok {
  background: #dcfce7;
  color: #166534;
}

.ml-badge--active {
  background: #bbf7d0;
  color: #14532d;
}

.ml-badge--warn {
  background: #fef3c7;
  color: #92400e;
}

.ml-badge--muted {
  background: var(--muted-bg, rgba(128, 128, 128, 0.15));
  color: var(--muted-fg, #888);
}

.ml-badge--bootstrap {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.ml-model--bootstrap {
  border-color: rgba(245, 158, 11, 0.35);
}

.ml-model__grid-status {
  margin: 0.65rem 0 0.5rem;
}

.ml-model__grid-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.ml-model__grid-hint,
.ml-model__grid-warn {
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0.35rem 0 0;
  color: var(--text-muted, #8a8a8a);
}

.ml-model__grid-warn {
  color: #b45309;
}

.ml-grid-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
  overflow: hidden;
}

.ml-grid-progress__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.3s ease;
}

.ml-grid-progress--ok .ml-grid-progress__fill {
  background: #22c55e;
}

.ml-grid-progress--bootstrap .ml-grid-progress__fill {
  background: #f59e0b;
}

.ml-grid-progress--warn .ml-grid-progress__fill {
  background: #ef4444;
}

.ml-panel--grid-status .ml-grid-hero {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.ml-grid-hero__hint {
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0;
  color: var(--text-muted, #8a8a8a);
}

.ml-panel__hint {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.ml-hero__training--sub {
  margin-top: 6px;
  font-size: 0.82rem;
  opacity: 0.85;
}

.ml-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.ml-mode-grid--summary {
  grid-template-columns: 1fr;
}

.ml-mode-card {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.ml-mode-card__title {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.ml-mode-card__purpose {
  margin: -4px 0 8px;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

.ml-mode-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 0.78rem;
}

.ml-mode-card__stats span {
  display: block;
  color: var(--muted);
}

.ml-mode-card__stats strong {
  font-size: 0.86rem;
}

.ml-pnl--pos { color: #15803d; }
.ml-pnl--neg { color: #b91c1c; }

.ml-glossary {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(240, 31, 1, 0.06);
  border: 1px solid rgba(240, 31, 1, 0.12);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.ml-glossary p {
  margin: 0;
}

@media (min-width: 640px) {
  .bal-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .balance-dashboard {
    padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
  }

  .ml-dashboard {
    padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
  }

  .ml-models {
    grid-template-columns: 1fr;
  }

  .bal-hero {
    padding: 18px;
  }

  .bal-hero__equity-groups {
    grid-template-columns: 1fr;
  }

  .bal-hero__stats {
    width: 100%;
  }

  .bal-stat-pill {
    min-height: 70px;
  }

  .bal-hero__stats-groups {
    width: 100%;
  }

  .bal-panel {
    padding: 14px;
  }

  .bal-mode-pnl-grid {
    grid-template-columns: 1fr;
  }

  .bal-pos-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  #app-screen {
    display: flex;
    flex-direction: row;
  }
  .app-main {
    flex: 1;
    min-height: 0;
  }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-backdrop:not([hidden]) { display: block; }
  .sidebar-brand { display: block; }
  .brand-logo--sidebar { max-width: 160px; }
}

@media (min-width: 768px) {
  .nav-toggle { display: none !important; }
  .sidebar-brand { display: block; }
}

/* ——— Feedback iterations ——— */
.feedback-dashboard {
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 720px;
}

.fb-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fb-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.fb-card--cursor {
  border-color: rgba(22, 163, 74, 0.25);
}

.fb-card--offline,
.fb-card--skipped {
  border-color: rgba(234, 179, 8, 0.35);
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.05) 0%, var(--surface) 40%);
}

.fb-card--failed {
  border-color: rgba(240, 31, 1, 0.3);
}

.fb-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.fb-card__time {
  font-size: 0.82rem;
  color: var(--muted);
}

.fb-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fb-badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.fb-badge--cursor {
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.3);
  color: #15803d;
}

.fb-badge--offline,
.fb-badge--skipped {
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(234, 179, 8, 0.35);
  color: #a16207;
}

.fb-badge--failed {
  background: var(--red-soft);
  border-color: rgba(240, 31, 1, 0.3);
  color: #b91c1c;
}

.fb-badge--task {
  background: var(--sidebar-bg);
  color: #fff;
  border-color: transparent;
}

.fb-badge--muted {
  color: var(--muted);
  background: transparent;
}

.fb-card__headline {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.fb-card__net {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.fb-card__reason {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.25);
  font-size: 0.85rem;
  color: #92400e;
}

.fb-card__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fb-card__section {
  margin: 10px 0 4px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
}

.fb-card__section:first-child {
  margin-top: 0;
}

.fb-card__line,
.fb-card__lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.fb-card__empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.fb-card__foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.fb-card__commit {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.fb-card__commit code {
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
}
