:root {
  --bg: #0e0e0e;
  --panel: #171717;
  --panel-light: #202020;
  --border: #2c2c2c;
  --text: #ffffff;
  --text-dim: #9b9b9b;
  --green: #4bb4b3;
  --red: #ff444f;
  --accent: #ff444f;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-light: #edeff2;
  --border: #dadde2;
  --text: #15181c;
  --text-dim: #666d78;
  --green: #138a84;
  --red: #d8323c;
  --accent: #d8323c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background-color: var(--bg);
  transition: background-color 0.15s ease, color 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='220' viewBox='0 0 400 220'%3E%3Cg opacity='0.07' fill='none' stroke-width='2'%3E%3Cpolyline points='0,170 20,150 40,160 60,120 80,140 100,95 120,112 140,70 160,88 180,58 200,78 220,45 240,62 260,34 280,50 300,22 320,40 340,15 360,30 380,10 400,22' stroke='%234bb4b3'/%3E%3C/g%3E%3Cg opacity='0.07'%3E%3Crect x='28' y='140' width='8' height='32' fill='%234bb4b3'/%3E%3Crect x='68' y='108' width='8' height='26' fill='%23ff444f'/%3E%3Crect x='108' y='80' width='8' height='24' fill='%234bb4b3'/%3E%3Crect x='148' y='56' width='8' height='28' fill='%23ff444f'/%3E%3Crect x='188' y='62' width='8' height='20' fill='%234bb4b3'/%3E%3Crect x='228' y='38' width='8' height='24' fill='%23ff444f'/%3E%3Crect x='268' y='26' width='8' height='26' fill='%234bb4b3'/%3E%3Crect x='308' y='16' width='8' height='22' fill='%23ff444f'/%3E%3Crect x='348' y='10' width='8' height='18' fill='%234bb4b3'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 400px 220px;
  background-attachment: fixed;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  max-width: 100%;
  overflow-x: hidden;
}

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

/* ---------- Landing page ---------- */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo span { color: var(--accent); }

.navbar .btn { margin-left: 12px; }

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 80px 40px;
  gap: 40px;
}

.hero-text { max-width: 560px; }

.hero-text h1 {
  font-size: 42px;
  line-height: 1.2;
  margin-bottom: 20px;
}

.hero-text p {
  color: var(--text-dim);
  font-size: 17px;
  margin-bottom: 30px;
}

.hero-badge {
  display: inline-block;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.hero-chart {
  flex: 1;
  min-width: 320px;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: none;
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--text-dim); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  padding: 0 40px 80px;
}

.feature-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.feature-card h3 { margin: 0 0 10px; font-size: 17px; }
.feature-card p { margin: 0; color: var(--text-dim); font-size: 14px; }

.footer-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

/* ---------- Trade page ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  gap: 10px;
}

.topbar .logo { flex-shrink: 0; }

.balance-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  white-space: nowrap;
}

.balance-box b { color: var(--green); }

/* Stays on one line with the logo always — if it doesn't fit, it scrolls
   sideways instead of wrapping onto a second row. */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar-actions::-webkit-scrollbar { display: none; }

.topbar-actions > * { flex-shrink: 0; }

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

/* ---------- Bottom tab navigation ---------- */

body.has-bottom-tabs { padding-bottom: 76px; }

.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 50;
}

body.has-bottom-tabs .telegram-fab,
body.has-bottom-tabs .theme-fab {
  bottom: 86px;
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 4px 8px;
  cursor: pointer;
}

.bottom-tab-icon { font-size: 19px; line-height: 1; }

.bottom-tab.active { color: var(--accent); }

.tab-view { display: none; padding: 0 16px 16px; }
.tab-view.active { display: block; }

.more-menu-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ---------- Instrument watchlist ---------- */

.instrument-list { display: flex; flex-direction: column; }

.instrument-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.instrument-row:last-child { border-bottom: none; }

.instrument-row.active { background: var(--panel-light); }

.instrument-name { font-weight: 600; font-size: 14px; }

.instrument-prices { display: flex; gap: 8px; }

.instrument-sell, .instrument-buy {
  min-width: 78px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel-light);
}

.instrument-sell { color: var(--red); }
.instrument-buy { color: var(--green); }

.app-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
}

.account-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 16px 0;
}

.account-summary-item {
  flex: 1;
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.account-summary-item b {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-top: 2px;
}

.pl-positive { color: var(--green); font-weight: 600; }
.pl-negative { color: var(--red); font-weight: 600; }

.btn-close-position {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.btn-close-position:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sltp-edit {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sltp-edit input {
  width: 64px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.btn-sltp-apply {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.btn-sltp-apply:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wins-ticker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 10px 16px;
  background: rgba(75, 180, 179, 0.08);
  border: 1px solid rgba(75, 180, 179, 0.25);
  border-radius: 8px;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}

.wins-ticker-icon {
  flex-shrink: 0;
}

#winsTickerText {
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-panel {
  flex: 3;
  min-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

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

.chart-header select {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

.timeframe-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.timeframe-bar::-webkit-scrollbar { display: none; }

.tf-btn {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

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

.tf-gap { flex: 1; min-width: 6px; }

.zoom-btn {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.zoom-btn:hover { border-color: var(--accent); }

.bid-ask-display {
  display: flex;
  gap: 14px;
  font-size: 16px;
  font-weight: 700;
}

.price-sell, .price-buy {
  white-space: nowrap;
  color: var(--text-dim);
  font-weight: 600;
}

.price-sell b, .price-buy b { font-weight: 700; }

.price-up { color: var(--green); }
.price-down { color: var(--red); }

#priceChart {
  width: 100%;
  height: 480px;
  display: block;
}

.trade-panel {
  flex: 1;
  min-width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.trade-panel h3 { margin-top: 0; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
}

.payout-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.direction-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
}

.btn-rise, .btn-fall {
  flex: 1;
  padding: 14px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  color: #fff;
}

/* ---------- Full-screen chart (MT5-style) ---------- */

#view-trade { padding: 0 0 16px; }

.chart-fullscreen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 190px); /* refined to the exact free height by JS */
  min-height: 300px;
  border-radius: 0;
  border: none;
  padding: 0;
}

/* Everything sits inside the chart frame as slim solid bars — a compact
   toolbar on top, the chart in the middle, the Buy/Sell bar underneath. */
.chart-stage {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chart-stage #priceChart {
  order: 1;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: 0;
  display: block;
}

.chart-float-top {
  order: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.chart-float-top .chart-header { margin: 0; flex: 0 0 auto; }

.chart-float-top .chart-header select {
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 700;
}

.chart-float-top .timeframe-bar { margin: 0; flex: 1 1 0; min-width: 0; }

.chart-float-stats {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}

.float-stat {
  flex: 1 1 0;
  min-width: 0;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.25;
  white-space: nowrap;
}

.float-stat span { display: block; overflow: hidden; text-overflow: ellipsis; }

.float-stat b { display: block; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.chart-float-stats .live-tag { flex: 0 0 auto; font-size: 10px; padding: 3px 8px; }

.chart-float-trade {
  order: 2;
  padding: 6px 8px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.trade-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
}

.trade-row .btn-rise,
.trade-row .btn-fall {
  flex: 1;
  max-width: 190px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 12px;
  line-height: 1.2;
}

.trade-row .btn-rise b,
.trade-row .btn-fall b { font-size: 14px; }

.lot-box {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  width: 88px;
}

.lot-box label { display: block; font-size: 10px; color: var(--text-dim); }

.lot-box input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  padding: 2px 0;
  outline: none;
}

.trade-options-btn {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 38px;
  font-size: 16px;
  cursor: pointer;
}

.trade-options {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 6px;
}

.trade-options-row { display: flex; gap: 8px; margin-bottom: 8px; }
.trade-options-row > div { flex: 1; }
.trade-options-row label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }

.trade-options-row input {
  width: 100%;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px;
  border-radius: 6px;
  font-size: 14px;
}

.trade-options .payout-hint { margin-bottom: 6px; font-size: 12px; }
.trade-options-note { font-size: 11px; color: var(--text-dim); margin: 4px 0 0; }

.btn-rise { background: var(--green); }
.btn-rise:hover { background: #3a9897; }
.btn-fall { background: var(--red); }
.btn-fall:hover { background: #e03039; }

.panels-bottom {
  padding: 0 16px 24px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.tag-win { background: rgba(75,180,179,0.15); color: var(--green); }
.tag-loss { background: rgba(255,68,79,0.15); color: var(--red); }
.tag-open { background: rgba(255,255,255,0.1); color: var(--text-dim); }

.empty-row { color: var(--text-dim); text-align: center; padding: 20px 0; }

/* ---------- Auth pages ---------- */

.auth-wrap {
  display: flex;
  justify-content: center;
  padding: 60px 20px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.auth-card h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.auth-switch {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 16px;
}

.auth-switch a { color: var(--accent); font-weight: 600; }

.form-error {
  background: rgba(255, 68, 79, 0.12);
  border: 1px solid rgba(255, 68, 79, 0.4);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.user-chip {
  font-size: 14px;
  color: var(--text-dim);
}

.user-chip b { color: var(--text); }

.lang-switcher {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 6px 8px 10px;
  font-size: 13px;
  cursor: pointer;
  /* Collapsed, this only has room for the 2-letter code (e.g. "EN") since
     each option's text is "EN — English" — the dropdown list itself isn't
     bound by this width, so it still shows the full language name. */
  width: 52px;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

[dir="rtl"] .navbar, [dir="rtl"] .topbar {
  direction: rtl;
}

[dir="rtl"] .auth-switch a { margin: 0 4px; }

.telegram-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #229ed9;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  z-index: 999;
  transition: transform 0.15s ease;
}

.telegram-fab:hover { transform: scale(1.08); }

.telegram-fab svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

[dir="rtl"] .telegram-fab {
  right: auto;
  left: 20px;
}

@media (max-width: 680px) {
  .telegram-fab { width: 48px; height: 48px; bottom: 14px; right: 14px; }
  .telegram-fab svg { width: 24px; height: 24px; }
  [dir="rtl"] .telegram-fab { left: 14px; }
}

.theme-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 999;
  cursor: pointer;
  font-size: 22px;
  transition: transform 0.15s ease;
}

.theme-fab:hover { transform: scale(1.08); }

[dir="rtl"] .theme-fab {
  left: auto;
  right: 20px;
}

@media (max-width: 680px) {
  .theme-fab { width: 48px; height: 48px; bottom: 14px; left: 14px; font-size: 18px; }
  [dir="rtl"] .theme-fab { right: 14px; }
}

.account-switch {
  display: inline-flex;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.account-switch button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}

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

.account-switch button[data-type="live"].active {
  background: var(--green);
}

.live-tag {
  display: none;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: default;
}

.live-tag.visible { display: inline-block; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 24px 0;
}

.modal-overlay.visible {
  display: flex;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  margin: 16px auto;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal-card h3 { margin-top: 0; }

.input-locked {
  background: var(--panel-light) !important;
  color: var(--text-dim) !important;
  cursor: not-allowed;
}

.funding-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.funding-stepper .step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.funding-stepper .step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel-light);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

.funding-stepper .step.active { color: var(--text); font-weight: 600; }
.funding-stepper .step.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.funding-stepper .step.done .step-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.funding-stepper .step-line {
  width: 28px;
  height: 1px;
  background: var(--border);
}

.payment-card {
  background: linear-gradient(145deg, var(--panel-light), var(--panel));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}

.payment-card .payment-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(75, 180, 179, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

.payment-card .payment-icon svg { width: 18px; height: 18px; stroke: var(--green); }

.payment-method-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.payment-method-row .method-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255, 68, 79, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.payment-method-row .method-icon svg { width: 16px; height: 16px; stroke: var(--accent); }

@media (max-width: 720px) {
  .hero { padding: 40px 20px; }
  .hero-text h1 { font-size: 30px; }
  .hero-chart { min-width: 0; width: 100%; max-width: 100%; }
}

@media (max-width: 680px) {
  .navbar, .topbar {
    padding: 12px 16px;
    gap: 8px;
  }

  .logo { font-size: 19px; }

  .btn {
    padding: 9px 14px;
    font-size: 13px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-left {
    gap: 6px;
    width: 100%;
  }

  .lang-switcher { width: 44px; font-size: 12px; padding: 6px 4px 6px 8px; }

  .account-switch button { padding: 5px 10px; font-size: 12px; }

  .balance-box { padding: 6px 10px; font-size: 12px; }

  .app-layout { padding: 10px; gap: 10px; }

  .chart-panel, .trade-panel {
    min-width: 0;
    width: 100%;
    flex-basis: 100%;
    padding: 12px;
  }

  #priceChart { height: 320px; }

  .bid-ask-display { font-size: 13px; gap: 8px; }

  .panels-bottom { padding: 0 10px 20px; }

  .table-wrap { padding: 12px; }

  table { font-size: 12px; }
  th, td { padding: 6px 4px; }

  .auth-wrap { padding: 30px 14px; }
  .auth-card { padding: 22px; }

  .account-switch button {
    padding: 6px 10px;
    font-size: 12px;
  }

  .modal-card { padding: 18px; }

  .features { padding: 0 16px 50px; grid-template-columns: 1fr; gap: 14px; }

  .hero { padding: 30px 16px; }
}

/* Lots / Timed trade mode */
.trade-mode-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.mode-switch {
  display: flex;
  flex-shrink: 0;
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn.active { background: var(--accent); color: #fff; }

.duration-bar {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.duration-bar::-webkit-scrollbar { display: none; }

.dur-btn {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

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

.timer-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.timed-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  margin-right: 4px;
}

/* Chart tools (chart type, indicators, drawing) */
.chart-tools {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}

.tools-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tools-row::-webkit-scrollbar { display: none; }

.tools-label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 58px;
  flex-shrink: 0;
}

.tool-chip {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.tool-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.tools-hint { font-size: 11px; color: var(--accent); min-height: 0; }
.tools-hint:empty { display: none; }

/* Margin call warning */
.margin-warning {
  background: rgba(255, 68, 79, 0.18);
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  text-align: center;
}

.margin-warning.stop-out { background: var(--accent); color: #fff; }

.input-with-btn { display: flex; gap: 4px; }
.input-with-btn input { min-width: 0; flex: 1; }
.input-with-btn .btn { padding: 0 10px; }

/* Toast + notification badge */
.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  max-width: min(92vw, 420px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.bottom-tab-icon { position: relative; display: inline-block; }

.tab-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notif-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.notif-item {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}
.notif-item.unread { border-color: var(--accent); }
.notif-item small { display: block; color: var(--text-dim); font-size: 11px; margin-top: 2px; }

.sound-setting { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* Open-position extras: trailing stop + partial close */
.sltp-edit .sltp-trail { width: 64px; }
.close-cell { display: flex; gap: 4px; align-items: center; }
.close-cell .close-lots { width: 58px; padding: 4px; }

/* History page */
.history-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.history-filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-dim); gap: 3px; }
.history-filters input, .history-filters select {
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px;
  border-radius: 6px;
  font-size: 13px;
}
.history-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.history-summary .float-stat { flex: 1 1 110px; padding: 8px; }
.history-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

/* Help page + first-run tour */
.learn-card { margin-bottom: 12px; }
.learn-card h4 { margin: 0 0 6px; }
.learn-card p { margin: 0; font-size: 14px; color: var(--text-dim); line-height: 1.55; }
.tour-dots { display: flex; justify-content: center; gap: 6px; }
.tour-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); display: inline-block; }
.tour-dots i.on { background: var(--accent); }
/* Timeframe row: the timeframes scroll on their own, while the chart-tools
   and zoom buttons stay pinned and always visible on the right. */
.chart-float-top .timeframe-bar { overflow: visible; flex-wrap: nowrap; align-items: stretch; gap: 6px; }
.tf-scroll { display: flex; gap: 4px; flex: 1 1 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tf-scroll::-webkit-scrollbar { display: none; }
.tf-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tf-actions .zoom-btn { width: 30px; padding: 4px 0; font-size: 13px; }
.zoom-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 420px) {
  .tf-btn { padding: 4px 8px; }
  .tf-actions { gap: 3px; }
  .tf-actions .zoom-btn { width: 28px; }
}
.toast-success { border-color: var(--green); }
.toast-success::before { content: "\2713  "; color: var(--green); font-weight: 700; }

/* The trading chart runs edge to edge. The small-screen rule above gives every .chart-panel 12px of padding,
   which pushed the chart, its toolbars and the Buy/Sell bar in from the screen edges. */
.chart-panel.chart-fullscreen { padding: 0; width: 100%; max-width: none; }
