/* FoxxTreading production polish — stable final override layer. */
:root {
  --ui-radius-sm: 10px;
  --ui-radius-md: 14px;
  --ui-radius-lg: 20px;
  --ui-space-1: 6px;
  --ui-space-2: 10px;
  --ui-space-3: 14px;
  --ui-space-4: 20px;
  --ui-focus: 0 0 0 3px rgba(124, 92, 255, .22);
  --readable-muted: #514b61;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; max-width: 100%; overflow-x: clip; }
body { max-width: 100%; overflow-x: clip; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, [role="button"], .btn, .small-btn { min-height: 40px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus);
}
button:disabled { cursor: not-allowed; opacity: .58; }

/* Auth: visible state and usable controls. */
.auth-card { width: min(100%, 460px); }
.auth-form label, .auth-card .muted, .auth-card .auth-foot { color: #c6ccdf; font-size: 14px; }
.auth-form input::placeholder { color: #9da6bc; opacity: 1; }
.auth-form input { min-height: 46px; }
.auth-error { margin-top: 4px; text-align: left; }
.pw-eye { width: 44px !important; min-width: 44px; height: 40px; color: #f5f7ff; background: #31394d; border: 1px solid #59647d; border-radius: 9px; opacity: 1; display: grid; place-items: center; }
.pw-eye:hover, .pw-eye:focus-visible { color: #fff; background: #46516b; }
.auth-screen .eyebrow { font-size: 12px !important; letter-spacing: .08em; }

/* App shell hierarchy. */
.sidebar { width: 250px; padding: 22px 16px; }
.sidebar .brand { margin-bottom: 18px; }
.sidebar .nav { gap: 5px; }
.sidebar [data-page] {
  min-height: 43px;
  border-radius: 11px;
  padding: 10px 12px;
  line-height: 1.25;
}
.sidebar [data-page].active { box-shadow: inset 3px 0 0 var(--accent, #7c5cff); }
.main { width: 100%; min-width: 0; padding: 24px clamp(16px, 2.2vw, 32px); }
.topbar { gap: 14px; margin-bottom: 20px; }
.top-actions { gap: 8px; flex-wrap: wrap; }
.page.active { min-width: 0; }

/* Cards: quieter, consistent spacing. */
.panel, .stat-card, .bot-card, .hero-card, .side-card {
  border-radius: var(--ui-radius-lg);
}
.panel { padding: clamp(16px, 2vw, 22px); }
.panel-head { gap: 12px; margin-bottom: 16px; }
.panel-head > div { min-width: 0; }
.panel-head h3 { line-height: 1.25; }
.content-grid, .stats-grid { gap: 16px; }
.muted, small { line-height: 1.5; color: var(--readable-muted); font-size: 13px; }
.security-reminders .check-list li { color: #403a50; font-size: 14px; font-weight: 600; }
.security-reminders .check-list li::before { opacity: 1; }
.exchange-supported-panel, .exchange-connected-panel { margin-bottom: 16px; }
.exchange-supported-panel .exchange-grid { grid-template-columns: minmax(240px, 360px); margin-top: 4px; }
.exchange-card { color: #282335; min-height: 0; }
.exchange-card strong { font-size: 16px; }
.exchange-card .exchange-bots, .exchange-card small { color: var(--readable-muted); font-size: 13px; }
.exchange-connect-cta { width: 100%; margin-top: 4px; }
.exchange-account-empty { padding: 14px 16px; border: 1px dashed #c4bcd8; border-radius: 12px; background: #faf9fd; }
.longzong-scope { padding: 14px; border: 1px solid #cfc6e4; border-radius: 12px; background: #f8f6fc; }
.longzong-scope .field-label { display: block; margin-bottom: 8px; color: #342d43; font-size: 14px; font-weight: 700; }
.scope-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.scope-chips span { padding: 7px 10px; border: 1px solid #b9a9df; border-radius: 999px; background: #eee9fb; color: #443377; font-size: 13px; font-weight: 800; }
.longzong-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.longzong-summary-grid > div { padding: 12px; border: 1px solid #d8d1e7; border-radius: 10px; background: #faf9fd; }
.longzong-summary-grid small { display: block; margin-bottom: 3px; }
.longzong-summary-grid strong { color: #342d43; font-size: 14px; }
.modal-xl { max-height: min(92vh, 920px); overflow-y: auto; }
.modal-xl .bot-form-layout { padding-bottom: 24px; }
.modal-xl > .modal-actions { position: sticky; bottom: 0; z-index: 5; margin: 18px 0 0; padding: 14px 0 4px; background: rgba(248, 247, 252, .98); border-top: 1px solid #d8d1e7; backdrop-filter: blur(10px); }

/* Bot modal: wider desktop canvas, compact header, one scroll surface only. */
#bot-modal { padding: 12px 32px; }
#bot-modal .modal-xl { width: min(1280px, calc(100vw - 64px)); max-width: 1280px; max-height: min(920px, calc(100vh - 24px)); overflow-y: auto; overflow-x: clip; padding: 14px 22px 0; }
#bot-modal .bot-modal-head { margin-bottom: 6px; }
#bot-modal .balance-banner { min-height: 44px; margin-bottom: 5px; padding: 5px 10px; }
#bot-modal .balance-item strong { font-size: 16px; }
#bot-modal .bot-type-select { gap: 8px; margin-bottom: 8px; }
#bot-modal .bot-type-card { min-height: 64px; padding: 7px 10px; }
#bot-modal .bot-type-card small { line-height: 1.25; }
#bot-modal .bot-type-icon { font-size: 19px; }
#bot-modal .bot-form-layout { grid-template-columns: minmax(400px, 5fr) minmax(520px, 7fr); gap: 18px; padding-bottom: 2px; }
#bot-modal .bot-form { gap: 7px; }
#bot-modal .bot-form label { color: #40394d; font-size: 14px; font-weight: 700; letter-spacing: .01em; }
#bot-modal .bot-form small, #bot-modal .bot-type-card small, #bot-modal .signal-config-panel small { color: #554e63; font-size: 13px; }
#bot-modal .cost-limit-hint { display: block; margin-top: 3px; color: #6b4bb3 !important; font-weight: 700; line-height: 1.35; }
#bot-modal .bot-type-card strong { color: #2f2939; }
#bot-modal .longzong-risk-notice { margin-bottom: 8px; padding: 8px 10px; }
#bot-modal .longzong-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 8px 0 10px; }
#bot-modal .longzong-summary-card { min-width: 0; min-height: 58px; padding: 8px 9px; border: 1px solid #d8d1e7; border-radius: 10px; background: #faf9fd; }
#bot-modal .longzong-summary-card small { display: block; margin-bottom: 2px; color: #625b72; font-size: 11px; }
#bot-modal .longzong-summary-card strong { display: block; color: #2f2939; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
#bot-modal .tg-examples.compact { margin-top: 0; }
#bot-modal .tg-examples.compact h5 { margin: 0 0 6px; }
#bot-modal .longzong-signal-example { margin: 0; padding: 9px 11px; border: 1px solid #cfc6e4; border-radius: 10px; background: #f6f3fb; }
#bot-modal .longzong-signal-example figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; color: #4d3d69; font-size: 11px; font-weight: 800; }
#bot-modal .longzong-signal-example figcaption em { padding: 2px 7px; color: #493477; background: #e9e2f7; border-radius: 999px; font-size: 10px; font-style: normal; letter-spacing: .04em; }
#bot-modal .longzong-signal-example pre { margin: 0; padding: 0; color: #2f2939 !important; background: transparent; border: 0; font: 700 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
#bot-modal .tg-examples.compact > p { margin: 6px 0 0; line-height: 1.4; }
#bot-modal .bot-basic-grid, #bot-modal .bot-account-cost-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
#bot-modal .bot-basic-grid > label, #bot-modal .bot-account-cost-grid > label { min-width: 0; }
#bot-modal .api-key-mode-conflict { position: static !important; display: block; width: 100%; max-width: none; margin: 0; padding: 9px 11px; color: #7a2333; background: #fff1f3; border: 1px solid #d89aa5; border-left: 4px solid #b9384d; border-radius: 10px; box-shadow: none; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
#bot-modal .api-key-mode-conflict[hidden] { display: none !important; }
#bot-modal #api-key-select.field-invalid { border-color: #b9384d !important; box-shadow: 0 0 0 3px rgba(185,56,77,.13); }
#bot-modal .compact-source-field .notice, #bot-modal .tv-uid-note { padding: 7px 9px; }
#bot-modal .compact-leverage-field .leverage-input { min-height: 48px; padding: 7px 10px; }
#bot-modal .longzong-leverage-grid { display: grid; gap: 8px; padding: 10px; border: 1px solid #cfc6e4; border-radius: 12px; background: #f8f6fc; }
#bot-modal .longzong-leverage-grid[hidden] { display: none; }
#bot-modal .longzong-leverage-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
#bot-modal .longzong-leverage-grid > label { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px; }
#bot-modal .longzong-leverage-grid .leverage-input { min-height: 44px; padding: 6px 9px; }
#bot-modal .longzong-leverage-grid .leverage-hint { min-width: 104px; text-align: right; }
#bot-modal .signal-config-panel { min-width: 0; max-height: none !important; overflow: visible !important; overflow-x: clip !important; }
#bot-modal .tv-config, #bot-modal .tg-config, #bot-modal .tv-alert-section, #bot-modal .tv-alert-list { min-width: 0; overflow: visible; }
#bot-modal .webhook-url-box { min-width: 0; width: 100%; overflow: hidden; }
#bot-modal .tv-alert-code { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; min-width: 0; width: 100%; overflow: visible; }
#bot-modal .tv-alert-code .icon-btn { width: 44px; min-width: 44px; height: 44px; flex-shrink: 0; border-radius: 0 9px 9px 0; }
#bot-modal .webhook-url-box code, #bot-modal .tv-alert-code code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2f2750 !important; font-weight: 700; }
#bot-modal .webhook-url-box, #bot-modal .tv-alert-code { background: #f3f0f8 !important; border: 1px solid #b9aecf; }
#bot-modal .webhook-url-box .icon-btn, #bot-modal .tv-alert-code .icon-btn { color: #3f326d; background: #fff; border-color: #aa9bc6; }
#bot-modal .webhook-network-warning { margin-top: 8px; color: #61400a; background: #fff8e7; border-left: 4px solid #c27a00; }
#bot-modal .secret-preview-box { grid-template-columns: minmax(0, 1fr) auto auto; }
#bot-modal .tv-alert-disclosure, #bot-modal .bot-advanced-disclosure { margin-top: 6px; border: 1px solid #d3cbe3; border-radius: 12px; background: #faf9fd; }
#bot-modal .tv-alert-disclosure > summary, #bot-modal .bot-advanced-disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; color: #342d43; cursor: pointer; list-style: none; }
#bot-modal .tv-alert-disclosure > summary::-webkit-details-marker, #bot-modal .bot-advanced-disclosure > summary::-webkit-details-marker { display: none; }
#bot-modal .tv-alert-disclosure > summary::after, #bot-modal .bot-advanced-disclosure > summary::after { content: '展開'; color: #5d3da8; font-size: 12px; font-weight: 800; }
#bot-modal .tv-alert-disclosure[open] > summary::after, #bot-modal .bot-advanced-disclosure[open] > summary::after { content: '收合'; }
#bot-modal .tv-alert-disclosure summary span, #bot-modal .bot-advanced-disclosure summary span { min-width: 0; }
#bot-modal .tv-alert-disclosure summary strong, #bot-modal .tv-alert-disclosure summary small, #bot-modal .bot-advanced-disclosure summary strong, #bot-modal .bot-advanced-disclosure summary small { display: block; }
#bot-modal .bot-advanced-body { padding: 10px 12px 12px; border-top: 1px solid #e1dbe9; }
#bot-modal .tv-alert-disclosure .tv-alert-section { padding: 12px; border-top: 1px solid #e1dbe9; }
#bot-modal .tv-alert-fullwidth .tv-alert-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 18px; }
#bot-modal .tv-alert-group { min-width: 0; }
#bot-modal .tv-alert-group h5 { margin: 0 0 8px; }
#bot-modal .tv-alert-group .tv-alert-row:last-child { margin-bottom: 0; }
#bot-modal .modal-xl > .modal-actions { position: static; margin: 2px -22px 0; padding: 8px 22px calc(10px + env(safe-area-inset-bottom)); background: rgba(248,247,252,.98); border-top: 1px solid #d8d1e7; }
body.modal-open { overflow: hidden; }
.site-dialog-backdrop { z-index: 3000; }
.site-dialog-card { position: relative; z-index: 1; width: min(460px, calc(100vw - 32px)); padding: 24px; opacity: 1 !important; filter: none !important; }
.site-dialog-backdrop.open { background: rgba(23,21,31,.56); backdrop-filter: blur(5px); }
.site-dialog-backdrop.open .site-dialog-card { background: #fff !important; color: #272233 !important; }
.site-dialog-card h3 { color: #272233 !important; }
.site-dialog-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: #fff4d6; font-size: 23px; }
.site-dialog-message { white-space: pre-line; color: #4f485d; line-height: 1.65; }
.site-dialog-card .modal-actions { margin-top: 18px; }
.site-dialog-card .danger-btn { color: #fff !important; background: #a93446 !important; border-color: #a93446 !important; box-shadow: none !important; }

.setup-next-step { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 16px; border-color: #bba9e8; background: linear-gradient(135deg, #faf8ff, #f2edff); }
.setup-next-step[hidden] { display: none; }
.setup-next-step h3 { margin: 2px 0 5px; }
.setup-next-step p { margin: 0; }
.setup-next-step button { flex: 0 0 auto; }
.longzong-risk-notice { border-left: 4px solid #c27a00; background: #fff8e7; color: #61400a; }

.password-field { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.password-field .icon-btn { width: 44px; min-width: 44px; height: 44px; color: #403a50; background: #f0ecf8; border: 1px solid #c7bddc; }
.password-rules { align-self: end; }
.account-actions { display: flex; justify-content: flex-end; margin: 14px 0; }
.learning-card { display: flex; flex-direction: column; }
.learning-card small { margin-top: auto; padding-top: 10px; }
.learning-action { width: 100%; margin-top: 12px; }

#longzong-settings-panel .panel-head { margin-bottom: 10px; }
#longzong-settings-panel .longzong-control-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr); gap: 12px; align-items: stretch; margin-bottom: 12px; }
#longzong-settings-panel .longzong-service-state { padding: 10px 12px; border: 1px solid #d8d1e7; border-radius: 12px; background: #faf9fd; }
#longzong-settings-panel .longzong-service-state small { display: block; margin-bottom: 2px; color: #625b72; font-weight: 700; }
#longzong-settings-panel .longzong-service-state strong { display: block; color: #2f2939; font-size: 15px; }
#longzong-settings-panel .longzong-service-state span { display: block; margin-top: 4px; color: #554e63; font-size: 13px; }
#longzong-settings-panel .longzong-telegram-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
#longzong-settings-panel #lz-bind-status { margin: 0; }
#longzong-settings-panel #lz-bind-btn { min-width: 142px; }

/* Backtest: chart-first replay workspace. */
.backtest-controls-panel { margin-bottom: 14px; }
.backtest-controls { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; }
.backtest-controls label { color: #40394d; font-size: 12px; font-weight: 750; }
.backtest-controls input, .backtest-controls select { width: 100%; min-height: 40px; margin-top: 4px; }
.backtest-symbol-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.backtest-symbol-controls label { display: flex; align-items: center; gap: 6px; padding: 7px 10px; color: #342d43; background: #f4f0fb; border: 1px solid #cbbfe3; border-radius: 10px; font-size: 13px; font-weight: 800; }
.backtest-symbol-controls input[type="number"] { width: 62px; min-height: 32px; padding: 5px 7px; }
.backtest-run-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 10px; }
.backtest-run-row button { min-width: 132px; }
.backtest-stats .stat-card { background: #fff; border-color: #d4cce2; opacity: 1 !important; animation: none !important; transform: none !important; }
.backtest-stats .stat-card span, .backtest-stats .stat-card small { color: #514b61; opacity: 1; }
.backtest-stats .stat-card strong { color: #2c2637; opacity: 1; }
.backtest-scroll-hint { display: none; margin-top: 5px; color: #625b72; }
.backtest-disclaimer { margin-top: 0; border-left: 4px solid #7c5cff; }
.backtest-stats { margin-bottom: 10px; }
.backtest-funnel { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; align-items: baseline; margin: 0 0 14px; border-left: 4px solid #7c5cff; }
.backtest-funnel strong { color: #3b3151; }
.backtest-funnel span { color: #534969; font-weight: 750; }
.backtest-funnel small { grid-column: 1 / -1; color: #655d72; }
.backtest-excluded-panel { margin: 0 0 14px; padding: 0; overflow: hidden; }
.backtest-excluded-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.backtest-excluded-panel > summary::-webkit-details-marker { display: none; }
.backtest-excluded-panel > summary span:first-child { display: flex; align-items: center; gap: 9px; }
.backtest-excluded-panel > summary small { color: #655d72; }
.backtest-excluded-body { padding: 0 14px 14px; border-top: 1px solid #ded7e9; }
.backtest-excluded-body .filters { display: flex; justify-content: flex-end; padding: 10px 0; }
.backtest-excluded-body select { min-height: 36px; }
.backtest-excluded-list { display: grid; gap: 7px; max-height: 420px; overflow-y: auto; }
.backtest-excluded-row { padding: 10px 12px; background: #fff; border: 1px solid #ddd6e9; border-radius: 10px; }
.backtest-excluded-row > div { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.backtest-excluded-row time { margin-left: auto; color: #6b6478; font-size: 11px; }
.backtest-excluded-row p { margin: 7px 0 3px; color: #3d3549; font-weight: 700; }
.backtest-excluded-row small { display: block; color: #625b6e; white-space: pre-wrap; overflow-wrap: anywhere; }
.backtest-excluded-row em { display: block; margin-top: 5px; color: #7c5cff; font-size: 10px; font-style: normal; font-weight: 750; }
.backtest-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(350px, 1fr); gap: 14px; align-items: start; }
.backtest-chart-panel, .backtest-list-panel { min-width: 0; }
.backtest-message-compare { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid #ddd6e9; }
.backtest-message-compare .panel-head { margin-bottom: 8px; }
#backtest-original-message { margin: 0; min-height: 104px; max-height: 260px; overflow: auto; padding: 12px; border: 1px solid #d9d1e5; border-radius: 10px; background: #f7f5fb; color: #342d40; font: 600 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.backtest-parsed-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.backtest-parsed-summary > * { padding: 5px 7px; border-radius: 7px; background: #f1edf8; color: #51475f; font-size: 10px; }
.backtest-parsed-summary strong { background: #e7def8; color: #5a3f91; }
.backtest-trades-head { margin-top: 0; }
.backtest-chart-shell { width: 100%; overflow-x: auto; border: 1px solid #2d2e3a; border-radius: 14px; background: #090a0f; box-shadow: inset 0 0 0 1px rgba(255,255,255,.025); }
#backtest-chart { display: block; max-width: none; }
.backtest-detail { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; padding: 10px 12px; color: #514b61; background: #faf9fd; border: 1px solid #ddd6e9; border-radius: 10px; }
.backtest-detail strong { color: #2e2838; }
.backtest-detail small { margin-left: auto; }
.backtest-trades { display: grid; gap: 6px; max-height: 580px; overflow-y: auto; padding-right: 3px; }
.backtest-trade-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px 58px 70px; align-items: center; gap: 7px; width: 100%; min-height: 58px; padding: 8px 10px; color: #352f40; text-align: left; background: #fff; border: 1px solid #ddd6e9; border-radius: 10px; }
.backtest-trade-row:hover, .backtest-trade-row.active { background: #f3effc; border-color: #9077cf; }
.backtest-trade-row span:first-child { min-width: 0; }
.backtest-trade-row strong, .backtest-trade-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backtest-trade-row small { color: #6a6376; font-size: 10px; }
.backtest-side, .backtest-outcome { text-align: center; font-size: 11px; font-weight: 850; }
.backtest-side.buy { color: #18794e; }.backtest-side.sell { color: #b42335; }
.backtest-outcome.tp { color: #18794e; }.backtest-outcome.sl { color: #b42335; }.backtest-outcome.breakeven { color: #0369a1; }.backtest-outcome.overlap_skipped, .backtest-outcome.unfilled { color: #6a6376; }
.backtest-trade-row b { text-align: right; font-size: 12px; }

/* Compact pre-flight confirmation: summary, not a second full-page form. */
#bot-preflight-modal { padding: 24px; }
#bot-preflight-modal .preflight-modal { width: min(720px, calc(100vw - 48px)); max-width: 720px; max-height: min(680px, calc(100vh - 48px)); padding: 16px 18px 0; overflow-y: auto; overflow-x: clip; scrollbar-width: thin; scrollbar-color: #9b87d5 transparent; scroll-padding-bottom: 18px; }
#bot-preflight-modal .panel-head { margin-bottom: 8px; }
#bot-preflight-modal .preflight-hero { margin: 8px 0 10px; padding: 10px 12px; border-radius: 14px; }
#bot-preflight-modal .preflight-orb { width: 42px; height: 42px; border-radius: 12px; font-size: 21px; }
#bot-preflight-modal .preflight-hero strong { font-size: 15px; }
#bot-preflight-modal .preflight-summary { gap: 7px; margin-bottom: 8px; }
#bot-preflight-modal .preflight-chip { padding: 8px 10px; border-radius: 10px; }
#bot-preflight-modal .preflight-chip small { margin-bottom: 1px; }
#bot-preflight-modal .preflight-chip strong { font-size: 13px; }
#bot-preflight-modal .preflight-checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0 10px; }
#bot-preflight-modal .preflight-check { align-self: stretch; min-height: 0; padding: 8px 10px; border-radius: 10px; }
#bot-preflight-modal .preflight-check > div { min-width: 0; }
#bot-preflight-modal .preflight-check strong, #bot-preflight-modal .preflight-check small { overflow-wrap: anywhere; }
#bot-preflight-modal .preflight-check .mark { width: 19px; height: 19px; }
#bot-preflight-modal .preflight-check small { line-height: 1.35; }
#bot-preflight-modal .notice { padding: 9px 11px; }
#bot-preflight-modal .modal-actions { position: static; margin: 8px -18px 0; padding: 10px 18px calc(14px + env(safe-area-inset-bottom)); background: rgba(248,247,252,.98); border-top: 1px solid #d8d1e7; }

/* Bot management: compact, full-width and operationally clear. */
.bots-panel { grid-column: 1 / -1; width: 100%; }
.bots-panel, .bots-panel .bot-card { box-shadow: none !important; }
.bots-panel .bot-list { gap: 10px; }
.bots-panel .bot-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(420px, 2fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid #d2cbe0 !important;
  border-radius: 14px;
  background: #fff !important;
  transform: none !important;
}
.bot-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bot-identity .bot-icon { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 12px; }
.bot-main { min-width: 0; }
.bot-main strong { display: block; color: #272233; font-size: 15px; overflow-wrap: anywhere; }
.bot-main p { margin: 3px 0 0; color: #625b72; font-size: 12px; line-height: 1.4; }
.bot-metrics { display: grid; grid-template-columns: 1.3fr 1.3fr .9fr .65fr .85fr; gap: 8px; margin: 0; }
.bot-metrics div { min-width: 0; padding: 7px 9px; border-left: 1px solid #e1dce9; }
.bot-metrics dt { color: #70697e; font-size: 10px; font-weight: 700; }
.bot-metrics dd { margin: 2px 0 0; color: #2f293b; font-size: 12px; font-weight: 750; overflow-wrap: anywhere; }
.bot-metrics dd small { display: block; color: #6b6478; font-size: 10px; font-weight: 600; }
.bot-status-line { grid-column: 1; display: grid; gap: 4px; color: #625b72; font-size: 11px; }
.bot-status-line span { display: block; }
.bot-actions { display: flex; align-items: stretch; gap: 10px; padding-left: 14px; border-left: 1px solid #d8d1e2; }
.bot-actions-primary { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.bot-actions button { min-height: 40px; border-radius: 9px; padding: 8px 11px; font-weight: 750; white-space: nowrap; box-shadow: none !important; }
.bot-action-main { color: #553a08; background: #fff4d6; border: 1px solid #d7a94e; }
.bot-action-main.play { color: #14532d; background: #e8f8ed; border-color: #71b987; }
.bot-action-secondary { color: #38256d; background: #f0ebfb; border: 1px solid #a895d5; }
.bot-action-danger { color: #8c2635; background: #fff1f3; border: 1px solid #d58a96; }
.bot-action-main:hover, .bot-action-secondary:hover, .bot-action-danger:hover { filter: brightness(.97); }

/* Tables never break the viewport. */
.table-wrap, .table-scroll, .panel:has(> table) { overflow-x: auto; overscroll-behavior-inline: contain; }
table { min-width: 680px; border-collapse: separate; border-spacing: 0; }
th { white-space: nowrap; font-size: 12px; letter-spacing: .02em; }
td { vertical-align: top; }
td, th { padding: 11px 12px; }

/* Forms and long values. */
.bot-form { gap: 14px; }
.bot-form input, .bot-form select, .bot-form textarea { min-height: 44px; width: 100%; }
.bot-form textarea { min-height: 110px; resize: vertical; }
code, .webhook-url-box, .webhook-copy-box { overflow-wrap: anywhere; word-break: break-word; }
.webhook-box { min-width: 0 !important; width: 100%; }
.filters { gap: 10px; flex-wrap: wrap; }
.filters > * { min-width: min(160px, 100%); }

/* Status and destructive controls. */
.pill { white-space: nowrap; }
.danger, .danger-btn, button[data-danger] { font-weight: 700; }
.notice.error, .notice.fail { border-left: 4px solid var(--red, #e5484d); }
.notice.ok { border-left: 4px solid var(--green, #30a46c); }

.app-update-banner { position: fixed; z-index: 4000; right: 20px; bottom: 20px; display: flex; align-items: center; gap: 16px; max-width: min(520px, calc(100vw - 32px)); padding: 14px 16px; color: #2e2839; background: #fff; border: 1px solid #9f8bcf; border-radius: 14px; box-shadow: 0 16px 44px rgba(37,27,55,.22); }
.app-update-banner[hidden] { display: none; }
.app-update-banner div { display: grid; gap: 2px; }
.app-update-banner strong { font-size: 14px; }
.app-update-banner span { color: #554e63; font-size: 13px; }
.app-update-banner button { flex: 0 0 auto; }

/* Toast must not look like hidden stale content to assistive tech. */
.toast { max-width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.toast:not(.show) { visibility: hidden; }
.toast.show { visibility: visible; }

/* Dashboard result list: useful but should not dominate the first screen. */
.wins-panel .wins-body { max-height: 430px; overflow-y: auto; padding-right: 4px; }
.win-row { display: grid; grid-template-columns: auto minmax(78px, 1fr) auto auto; align-items: center; gap: 7px 10px; margin-bottom: 8px; padding: 11px 12px; border: 1px solid #ddd8ea; border-radius: 12px; background: #f8f6fc; color: #292638; }
.win-icon { grid-row: span 2; font-size: 18px; }
.win-symbol { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.win-side { justify-self: start; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; }
.win-side.long { background: #dcfce7; color: #166534; }
.win-side.short { background: #ffe4e6; color: #9f1239; }
.win-testnet { font-size: 11px; }
.win-target { grid-column: 2 / span 2; color: #5f596f; font-size: 12px; }
.win-roi { justify-self: end; color: #15803d; font-family: ui-monospace, monospace; font-size: 13px; font-weight: 800; }
.win-time { justify-self: end; color: #6e687d; font-family: ui-monospace, monospace; font-size: 11px; }
.mobile-position-list { display: none; }
.mobile-position-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #f8f6fc; }
.mobile-position-head { display: flex; align-items: center; gap: 8px; }
.mobile-position-head .pill:last-child { margin-left: auto; }
.mobile-position-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 0; }
.mobile-position-card dl div { min-width: 0; }
.mobile-position-card dt { color: #6e687d; font-size: 11px; }
.mobile-position-card dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.empty-state.compact { padding: 18px; border: 1px dashed #cbc4dc; border-radius: 12px; color: #625c72; text-align: center; }
.exchange-acct-right .icon-btn { width: 44px !important; min-width: 44px; height: 44px; }

@media (max-width: 1250px) {
  .bots-panel .bot-card { grid-template-columns: minmax(220px, 1fr) minmax(420px, 2fr); }
  .bot-status-line { grid-column: 1; }
  .bot-actions { grid-column: 2; justify-content: flex-end; padding-left: 0; border-left: 0; }
}

/* Mobile/tablet: horizontal nav instead of a very tall sidebar. */
@media (max-width: 1050px) {
  #bot-modal { padding: 12px; }
  #bot-modal .modal-xl { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  #bot-modal .bot-form-layout, #bot-modal .bot-basic-grid, #bot-modal .bot-account-cost-grid { grid-template-columns: 1fr; }
  #bot-modal .bot-type-select { grid-template-columns: 1fr; }
  #bot-modal .tv-alert-fullwidth .tv-alert-list { grid-template-columns: 1fr; }
  #bot-modal .longzong-leverage-grid > label { grid-template-columns: 1fr; gap: 4px; }
  #bot-modal .longzong-leverage-head { align-items: flex-start; flex-direction: column; }
  #bot-modal .longzong-summary-grid { grid-template-columns: 1fr; }
  .backtest-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backtest-layout { grid-template-columns: 1fr; }
  .backtest-chart-shell { overflow-x: auto; }
  #longzong-settings-panel .longzong-control-grid, #longzong-settings-panel .longzong-telegram-row { grid-template-columns: 1fr; }
  #longzong-settings-panel #lz-bind-btn { width: 100%; }
  #bot-modal .modal-xl > .modal-actions { position: static; margin: 12px -22px 0; }
  body.logged-in .app-shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand { margin: 0 0 10px; }
  .sidebar .brand p, .sidebar .side-card { display: none; }
  .sidebar .nav {
    display: flex !important;
    flex-flow: row nowrap !important;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 5px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }
  .sidebar [data-page] {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .sidebar [data-page].active { box-shadow: inset 0 -3px 0 var(--accent, #7c5cff); }
  .topbar { flex-direction: row; align-items: center; }
  .main { padding-top: 18px; }
}

@media (max-width: 720px) {
  .main { padding: 14px 12px 28px; }
  .topbar { align-items: flex-start; }
  .topbar h2 { font-size: clamp(21px, 7vw, 28px); }
  .top-actions { width: 100%; align-items: center; }
  .top-actions button { flex: 1 1 140px; }
  .top-actions #logout-btn { flex: 0 0 auto; width: auto; min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .content-grid, .stats-grid, .bot-form.two-col { grid-template-columns: 1fr !important; }
  .bots-panel .bot-card { grid-template-columns: 1fr; gap: 12px; }
  .bot-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bot-status-line, .bot-actions { grid-column: 1; }
  .bot-actions { align-items: stretch; flex-direction: column; }
  .bot-actions-primary { width: 100%; }
  .bot-action-danger { width: 100%; }
  .setup-next-step { align-items: stretch; flex-direction: column; }
  .setup-next-step button { width: 100%; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-head > button, .panel-head > .actions { width: 100%; }
  .panel-head > button { justify-content: center; }
  .modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; }
  #bot-preflight-modal { padding: 12px; }
  #bot-preflight-modal .preflight-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  #bot-preflight-modal .preflight-summary, #bot-preflight-modal .preflight-checklist { grid-template-columns: 1fr; }
  #bot-preflight-modal .modal-actions { position: static; }
  .toast { right: 14px; left: 14px; bottom: 14px; }
  .app-update-banner { right: 12px; left: 12px; bottom: 12px; align-items: stretch; flex-direction: column; }
  .app-update-banner button { width: 100%; }
}

@media (max-width: 560px) {
  .backtest-controls { grid-template-columns: 1fr; }
  .backtest-symbol-controls { display: grid; grid-template-columns: 1fr; }
  .backtest-trade-row { grid-template-columns: minmax(0, 1fr) 30px 52px 64px; padding: 7px 8px; }
  .backtest-detail small { width: 100%; margin-left: 0; }
  .backtest-run-row { align-items: stretch; flex-direction: column; }
  .backtest-run-row button { width: 100%; }
  .backtest-scroll-hint { display: block; }
  .backtest-funnel { grid-template-columns: 1fr; }
  .backtest-funnel small { grid-column: 1; }
  .backtest-excluded-row time { width: 100%; margin-left: 0; }
}

@media (max-width: 420px) {
  .auth-screen { padding: 16px 12px; }
  .auth-card { padding: 20px 16px; }
  .form-line { align-items: flex-start; gap: 10px; }
  button, [role="button"], .btn, .small-btn { min-height: 44px; }
  .panel { border-radius: 16px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .stat-card { min-height: 104px; padding: 12px 14px; }
  .stat-card strong { font-size: clamp(21px, 7vw, 30px); overflow-wrap: anywhere; }
  .stat-card span, .stat-card small { font-size: 11px; }
  .sidebar .nav { position: relative; padding-right: 14px; }
  .sidebar .nav::after { content: ''; display: block; flex: 0 0 14px; min-width: 14px; pointer-events: none; }
  .desktop-positions-table { display: none; }
  .mobile-position-list { display: grid; gap: 10px; }
  .win-row { grid-template-columns: auto minmax(70px, 1fr) auto; }
  .win-testnet { display: none; }
  .win-target { grid-column: 2 / -1; }
  .win-roi { grid-column: 2; justify-self: start; }
  .win-time { grid-column: 3; }
  .exchange-account-card { align-items: stretch; flex-direction: column; gap: 12px; padding: 14px; min-width: 0; }
  .exchange-acct-left { align-items: flex-start; min-width: 0; }
  .exchange-acct-left > div:last-child { min-width: 0; }
  .exchange-acct-left small { display: block; overflow-wrap: anywhere; }
  .exchange-acct-right { justify-content: flex-end; width: 100%; gap: 8px; }
  .exchange-acct-right .pill { margin-right: auto; }
  .wins-panel .wins-body { max-height: none; overflow: visible; padding-right: 0; }
}

.billing-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px}.billing-layout .large{grid-column:1/-1}.billing-current-card{display:flex;flex-wrap:wrap;gap:10px 16px;align-items:center}.billing-current-card strong{font-size:22px;color:#2e2448}.billing-current-card small{flex-basis:100%;color:#9a4160}.billing-plans{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.billing-plan-card{border:1px solid #ddd6e9;border-radius:18px;padding:16px;background:rgba(255,255,255,.8);display:grid;gap:10px}.billing-plan-card h4{margin:0;font-size:20px}.billing-plan-card ul{margin:0;padding-left:20px;color:#666176}.billing-payment-form{display:grid;gap:10px;margin-top:12px}.billing-payment-info{display:grid;gap:6px}.billing-payment-info code{overflow-wrap:anywhere;color:#563f93}.admin-plan-settings{display:grid;gap:10px}.admin-plan-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;align-items:end;border:1px solid #e4dfec;border-radius:14px;padding:14px}.admin-plan-row>strong{grid-column:1/-1;font-size:18px}.admin-plan-row input[type="checkbox"],.admin-enforcement-card input[type="checkbox"]{width:18px!important;height:18px!important;min-height:18px!important;padding:0!important;accent-color:#7357c8}.admin-plan-row label:has(input[type="checkbox"]){display:flex;flex-direction:row;align-items:center;gap:7px}.admin-subscription-setter{display:grid;grid-template-columns:minmax(220px,1fr) 160px 220px auto;gap:10px;align-items:end;margin:18px 0;padding-top:16px;border-top:1px solid #e4dfec}.admin-subscription-setter label{display:grid;gap:4px;font-size:12px;color:#6f6980}.admin-plan-row>button{justify-self:start}.admin-plan-row label,.admin-usdt-settings label{display:grid;gap:4px;font-size:12px;color:#6f6980}.admin-usdt-settings{display:grid;grid-template-columns:140px minmax(260px,1fr) 160px minmax(180px,1fr);gap:10px;align-items:end;margin:16px 0}.admin-enforcement-card{grid-column:1/-1!important;display:flex!important;flex-direction:row!important;align-items:flex-start;gap:10px;padding:12px;border:1px solid #e5b9c8;border-radius:14px;background:#fff7fa}.admin-enforcement-card span{display:grid;gap:3px}.admin-enforcement-card small{color:#8b5367}.admin-usdt-settings>button{justify-self:start}
@media(max-width:900px){.billing-layout{grid-template-columns:1fr}.billing-plans{grid-template-columns:1fr}.admin-plan-row,.admin-usdt-settings,.admin-subscription-setter{grid-template-columns:1fr 1fr}.admin-plan-row strong{grid-column:1/-1}}
@media(max-width:560px){.admin-plan-row,.admin-usdt-settings,.admin-subscription-setter{grid-template-columns:1fr}.billing-current-card{display:grid}}

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