:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #171f29;
  --line: #263240;
  --text: #edf2f7;
  --muted: #8f9cab;
  --accent: #39d98a;
  --accent-dark: #123d2d;
  --danger: #ff6262;
  --danger-dark: #432126;
  --warning: #f5bd45;
  --radius: 18px;
  --shadow: 0 20px 60px rgb(0 0 0 / 28%);
  font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 4px 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

h1, h2, h3, p { margin-top: 0; }
.topbar h1 { margin-bottom: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.04em; }
.eyebrow { color: var(--accent); font-size: .76rem; font-weight: 700; letter-spacing: .08em; margin-bottom: 6px; }
.muted, .section-head p { color: var(--muted); line-height: 1.8; }

.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .9rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgb(245 189 69 / 10%); }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 4px rgb(57 217 138 / 10%); }

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 80px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.card {
  grid-column: span 12;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: var(--shadow);
}

@media (min-width: 900px) {
  .login-card, .instrument-card { grid-column: span 6; }
}

.section-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 24px; }
.section-head h2 { margin: 4px 0 7px; font-size: 1.3rem; }
.section-head p { margin: 0; font-size: .9rem; }
.step { display: block; color: #566476; font: 700 .75rem/1 monospace; }

.pill { display: inline-flex; white-space: nowrap; border-radius: 999px; padding: 7px 11px; font-size: .76rem; font-weight: 700; }
.pill.neutral { background: #202a36; color: #aeb9c6; }
.pill.success { background: var(--accent-dark); color: #79e8b2; }
.pill.danger { background: var(--danger-dark); color: #ff8e8e; }

label, legend { display: block; color: #bdc7d2; font-size: .82rem; font-weight: 700; }
input {
  width: 100%; margin-top: 8px; padding: 12px 14px;
  border: 1px solid #344151; border-radius: 10px;
  color: var(--text); background: #0d131a; outline: none;
}
select { width: 100%; min-height: 44px; margin-top: 8px; padding: 10px 12px; border: 1px solid #344151; border-radius: 10px; color: var(--text); background: #0d131a; outline: none; }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(57 217 138 / 12%); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(57 217 138 / 12%); }

.button {
  min-height: 42px; padding: 10px 17px; border-radius: 10px;
  border: 1px solid transparent; color: var(--text); font-weight: 700;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { background: var(--accent); color: #07170f; }
.button.secondary { background: #202a36; border-color: #344151; }
.button.danger { background: var(--danger); color: #24090c; }
.button.ghost { background: transparent; border-color: var(--line); }
.danger-text { color: #ff8b8b; }
.button.full { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.balance-panel { margin-top: 18px; padding: 15px; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr) auto; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.balance-panel div span, .balance-panel div small { display: block; color: var(--muted); font-size: .72rem; }
.balance-panel strong { display: block; margin: 6px 0 2px; direction: ltr; text-align: right; }
.balance-panel > div:first-child strong { color: var(--accent); font-size: 1.15rem; }

.feedback { min-height: 20px; margin: 15px 0 0; color: var(--muted); font-size: .86rem; }
.feedback.error, .form-error { color: #ff8b8b; }
.feedback.success { color: #79e8b2; }
.form-error { min-height: 18px; margin: 12px 0 0; font-size: .82rem; }
.hidden { display: none !important; }

.captcha-panel { margin-top: 20px; display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: end; }
.captcha-frame { background: white; border-radius: 12px; overflow: hidden; padding: 8px; text-align: center; }
.captcha-frame img { display: block; width: 100%; min-height: 62px; object-fit: contain; }
.text-button { border: 0; background: transparent; color: #344151; font-size: .75rem; padding: 6px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 18px; }
.inline-form label { grid-column: 1 / -1; }

.input-action { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.instrument-result { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 22px; }
.symbol-title { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; }
.symbol-title h3 { margin: 0 0 5px; }
.symbol-title code { color: var(--muted); direction: ltr; display: inline-block; }
.symbol-badge { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 13px; background: var(--accent-dark); color: var(--accent); font-weight: 800; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.metric { padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.metric span, .metric small { display: block; color: var(--muted); font-size: .72rem; }
.metric strong { display: block; margin: 8px 0 3px; direction: ltr; text-align: right; font-size: 1.15rem; }
.metric.buy { border-color: rgb(57 217 138 / 35%); }
.metric.sell { border-color: rgb(255 98 98 / 35%); }

.order-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; align-items: end; }
.order-form fieldset { border: 0; padding: 0; margin: 0; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #0d131a; border: 1px solid #344151; border-radius: 10px; overflow: hidden; margin-top: 8px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 12px; text-align: center; color: var(--muted); }
.segmented input:checked + span { background: var(--accent-dark); color: #79e8b2; }
.order-total { grid-column: 1 / -1; display: flex; justify-content: space-between; padding: 12px 14px; background: var(--panel-2); border-radius: 10px; }
.order-total span { color: var(--muted); }
.order-form > .button { grid-column: 1 / -1; }
.order-calculator { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 16px; background: #0d131a; border: 1px solid var(--line); border-radius: 12px; }
.order-calculator h4, .order-calculator .actions, .calculator-note { grid-column: 1 / -1; margin: 0; }
.order-calculator h4 { font-size: .9rem; }
.calculator-note { color: var(--muted); font-size: .78rem; line-height: 1.7; }

.warning-box { border-right: 3px solid var(--warning); background: #2b2518; color: #e7d4a8; padding: 13px 15px; border-radius: 9px; line-height: 1.8; font-size: .84rem; margin-bottom: 20px; }
.calibration-prepare { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.calibration-parameters { display: grid; grid-template-columns: 1.5fr repeat(5, 1fr); gap: 12px; }
.money-input { position: relative; }
.money-input input { padding-left: 60px; }
.money-input span { position: absolute; left: 14px; bottom: 13px; color: var(--muted); font-size: .8rem; }
.calibration-order { margin-top: 18px; padding: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; align-items: center; }
.calibration-order div span { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 5px; }
.calibration-settings { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.calibration-settings h3 { font-size: 1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }

.job-panel { margin-top: 18px; background: #0d131a; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.job-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
pre { direction: ltr; text-align: left; white-space: pre-wrap; overflow: auto; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; max-height: 230px; color: #9fb0c0; font: 12px/1.65 monospace; }

.live-controls { display: grid; grid-template-columns: 1fr 180px auto; gap: 12px; align-items: end; }
.tab-nav { display: flex; gap: 8px; grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab-button { min-height: 44px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); cursor: pointer; font: inherit; }
.tab-button.active { border-color: var(--accent); background: var(--accent-dark); color: #79e8b2; }
.tab-panel { display: none; grid-column: 1 / -1; }
.tab-panel.active { display: grid; gap: 18px; }
.performance-tab { grid-column: 1 / -1; }
.performance-hero { display: grid; grid-template-columns: 1fr; gap: 22px; align-items: end; padding: clamp(22px, 4vw, 34px); border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, #151f2a, #10171f); box-shadow: var(--shadow); }
.performance-hero h2 { margin: 4px 0 8px; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.performance-hero p:last-child { max-width: 650px; margin: 0; color: var(--muted); line-height: 1.9; }
.performance-filter { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(220px, 1.4fr) auto; gap: 10px; align-items: end; }
.performance-toggle { min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid #344151; border-radius: 10px; background: #0d131a; cursor: pointer; }
.performance-toggle input { width: 18px; height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.performance-toggle span, .performance-toggle strong, .performance-toggle small { display: block; }
.performance-toggle strong { color: var(--text); font-size: .76rem; }.performance-toggle small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.performance-guide { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 14px 18px; border: 1px solid rgb(59 130 246 / 20%); border-radius: 12px; background: rgb(30 64 175 / 10%); color: #bac8d8; font-size: .82rem; line-height: 1.7; }
.performance-guide strong { color: #dce7f4; }
.performance-guide b { color: #8ab4ff; }
.performance-empty { min-height: 330px; display: grid; place-items: center; align-content: center; text-align: center; padding: 40px 20px; border: 1px dashed #344151; border-radius: var(--radius); background: var(--panel); }
.performance-empty h3 { margin: 22px 0 8px; }
.performance-empty p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.9; }
.empty-chart { height: 70px; display: flex; gap: 7px; align-items: end; direction: ltr; }
.empty-chart i { display: block; width: 15px; border-radius: 5px 5px 2px 2px; background: linear-gradient(var(--accent), #17643f); }
.empty-chart i:nth-child(1) { height: 28px; }.empty-chart i:nth-child(2) { height: 48px; }.empty-chart i:nth-child(3) { height: 38px; }.empty-chart i:nth-child(4) { height: 64px; }
.performance-content { display: grid; gap: 16px; }
.account-overview { padding: clamp(20px, 3vw, 28px); border: 1px solid rgb(57 217 138 / 32%); border-radius: var(--radius); background: linear-gradient(145deg, rgb(18 61 45 / 72%), var(--panel)); box-shadow: var(--shadow); }
.account-overview.unavailable { border-color: rgb(245 189 69 / 28%); background: linear-gradient(145deg, rgb(55 45 23 / 48%), var(--panel)); }
.account-overview-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 20px; }
.account-overview-head span, .account-overview-head small { display: block; color: var(--muted); font-size: .76rem; }
.account-overview-head strong { display: block; margin: 8px 0 5px; direction: ltr; text-align: right; font-size: clamp(1.35rem, 3vw, 2rem); font-variant-numeric: tabular-nums; }
.account-overview-head p { max-width: 580px; margin: 0; color: #afc1b7; font-size: .8rem; line-height: 1.8; }
.account-overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.account-overview-grid > div { min-width: 0; padding: 13px 14px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 10px; background: rgb(8 15 21 / 45%); }
.account-overview-grid span { display: block; color: var(--muted); font-size: .72rem; }
.account-overview-grid strong { display: block; margin-top: 7px; direction: ltr; text-align: right; overflow-wrap: anywhere; font-size: .9rem; font-variant-numeric: tabular-nums; }
.account-overview-grid .account-equity { border-color: rgb(57 217 138 / 25%); }
.performance-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 10px 30px rgb(0 0 0 / 14%); }
.summary-card span, .summary-card small { display: block; color: var(--muted); font-size: .76rem; line-height: 1.6; }
.summary-card strong { display: block; margin: 12px 0 7px; direction: ltr; text-align: right; font-size: clamp(1rem, 2vw, 1.35rem); overflow-wrap: anywhere; }
.summary-card.profit-card { border-color: rgb(57 217 138 / 28%); background: linear-gradient(145deg, rgb(18 61 45 / 60%), var(--panel)); }
.summary-card.open-card { border-color: rgb(59 130 246 / 25%); }
.summary-card.market-card { border-color: rgb(245 189 69 / 28%); background: linear-gradient(145deg, rgb(55 45 23 / 50%), var(--panel)); }
.positive { color: #79e8b2 !important; }.negative { color: #ff8e8e !important; }
.performance-story { padding: 18px 20px; border-radius: 13px; border-right: 4px solid var(--accent); background: var(--accent-dark); }
.performance-story strong { font-size: 1rem; }.performance-story p { margin: 8px 0 0; color: #a8c8b7; font-size: .82rem; line-height: 1.8; }
.performance-warnings { display: grid; gap: 7px; }
.performance-warnings:empty { display: none; }
.performance-warnings p { margin: 0; padding: 10px 13px; color: #dfcca0; background: #2b2518; border-radius: 8px; font-size: .78rem; line-height: 1.7; }
.performance-section { padding: clamp(18px, 3vw, 26px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.performance-section-head { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 16px; }
.performance-section-head h3 { margin: 0 0 6px; }.performance-section-head p { margin: 0; color: var(--muted); font-size: .8rem; }
.performance-section-badges { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.symbol-performance-list { display: grid; gap: 9px; }
.symbol-reconciliation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: rgba(8, 18, 28, .72); }
.symbol-reconciliation.verified { border-color: rgba(43, 210, 143, .55); }
.symbol-reconciliation.invalid { border-color: rgba(255, 98, 98, .7); background: rgba(67, 33, 38, .35); }
.symbol-reconciliation > div { display: grid; gap: 5px; min-width: 0; }
.symbol-reconciliation span, .symbol-reconciliation small { color: var(--muted); font-size: .76rem; }
.symbol-reconciliation strong { font-size: 1rem; }
.symbol-reconciliation small { grid-column: 1 / -1; line-height: 1.7; }
@media (max-width: 720px) { .symbol-reconciliation { grid-template-columns: 1fr; } .symbol-reconciliation small { grid-column: auto; } }
.symbol-performance { border: 1px solid var(--line); border-radius: 12px; background: #0e151d; overflow: hidden; }
.symbol-performance[open] { border-color: rgb(57 217 138 / 35%); }
.symbol-performance.excluded { opacity: .68; border-style: dashed; }
.symbol-performance.excluded[open] { opacity: .9; border-color: rgb(245 189 69 / 35%); }
.symbol-performance > summary { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 13px 16px; cursor: pointer; list-style: none; }
.symbol-performance > summary::-webkit-details-marker { display: none; }
.symbol-performance-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.symbol-performance-name > span { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; color: var(--accent); background: var(--accent-dark); font-weight: 800; }
.symbol-performance-name strong, .symbol-performance-name small, .symbol-performance-result small { display: block; }
.symbol-performance-name small, .symbol-performance-result small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.symbol-performance-result { text-align: left; }.symbol-performance-result strong { display: block; margin-top: 4px; direction: ltr; }
.symbol-performance-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0 16px 14px; }
.symbol-performance-metrics div { padding: 10px; border-radius: 8px; background: var(--panel-2); }
.symbol-performance-metrics dt { color: var(--muted); font-size: .7rem; }.symbol-performance-metrics dd { margin: 5px 0 0; direction: ltr; text-align: right; font-size: .8rem; }
.symbol-cycles { border-top: 1px solid var(--line); padding: 14px 16px; background: rgb(5 11 16 / 18%); }
.symbol-cycles-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }.symbol-cycles-heading strong { font-size: .84rem; }.symbol-cycles-heading small { color: var(--muted); font-size: .7rem; }
.trade-cycle { margin-top: 8px; padding: 12px; border: 1px solid rgb(58 78 96 / 72%); border-radius: 9px; background: var(--panel-2); }.trade-cycle.incomplete { border-style: dashed; border-color: rgb(245 189 69 / 45%); }
.trade-cycle-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; }.trade-cycle-head > strong, .trade-cycle-head small { display: block; }.trade-cycle-head > small { margin-top: 4px; color: var(--muted); font-size: .7rem; }.trade-cycle-outcome { text-align: left; flex: 0 0 auto; }.trade-cycle-outcome small { color: var(--muted); font-size: .67rem; }.trade-cycle-outcome strong { display: block; margin-top: 4px; direction: ltr; }
.trade-cycle-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 12px 0 0; }.trade-cycle-metrics div { min-width: 0; padding: 8px; border-radius: 7px; background: rgb(14 25 35 / 82%); }.trade-cycle-metrics dt { color: var(--muted); font-size: .66rem; }.trade-cycle-metrics dd { margin: 4px 0 0; font-size: .72rem; line-height: 1.5; overflow-wrap: anywhere; }
.symbol-trades { display: grid; border-top: 1px solid var(--line); }
.transaction-section { padding: 0; }
.transaction-section > summary { padding: 17px 20px; cursor: pointer; font-weight: 700; }
.transaction-section > summary span { color: var(--muted); font-size: .78rem; }
.transaction-list { display: grid; border-top: 1px solid var(--line); }
.cashflow-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.cashflow-summary div { padding: 12px; border-radius: 9px; background: var(--panel-2); }
.cashflow-summary span { display: block; color: var(--muted); font-size: .72rem; }.cashflow-summary strong { display: block; margin-top: 6px; direction: ltr; text-align: right; }
.performance-row-empty { margin: 0; padding: 18px; color: var(--muted); font-size: .8rem; }
.transaction-row { display: grid; grid-template-columns: 55px 1fr 1.4fr 1fr 1fr; gap: 10px; align-items: center; min-height: 52px; padding: 10px 16px; border-bottom: 1px solid rgb(38 50 64 / 70%); font-size: .78rem; }
.transaction-row:last-child { border-bottom: 0; }.transaction-row > strong:nth-of-type(2) { direction: ltr; text-align: right; }.transaction-row small { color: var(--muted); direction: ltr; text-align: left; }
.trade-side { display: inline-flex; justify-content: center; padding: 5px 8px; border-radius: 999px; font-weight: 700; }.trade-side.buy { color: #7ee8b4; background: rgb(57 217 138 / 12%); }.trade-side.sell { color: #ffaaa9; background: rgb(255 98 98 / 12%); }
.performance-updated { margin: 0; color: var(--muted); text-align: left; font-size: .72rem; }
.history-tab { margin-top: 0; }
.history-layout { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.8fr); gap: 14px; align-items: start; min-width: 0; }
.history-layout > * { min-width: 0; }
.history-run-list { display: grid; gap: 8px; }
.history-run-button { width: 100%; padding: 13px; text-align: right; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font: inherit; }
.history-run-button:hover, .history-run-button.active { border-color: var(--accent); background: var(--accent-dark); }
.history-run-button strong, .history-run-button span { display: block; overflow-wrap: anywhere; }
.history-run-button span { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.history-detail { min-width: 0; }
.order-history { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.order-history h3 { margin: 0 0 4px; font-size: 1rem; }
.order-history p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.7; }
.history-date { min-width: 150px; font-size: .75rem; color: var(--muted); }
.history-date input { margin-top: 5px; }
.history-list { display: grid; gap: 10px; }
.history-run { padding: 15px; background: #0d131a; border: 1px solid var(--line); border-radius: 12px; }
.history-run h4 { margin: 0 0 8px; font-size: .95rem; }
.history-run-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.history-run-overview div, .history-run-settings-grid div { min-width: 0; padding: 10px; border-radius: 8px; background: var(--panel-2); }
.history-run-overview dt, .history-run-settings-grid dt { color: var(--muted); font-size: .7rem; }
.history-run-overview dd, .history-run-settings-grid dd { margin: 5px 0 0; color: var(--text); direction: ltr; font: 600 .78rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.history-run-overview div:last-child { grid-column: span 2; }
.history-run-settings { margin: 10px 0 14px; border: 1px solid rgb(144 164 184 / 14%); border-radius: 9px; background: rgb(5 9 14 / 20%); }
.history-run-settings summary { min-height: 42px; padding: 11px 12px; cursor: pointer; color: var(--muted); font-size: .8rem; }
.history-run-settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 10px 10px; }
.history-run-settings-grid div:last-child { grid-column: span 2; }
.history-run .history-entry { margin-top: 10px; }
.history-entry { min-width: 0; padding: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; }
.history-entry.deleted { border-color: rgb(57 217 138 / 35%); }
.history-entry.failed { border-color: rgb(255 98 98 / 45%); }
.history-entry-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.history-entry-title { min-width: 0; display: grid; gap: 4px; }
.history-entry-title strong { direction: ltr; color: var(--text); font-size: .92rem; overflow-wrap: anywhere; }
.history-entry-title span:not(.history-attempt) { color: var(--muted); font-size: .78rem; direction: ltr; overflow-wrap: anywhere; }
.history-attempt { color: var(--muted); font-size: .72rem; }
.history-result { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.history-result.success { color: #8cf0bd; background: rgb(57 217 138 / 12%); }
.history-result.error { color: #ffaaa9; background: rgb(255 98 98 / 12%); }
.history-timing { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.history-timing div { min-width: 0; padding: 9px 10px; background: rgb(5 9 14 / 35%); border-radius: 8px; }
.history-timing dt { color: var(--muted); font-size: .7rem; }
.history-timing dd { margin: 4px 0 0; color: var(--text); direction: ltr; font: 600 .78rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.history-alert { margin: 12px 0 0 !important; padding: 9px 11px; color: #ffb1ae !important; background: rgb(255 98 98 / 8%); border-right: 3px solid var(--danger); border-radius: 7px; overflow-wrap: anywhere; }
.history-note { margin-top: 12px !important; font-size: .75rem !important; overflow-wrap: anywhere; }
.history-details { margin-top: 10px; border: 1px solid rgb(144 164 184 / 14%); border-radius: 8px; background: rgb(5 9 14 / 22%); }
.history-details summary { min-height: 40px; padding: 10px 12px; cursor: pointer; color: var(--muted); font-size: .8rem; }
.history-details pre { margin: 0; padding: 0 12px 12px; max-height: 180px; color: #aebfd0; }
.history-actions { display: flex; gap: 8px; margin-top: 12px; }

.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgb(7 10 14 / 96%); }
.auth-box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.auth-box h1 { margin-bottom: 10px; }
.auth-box .button { margin-top: 14px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #07170f; font-size: 1.5rem; font-weight: 900; margin-bottom: 22px; }

dialog { width: min(560px, calc(100% - 28px)); border: 1px solid #4a3035; border-radius: 20px; background: var(--panel); color: var(--text); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 78%); }
.confirm-box { padding: 28px; }
.confirm-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--danger-dark); color: var(--danger); font-weight: 900; margin-bottom: 18px; }
.confirm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.confirm-grid div { background: var(--panel-2); padding: 12px; border-radius: 10px; }
.confirm-grid dt { color: var(--muted); font-size: .72rem; }
.confirm-grid dd { margin: 6px 0 0; direction: ltr; text-align: right; font-weight: 700; }
.confirm-check { display: flex; gap: 10px; align-items: start; line-height: 1.7; }
.confirm-check input { width: auto; margin-top: 5px; }
.dialog-actions { display: flex; gap: 10px; justify-content: end; margin-top: 22px; }

.toast { position: fixed; left: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); background: #202a36; border: 1px solid #344151; border-radius: 11px; padding: 12px 16px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #74353c; color: #ff9a9a; }

@media (max-width: 700px) {
  .topbar { padding-top: 24px; }
  .topbar-status { display: none; }
  .captcha-panel, .inline-form, .input-action, .calibration-prepare, .calibration-parameters, .live-controls { grid-template-columns: 1fr; }
  .price-grid, .settings-grid, .balance-panel, .order-calculator { grid-template-columns: 1fr; }
  .order-form { grid-template-columns: 1fr; }
  .calibration-order { grid-template-columns: 1fr 1fr; }
  .history-layout { grid-template-columns: 1fr; }
  .history-run-overview, .history-run-settings-grid { grid-template-columns: 1fr 1fr; }
  .history-run-overview div:last-child, .history-run-settings-grid div:last-child { grid-column: auto; }
  .history-entry-header { align-items: stretch; flex-direction: column; }
  .history-result { align-self: flex-start; }
  .history-timing { grid-template-columns: 1fr 1fr; }
  .calibration-order .button { grid-column: 1 / -1; }
  .confirm-grid { grid-template-columns: 1fr; }
  .performance-hero, .performance-filter { grid-template-columns: 1fr; }
  .account-overview-head { align-items: start; flex-direction: column; }
  .account-overview-grid { grid-template-columns: 1fr 1fr; }
  .performance-summary { grid-template-columns: 1fr 1fr; }
  .symbol-performance-metrics { grid-template-columns: 1fr 1fr; }
  .trade-cycle-metrics { grid-template-columns: 1fr 1fr; }
  .transaction-row { grid-template-columns: 50px 1fr auto; }
  .transaction-row > span:nth-of-type(2), .transaction-row small { grid-column: 2 / -1; }
}

@media (max-width: 430px) {
  .account-overview-grid { grid-template-columns: 1fr; }
  .performance-summary { grid-template-columns: 1fr; }
  .symbol-performance > summary { align-items: flex-start; }
  .symbol-performance-metrics { grid-template-columns: 1fr; }
  .symbol-cycles-heading, .trade-cycle-head { align-items: flex-start; flex-direction: column; }
  .trade-cycle-outcome { text-align: right; }.trade-cycle-metrics { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
