:root {
  --bg: #0b0e11;
  --panel: #181a20;
  --panel-soft: #1e2329;
  --line: #2b3139;
  --text: #eaecef;
  --muted: #848e9c;
  --gold: #f0b90b;
  --gold-soft: rgba(240, 185, 11, 0.14);
  --green: #0ecb81;
  --red: #f6465d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(240, 185, 11, 0.14), transparent 32%),
    linear-gradient(180deg, #11151b 0%, var(--bg) 34%, #07090c 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

h1,
h2,
p {
  margin: 0;
}

.terminal {
  width: min(1380px, calc(100vw - 360px));
  margin: 0 332px 0 14px;
  padding: 18px 0 34px;
  transition: width 0.2s ease, margin 0.2s ease;
}

body.logs-expanded .terminal {
  width: min(1164px, calc(100vw - 576px));
  margin-right: 548px;
}

body.logs-closed .terminal {
  width: min(1380px, calc(100vw - 28px));
  margin-right: 14px;
}

.topbar,
.brand,
.topbar-actions,
.hero-actions,
.panel-head {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.brand {
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  position: relative;
  display: block;
  border-radius: 12px;
  background: #f0b90b;
  box-shadow: 0 10px 30px rgba(240, 185, 11, 0.24);
}

.brand-mark i {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #0b0e11;
  transform: rotate(45deg);
}

.brand-mark i:nth-child(1) {
  left: 16px;
  top: 6px;
}

.brand-mark i:nth-child(2) {
  left: 16px;
  bottom: 6px;
}

.brand-mark i:nth-child(3) {
  left: 6px;
  top: 16px;
}

.brand-mark i:nth-child(4) {
  right: 6px;
  top: 16px;
}

.brand-mark i:nth-child(5) {
  left: 16px;
  top: 16px;
}

.brand b {
  display: block;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  min-width: 94px;
  padding: 9px 13px;
  border-radius: 999px;
  text-align: center;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid rgba(240, 185, 11, 0.22);
}

.topbar-actions {
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill[data-tone="good"] {
  color: #8ff2c8;
  background: rgba(14, 203, 129, 0.12);
  border-color: rgba(14, 203, 129, 0.22);
}

.status-pill[data-tone="bad"] {
  color: #ff9aa8;
  background: rgba(246, 70, 93, 0.12);
  border-color: rgba(246, 70, 93, 0.25);
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(255px, 0.76fr) minmax(190px, 0.48fr) minmax(320px, 0.92fr) minmax(350px, 1fr);
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
}

.hero-card,
.metric-card,
.metric-stack,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(30, 35, 41, 0.96), rgba(18, 22, 28, 0.96));
  box-shadow: var(--shadow);
}

.hero-card,
.metric-card,
.metric-stack {
  border-radius: 18px;
  padding: 12px;
}

.hero-card {
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -70px -95px auto;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 185, 11, 0.24), transparent 68%);
  pointer-events: none;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.hero-card h1 {
  font-size: clamp(22px, 2vw, 31px);
  line-height: 1.06;
  letter-spacing: -0.05em;
}

.formula-line {
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 12px;
  color: #f7d35c;
  background: rgba(240, 185, 11, 0.08);
  border: 1px solid rgba(240, 185, 11, 0.18);
  font-family: "JetBrains Mono", monospace;
  word-break: break-all;
}

.hero-actions {
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.primary,
.secondary,
.success,
.danger {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 800;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.primary:hover,
.secondary:hover,
.success:hover,
.danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.primary {
  background: linear-gradient(135deg, var(--gold), #ffd765);
  color: #101014;
}

.secondary {
  color: var(--text);
  background: #252b33;
  border: 1px solid #343b45;
}

.success {
  color: #06150f;
  background: linear-gradient(135deg, var(--green), #55e9b6);
}

.danger {
  color: #26070c;
  background: linear-gradient(135deg, var(--red), #ff8d7f);
}

.metric-card {
  display: grid;
  align-content: space-between;
  min-height: 116px;
}

.metric-stack {
  overflow: hidden;
}

.metric-stack .compact-head {
  margin-bottom: 8px;
}

.metric-strip {
  display: grid;
  gap: 6px;
}

.metric-mini {
  display: grid;
  gap: 3px;
  min-height: 53px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.metric-card span,
.metric-card small,
.metric-mini span,
.metric-mini small,
.field span,
.panel-head p,
.compact-head p,
.readout span,
.account-grid span,
.logs .muted {
  color: var(--muted);
}

.metric-card strong {
  margin: 8px 0;
  font-size: clamp(20px, 1.8vw, 28px);
  line-height: 1;
  word-break: break-word;
}

.metric-mini strong {
  font-size: 16px;
  line-height: 1.1;
  word-break: break-word;
}

.metric-mini small {
  font-size: 11px;
}

.quick-panel {
  margin-top: 10px;
}

.strategy-manager-panel {
  position: relative;
  margin-top: 10px;
}

.strategy-manager-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(240, 185, 11, 0.95), transparent);
  opacity: 0.68;
}

.strategy-manager-panel .panel-head {
  align-items: center;
}

.strategy-manager-panel .panel-head button {
  min-width: 116px;
}

.strategy-manager-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto minmax(120px, 0.25fr);
  gap: 10px;
  align-items: end;
  padding: 14px 22px 0;
}

.strategy-manager-toolbar button {
  min-height: 48px;
}

.manager-status {
  display: grid;
  gap: 5px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.manager-status span,
.running-strategy-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.profile-strategy-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 22px 22px;
}

.profile-strategy-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.08), transparent 54%),
    rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(240, 185, 11, 0.12);
}

.profile-strategy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.profile-strategy-head strong,
.profile-strategy-head span {
  display: block;
}

.profile-strategy-head strong {
  font-size: 16px;
  line-height: 1.35;
}

.profile-strategy-head span {
  margin-top: 4px;
  color: #f7d35c;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

.profile-strategy-head > b {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.profile-strategy-head b[data-tone="good"] {
  color: #8ff2c8;
  background: rgba(14, 203, 129, 0.12);
}

.profile-strategy-head b[data-tone="bad"] {
  color: #ff9aa8;
  background: rgba(246, 70, 93, 0.12);
}

.profile-strategy-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.profile-strategy-metrics div {
  display: grid;
  gap: 4px;
  min-height: 55px;
  padding: 8px 9px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.profile-strategy-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.profile-strategy-metrics b {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.profile-strategy-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-strategy-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.running-strategy-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 22px 22px;
}

.empty-strategies {
  grid-column: 1 / -1;
  padding: 18px;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px dashed rgba(240, 185, 11, 0.2);
}

.running-strategy-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.07), transparent 52%),
    rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.running-strategy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.running-strategy-head strong,
.running-strategy-head span {
  display: block;
}

.running-strategy-head strong {
  font-size: 16px;
  line-height: 1.35;
}

.running-strategy-head span {
  margin-top: 4px;
  color: #f7d35c;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

.running-strategy-head > b {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.running-strategy-head b[data-tone="good"] {
  color: #8ff2c8;
  background: rgba(14, 203, 129, 0.12);
}

.running-strategy-head b[data-tone="bad"] {
  color: #ff9aa8;
  background: rgba(246, 70, 93, 0.12);
}

.running-strategy-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.running-strategy-metrics div {
  display: grid;
  gap: 4px;
  min-height: 55px;
  padding: 8px 9px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.running-strategy-metrics b {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.running-strategy-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.panel {
  border-radius: 18px;
  overflow: hidden;
}

.config-dialog {
  width: min(1080px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: transparent;
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65);
}

.config-dialog::backdrop {
  background: rgba(2, 6, 10, 0.72);
  backdrop-filter: blur(8px);
}

.dialog-card {
  margin: 0;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(30, 35, 41, 0.98), rgba(16, 20, 25, 0.98));
  overflow: hidden;
}

.dialog-head,
.dialog-foot {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
}

.dialog-head {
  align-items: flex-start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dialog-head h2 {
  margin-top: 4px;
  font-size: 24px;
}

.dialog-head p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.panel-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.panel-head h2 {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin-top: 6px;
  line-height: 1.7;
}

.compact-card {
  padding: 10px;
}

.compact-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.compact-head h2 {
  flex: 0 0 auto;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.compact-head p {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.is-hidden {
  display: none !important;
}

.field span {
  font-size: 13px;
}

.threshold-quick {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.threshold-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.threshold-buttons button {
  min-width: 74px;
  min-height: 34px;
}

.threshold-input-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 8px;
}

.threshold-mode {
  padding: 0 10px;
}

.threshold-input-row input:disabled {
  color: rgba(234, 236, 239, 0.45);
  background: rgba(255, 255, 255, 0.035);
  border-style: dashed;
}

.threshold-quick small {
  color: var(--muted);
  font-size: 12px;
}

.formula-live-line {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  color: #f7d35c;
  background: rgba(240, 185, 11, 0.08);
  border: 1px solid rgba(240, 185, 11, 0.16);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #343b45;
  background: #0f141a;
  color: var(--text);
  outline: none;
}

select {
  color-scheme: dark;
}

input:focus,
select:focus {
  border-color: rgba(240, 185, 11, 0.72);
  box-shadow: 0 0 0 4px rgba(240, 185, 11, 0.12);
}

.side-panel {
  min-height: 0;
}

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

.readout div {
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.readout b {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.readout b[data-tone="good"] {
  color: #8ff2c8;
}

.readout b[data-tone="bad"] {
  color: #ff9aa8;
}

.connect-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

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

.connect-actions button,
.connect-strip input,
.connect-strip select {
  min-height: 36px;
}

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

.account-grid div {
  display: grid;
  gap: 4px;
  min-height: 52px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.account-grid b {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.quick-panel {
  position: relative;
}

.quick-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.72;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 0;
}

.quick-grid .field:nth-child(1) {
  grid-column: span 3;
}

.quick-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 22px 0;
}

.quick-preview div {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 14px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.08), transparent 48%),
    rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(240, 185, 11, 0.12);
}

.quick-preview span {
  color: var(--muted);
  font-size: 13px;
}

.quick-preview b {
  line-height: 1.45;
  word-break: break-word;
}

.quick-preview b[data-tone="good"] {
  color: #8ff2c8;
}

.quick-preview b[data-tone="bad"] {
  color: #ff9aa8;
}

.quick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px 22px;
}

.quick-actions button {
  min-width: 160px;
}

.positions-panel {
  margin-top: 10px;
}

.positions-panel .panel-head {
  align-items: center;
  padding: 10px 14px 8px;
}

.positions-panel .panel-head h2 {
  font-size: 17px;
}

.positions-panel .panel-head p {
  margin-top: 2px;
  line-height: 1.35;
  font-size: 12px;
}

.positions-panel .panel-head button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 12px;
}

.positions-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 0;
}

.positions-toolbar button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 12px;
}

.positions-toolbar div {
  display: grid;
  gap: 2px;
  min-width: 156px;
  margin-left: auto;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.positions-toolbar span,
.position-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.positions-toolbar b[data-tone="good"],
.position-metrics b[data-tone="good"] {
  color: #8ff2c8;
}

.positions-toolbar b[data-tone="bad"],
.position-metrics b[data-tone="bad"] {
  color: #ff9aa8;
}

.positions-list {
  display: grid;
  gap: 7px;
  padding: 10px 14px 0;
}

.empty-positions {
  padding: 18px;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

.position-card {
  display: grid;
  grid-template-columns: minmax(190px, 0.26fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.06), transparent 52%),
    rgba(255, 255, 255, 0.032);
  border: 1px solid rgba(255, 255, 255, 0.065);
}

.position-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
  min-width: 0;
  font-size: 14px;
}

.position-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--gold);
}

.position-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(104px, 1fr));
  gap: 6px;
}

.position-metrics div {
  display: grid;
  gap: 2px;
  min-height: 42px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.position-metrics b {
  line-height: 1.35;
  word-break: break-word;
  font-size: 13px;
}

.close-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.percent-field span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  min-height: 38px;
  padding: 0;
  accent-color: var(--gold);
  background: transparent;
  border: 0;
}

.logs-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  width: 304px;
  display: flex;
  flex-direction: column;
  margin-top: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 35, 41, 0.98), rgba(12, 15, 20, 0.98));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  transition: width 0.2s ease, box-shadow 0.2s ease;
}

body.logs-expanded .logs-panel {
  width: 520px;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.48);
}

body.logs-closed .logs-panel {
  display: none;
}

.logs-panel .panel-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px 12px 8px;
}

.logs-panel .panel-head h2 {
  font-size: 17px;
}

.logs-panel .panel-head p {
  margin-top: 2px;
  line-height: 1.35;
  font-size: 12px;
}

.log-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.log-toggle-btn {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(240, 185, 11, 0.14);
  border: 1px solid rgba(240, 185, 11, 0.35);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.log-toggle-btn:hover {
  background: rgba(240, 185, 11, 0.22);
}

.log-close-btn {
  min-width: 48px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.log-close-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.log-open-pill {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 21;
  display: none;
  padding: 11px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #ffd760);
  color: #0b0e11;
  font-size: 13px;
  font-weight: 950;
  box-shadow: 0 14px 42px rgba(240, 185, 11, 0.28);
}

body.logs-closed .log-open-pill {
  display: inline-flex;
}

.dialog-foot {
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.dialog-foot button {
  min-width: 120px;
}

.close-dialog {
  width: min(920px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: transparent;
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65);
}

.close-dialog::backdrop {
  background: rgba(2, 6, 10, 0.72);
  backdrop-filter: blur(8px);
}

.close-draft-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 22px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #f7d35c;
  background: rgba(240, 185, 11, 0.08);
  border: 1px solid rgba(240, 185, 11, 0.18);
}

.sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sync-toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--gold);
}

.sync-toggle b {
  font-size: 12px;
}

.close-draft-list {
  display: grid;
  gap: 10px;
  padding: 16px 22px 0;
}

.close-draft-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.065);
}

.close-draft-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.close-draft-head strong {
  font-size: 15px;
}

.close-draft-head span {
  color: var(--muted);
  font-size: 12px;
}

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

.logs {
  display: grid;
  align-content: start;
  gap: 7px;
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
  padding: 10px 10px 12px;
}

.log-item {
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-item strong {
  display: block;
  line-height: 1.5;
}

.log-title {
  display: grid;
  gap: 5px;
}

.log-title span {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--gold);
  background: rgba(240, 185, 11, 0.1);
  font-size: 11px;
  font-weight: 900;
}

.log-title strong {
  font-size: 12px;
}

.log-item .muted {
  margin-top: 6px;
  font-size: 11px;
}

.log-item[data-level="loading"] {
  border-color: rgba(240, 185, 11, 0.24);
  background: rgba(240, 185, 11, 0.08);
}

.log-item[data-level="success"] {
  border-color: rgba(14, 203, 129, 0.24);
  background: rgba(14, 203, 129, 0.08);
}

.log-item[data-level="error"] {
  border-color: rgba(246, 70, 93, 0.26);
  background: rgba(246, 70, 93, 0.08);
}

pre {
  margin: 10px 0 0;
  max-width: 100%;
  overflow: auto;
  color: #cbd5e1;
  font: 12px/1.55 "JetBrains Mono", monospace;
}

@media (max-width: 1180px) {
  .terminal {
    width: min(100vw, calc(100vw - 18px));
    margin: 0 auto;
  }

  .logs-panel {
    position: static;
    width: auto;
    max-height: 360px;
    margin-top: 10px;
  }

  body.logs-expanded .terminal {
    width: min(100vw, calc(100vw - 18px));
    margin: 0 auto;
  }

  body.logs-closed .terminal {
    width: min(100vw, calc(100vw - 18px));
    margin: 0 auto;
  }

  body.logs-expanded .logs-panel {
    width: auto;
  }

  .log-open-pill {
    right: 12px;
    bottom: 12px;
  }

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

  .hero-card,
  .connect-panel {
    grid-column: 1 / -1;
  }

  .metric-strip,
  .readout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .account-grid,
  .quick-grid,
  .quick-preview {
    grid-template-columns: 1fr;
  }

  .position-card {
    grid-template-columns: minmax(170px, 0.34fr) minmax(0, 1fr);
  }

  .position-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .connect-strip {
    grid-template-columns: 1fr;
  }

  .quick-grid .field:nth-child(5),
  .quick-grid .field:nth-child(6),
  .quick-grid .field:nth-child(7),
  .quick-grid .field:nth-child(1) {
    grid-column: auto;
  }

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

  .strategy-manager-toolbar,
  .running-strategy-list,
  .running-strategy-metrics {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 132px;
  }
}

@media (max-width: 720px) {
  .terminal {
    width: min(100vw, calc(100vw - 14px));
    padding-top: 8px;
  }

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

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

  .status-pill {
    width: 100%;
  }

  .hero-card,
  .metric-card,
  .panel {
    border-radius: 16px;
  }

  .hero-card,
  .metric-card,
  .panel-head,
  .form-grid,
  .quick-grid,
  .quick-preview,
  .logs {
    padding-left: 14px;
    padding-right: 14px;
  }

  .compact-card {
    padding: 14px;
  }

  .compact-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .compact-head p {
    text-align: left;
    white-space: normal;
  }

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

  .connect-actions {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    flex-direction: column;
    padding-left: 14px;
    padding-right: 14px;
  }

  .positions-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding-left: 14px;
    padding-right: 14px;
  }

  .positions-toolbar div {
    margin-left: 0;
  }

  .positions-list,
  .close-draft-list,
  .close-draft-note {
    padding-left: 14px;
    padding-right: 14px;
  }

  .positions-toolbar button {
    width: 100%;
  }

  .strategy-manager-toolbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .running-strategy-list {
    padding-left: 14px;
    padding-right: 14px;
  }

  .close-dialog {
    width: calc(100vw - 16px);
  }

  .close-draft-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions button {
    width: 100%;
  }

  .hero-actions button {
    width: 100%;
  }

  .config-dialog {
    width: calc(100vw - 16px);
  }

  .dialog-head,
  .dialog-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .form-grid {
    padding-left: 14px;
    padding-right: 14px;
  }
}
