/* ===== MaoyiTool dashboard — design system (dark + light) ===== */
:root {
  --bg: #0a0d13;
  --surface: #0e131d;
  --topbar: #0f1626;        /* distinct elevated navy so the bar stands out */
  --surface-2: #141b28;
  --surface-3: #1c2534;
  --border: #212c3b;
  --line: rgba(138,152,171,.14);   /* Direction A: hairline for cards/tables */
  --text: #e7ecf4;
  --muted: #8a98ab;
  --accent: #4c9aff;
  --accent-2: #6f7cff;
  --green: #2bc281;
  --red: #ef5350;
  --gold: #f0b90b;
  --gold-lt: #ffd75e;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  --radius: 12px;
  --gap: 10px;
}

:root[data-theme="light"] {
  /* softened — no glaring pure white */
  --bg: #e7ebf2;
  --surface: #f5f7fb;
  --topbar: #ffffff;        /* clean white bar, distinct from the soft grey bg */
  --surface-2: #edf1f7;
  --surface-3: #e2e8f1;
  --border: #ccd5e2;
  --text: #1c2836;
  --muted: #5a6675;
  --accent: #2f6fe0;
  --accent-2: #5566e6;
  --green: #128a60;
  --red: #d23a4c;
  --gold: #9c7510;
  --gold-lt: #b8860b;
  --line: rgba(28,40,54,.12);
  --shadow: 0 10px 26px rgba(20, 40, 80, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-weight: 800; font-size: 16px; letter-spacing: .2px;
  background: linear-gradient(90deg, var(--gold), #ffd75e);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.status { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }

.ctrl {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; outline: none; transition: border-color .15s;
}
.ctrl:focus { border-color: var(--accent); }
.ctrl.bars { width: 72px; }
#symbol { min-width: 150px; }

.btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: transform .05s, filter .15s, box-shadow .15s;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.btn:hover { filter: brightness(1.08); }
a.btn { text-decoration: none; display: inline-block; }
.qa { display: flex; flex-wrap: wrap; gap: 8px; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 6px 9px; }
.btn.active { background: linear-gradient(180deg, var(--gold), #ffcb3d); color: #221a02; }

/* Crypto / Forex asset-class toggle (segmented control) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { background: transparent; color: var(--muted); border: none; cursor: pointer;
  padding: 6px 12px; font-size: 13px; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.active { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; }

.chk { color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; font-size: 12.5px; }
.chk input { accent-color: var(--accent); }

.badge { padding: 5px 11px; border-radius: 999px; font-weight: 700; font-size: 11.5px; letter-spacing: .4px; border: 1px solid transparent; }
.badge.paper { background: rgba(38,194,129,.14); color: var(--green); border-color: rgba(38,194,129,.35); }
.badge.live { background: rgba(255,90,106,.14); color: var(--red); border-color: rgba(255,90,106,.35); }
.price { font-weight: 800; font-size: 14px; color: var(--gold); font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; }

/* ===== Toolbar (trading controls, row 2) ===== */
.toolbar {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
/* 2 rows below the top bar: row 1 = data + chart tools · row 2 = bot options.
   each row stays on one line and scrolls horizontally if it overflows — no visible scrollbar. */
.tgroup { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tgroup::-webkit-scrollbar { display: none; }
/* hide all scrollbars app-wide (ugly) — scrolling still works via wheel/trackpad/drag */
*::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }
.tgroup > * { flex: 0 0 auto; }
.tgroup + .tgroup { border-top: 1px solid var(--border); padding-top: 8px; }
/* colour picker styled to match the toolbar buttons */
input[type="color"]#boxColor { height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
#boxColor::-webkit-color-swatch { border: none; border-radius: 4px; }
#boxColor::-webkit-color-swatch-wrapper { padding: 0; }

/* ===== Nav ===== */
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* ===== Layout ===== */
.layout { display: flex; min-height: 0; }
.chart-wrap { position: relative; flex: 1; min-width: 0; padding: 12px; }
/* Explicit viewport height (not a 100% flex chain) so the chart never overflows
   onto the History bar below it. */
/* fill the viewport down to the bottom (history panel removed) */
#chart { width: 100%; height: calc(100vh - 470px); min-height: 340px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.side { max-height: calc(100vh - 148px); }
.hint {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #221a02; padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: 12px; box-shadow: var(--shadow);
}

.side { width: 372px; border-left: 1px solid var(--border); background: var(--bg);
  overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .2px; }

.muted { color: var(--muted); }

.signal { font-size: 13px; margin-bottom: 10px; }
.signal .dir { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.signal .dir.long { color: var(--green); }
.signal .dir.short { color: var(--red); }
.signal .dir.neutral { color: var(--muted); }
.signal .blocked { color: var(--red); font-weight: 600; }
.signal .approved { color: var(--green); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.timeline .row { padding: 5px 0; border-top: 1px dashed var(--border); color: var(--muted); }
.timeline .pass { color: var(--green); }
.timeline .fail { color: var(--red); }

.balance { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.balance b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.pos.up { color: var(--green); } .pos.down { color: var(--red); } .pos.flat { color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); text-transform: uppercase; font-size: 11px; letter-spacing: .4px; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--surface-2); font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: var(--surface-2); }

.backtest .metric { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.backtest .metric b { font-variant-numeric: tabular-nums; }
.gate { margin-top: 10px; padding: 10px; border-radius: 8px; font-weight: 700; }
.gate.pass { background: rgba(38,194,129,.14); color: var(--green); }
.gate.fail { background: rgba(255,90,106,.14); color: var(--red); }
.gate ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

.bottom { margin: 4px 12px 12px; max-height: 150px; overflow-y: auto; padding: 10px 14px; }
.bottom .card-head { margin-bottom: 6px; }
.bottom .tbl th, .bottom .tbl td { padding: 4px 8px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 10px; z-index: 50; box-shadow: var(--shadow); font-weight: 500;
}
.hidden { display: none; }

/* ===== Login ===== */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(76,154,255,.12), transparent); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 32px; width: 340px; display: flex; flex-direction: column; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 26px; background: linear-gradient(90deg, var(--gold), #ffd75e); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-card input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn { padding: 11px; font-size: 14px; }
.login-err { color: var(--red); font-size: 13px; }

/* ===== Split login ===== */
.auth-body { display: block; }
.auth-split { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 100vh; }
@media (max-width: 860px) { .auth-split { grid-template-columns: 1fr; } .auth-left { display: none; } }

.auth-left {
  position: relative; padding: 44px; display: flex; flex-direction: column; justify-content: space-between;
  color: #e8eef6; overflow: hidden;
  background:
    radial-gradient(820px 460px at 18% 8%, rgba(111, 124, 255, .28), transparent),
    radial-gradient(700px 500px at 95% 100%, rgba(76, 154, 255, .18), transparent),
    linear-gradient(160deg, #161d31, #0b0e13 62%);
}
.auth-left-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-logo { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.auth-logo b { background: linear-gradient(90deg, var(--gold), #ffd75e); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-sub { font-size: 10px; letter-spacing: 2px; color: #8a98ab; border: 1px solid #2a3543; padding: 2px 7px; border-radius: 6px; }
.auth-pill { font-size: 11.5px; color: #8ff0c0; background: rgba(38, 194, 129, .14); border: 1px solid rgba(38, 194, 129, .35); padding: 5px 11px; border-radius: 999px; white-space: nowrap; }

.auth-hero h1 { font-size: 42px; line-height: 1.05; font-weight: 800; margin: 0 0 18px; }
.auth-hero .muted2 { color: #8a98ab; }
.auth-hero p { color: #aab6c6; max-width: 440px; font-size: 14.5px; line-height: 1.6; }

.auth-stats { display: flex; gap: 12px; }
.astat { background: rgba(255, 255, 255, .04); border: 1px solid #2a3543; border-radius: 14px; padding: 14px 20px; }
.astat b { display: block; font-size: 26px; font-weight: 800; color: #fff; }
.astat span { color: #8a98ab; font-size: 12px; }
.auth-foot { color: #6b7889; font-size: 12px; }

/* right panel: ambient gold+blue glow (was a flat dull var(--bg)) */
.auth-right { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 40px;
  background:
    radial-gradient(520px 440px at 72% 24%, rgba(240,185,11,.10), transparent 62%),
    radial-gradient(460px 420px at 26% 92%, rgba(76,99,255,.12), transparent 60%),
    var(--bg); }
.auth-right::before { content: ""; position: absolute; width: 300px; height: 300px; right: 6%; top: 15%;
  border-radius: 50%; background: rgba(240,185,11,.13); filter: blur(72px); z-index: 0;
  pointer-events: none; animation: authglow 12s ease-in-out infinite alternate; }
@keyframes authglow { from { transform: translateY(-16px) } to { transform: translateY(20px) } }
@media (prefers-reduced-motion: reduce) { .auth-right::before { animation: none; } }
/* form lifted onto a frosted console card */
.auth-form { position: relative; z-index: 1; width: 360px; display: flex; flex-direction: column; gap: 14px;
  padding: 30px 30px 28px;
  background: linear-gradient(180deg, rgba(22,30,48,.62), rgba(11,15,22,.80));
  border: 1px solid rgba(138,152,171,.20); border-radius: 18px;
  box-shadow: 0 26px 60px rgba(0,0,0,.50), inset 0 1px 0 rgba(255,255,255,.06);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.auth-form.hidden { display: none; }  /* beat .auth-form's display:flex when hidden */
.auth-form h2 { margin: 0; font-size: 28px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld span { font-size: 11px; letter-spacing: .6px; color: var(--muted); }
.fld input { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 13px; color: var(--text); font-size: 14px; }
.fld input:focus { outline: none; border-color: var(--accent); }
.auth-btn { padding: 13px; font-size: 15px; margin-top: 6px; }
.auth-link { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer;
  padding: 0; text-align: left; text-decoration: underline; align-self: flex-start; }
.auth-link:hover { color: var(--text); }
.reset-hint { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.auth-sec { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.sec-title { font-size: 11px; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.sec-item { color: var(--muted); font-size: 12.5px; padding: 3px 0; }

/* ===== Generic page ===== */
.page { padding: 18px; max-width: 1140px; margin: 0 auto; width: 100%; }
.page h2 { margin: 6px 0 16px; font-size: 20px; }

/* ===== News ===== */
.news-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 820px){ .news-grid { grid-template-columns: 1fr; } .side { width: 320px; } }
.news-col { display: flex; flex-direction: column; gap: 14px; }
.scrolllist { max-height: 260px; overflow-y: auto; }
.scrolllist.tall { max-height: 560px; }
.event { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px solid var(--surface-2); }
.impact { font-size: 10.5px; padding: 2px 9px; border-radius: 999px; font-weight: 700; height: fit-content; }
.impact.High { background: rgba(255,90,106,.16); color: var(--red); }
.impact.Medium { background: rgba(240,185,11,.16); color: var(--gold); }
.impact.Low { background: rgba(38,194,129,.16); color: var(--green); }
.headline { padding: 9px 0; border-top: 1px solid var(--surface-2); }
.headline a { color: var(--text); text-decoration: none; }
.headline a:hover { color: var(--accent); }

/* ===== Accounts / settings ===== */
.acct { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 720px){ .acct { grid-template-columns: repeat(2, 1fr); } }
.acct .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 12px; }
.acct .stat b { display: block; font-size: 18px; margin-top: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; max-width: 420px; }
.form-row label { color: var(--muted); font-size: 12px; }
.form-row input, .form-row select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; }
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent); }

/* ===== Bot decision log ===== */
.logs { max-height: 220px; overflow-y: auto; font-size: 12px; }
.logrow { padding: 5px 0; border-top: 1px solid var(--surface-2); }
.logrow .act { font-weight: 700; }
.logrow .act.entered { color: var(--green); }
.logrow .act.closed { color: var(--gold); }
.logrow .act.skipped { color: var(--muted); }
.logrow .t { color: var(--muted); font-size: 10.5px; }
.btn.xtiny { padding: 2px 8px; font-size: 11px; }
/* global log-action colors (used on the Logs page table + the dashboard panel) */
.act { font-weight: 700; }
.act.entered { color: var(--green); }
.act.closed { color: var(--gold); }
.act.skipped { color: var(--muted); }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex;
  align-items: center; justify-content: center; z-index: 60; }
.modal-overlay.hidden { display: none; }  /* override the flex above when hidden */
.modal { width: 380px; max-width: 92vw; }
.modal .metric { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.riskform { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.riskform .form-row { max-width: none; }
.riskform .form-actions { grid-column: 1 / -1; align-items: center; }
@media (max-width: 560px) { .riskform { grid-template-columns: 1fr; } }

/* ===== Accounts setup page ===== */
.accounts-layout { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .accounts-layout { grid-template-columns: 1fr; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.accounts-page .form-row, .form-grid .form-row { max-width: none; }
.form-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 14px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.acct.acct-2 { grid-template-columns: 1fr 1fr; }

/* ===== Strategies page ===== */
.strat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .strat-grid { grid-template-columns: 1fr; } }
.strat-card h3 { margin: 0 0 2px; font-size: 14px; }
.strat-card p { margin: 7px 0; font-size: 13px; line-height: 1.5; }
.strat-card .lbl { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.sitem { padding: 6px 0; border-top: 1px solid var(--surface-2); font-size: 12.5px; color: var(--muted); }
.sitem b { color: var(--text); }

/* ===== User chip ===== */
.user-chip { display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600;
  font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 999px; }
.user-chip .avatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; font-size: 11px; font-weight: 800; }

/* ===== Chart zoom tools ===== */
.chart-tools { position: absolute; top: 22px; right: 24px; display: flex; gap: 6px; z-index: 5; }
.chart-tools .btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  opacity: .9; font-size: 15px; line-height: 1; padding: 5px 10px; box-shadow: var(--shadow); }
.chart-tools .btn:hover { opacity: 1; }

/* ===== Login extras ===== */
.login-logo { font-size: 44px; }
.login-foot { font-size: 11px; margin-top: 6px; }

/* ===== Responsive: stack the dashboard + tighten on small screens ===== */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { width: 100%; max-height: none; border-left: none; border-top: 1px solid var(--border); }
  #chart { height: 56vh; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .brand { font-size: 14px; }
  .nav { overflow-x: auto; max-width: 100%; }
  .nav a { padding: 6px 8px; font-size: 12px; }
  .chart-wrap { padding: 8px; }
  #chart { height: 46vh; min-height: 300px; }
  .modal { width: 94vw; }
  .page, main { padding-left: 8px !important; padding-right: 8px !important; }
}

/* ============================================================
   Direction A — "Refined Console" polish + responsiveness
   (2026-07-26) — style-only, class-preserving. No HTML/JS
   changes: pagination, Closed column, chart lines, all fixes
   stay exactly as they are.
   ============================================================ */

/* Cards: hairline border + subtle top highlight, softer elevation */
.card {
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.04);
}
.card-head h3 { letter-spacing: .3px; }

/* Nav: cleaner active state with a gold underline (Direction A) */
.nav a { padding: 8px 12px; }
.nav a.active { background: transparent; color: var(--text); box-shadow: inset 0 -2px 0 var(--gold); }
.nav a:hover { background: var(--surface-2); }

/* Segmented control (Forex/Crypto/MT5): active = gold, matches the mockup */
.seg { border-color: var(--line); border-radius: 9px; }
.seg-btn.active { background: linear-gradient(180deg, var(--gold-lt), var(--gold)); color: #231a02; }

/* Primary CTA stays; add a gold "load/primary" affordance where used via .btn.active.
   Keep default buttons calm; refine ghost + radius. */
.btn { border-radius: 9px; }
.btn.ghost { border-color: var(--line); }
.ctrl { border-color: var(--line); border-radius: 9px; }
.ctrl:focus { border-color: var(--gold); }

/* Tables: tabular numerals, gentle row hover, hairline rules */
.tbl th { border-bottom: 1px solid var(--line); }
.tbl td { border-bottom: 1px solid var(--line); }
.tbl tbody tr:hover { background: var(--surface-2); }

/* Stat / KPI tiles used across History / Accounts / Settings */
.acct .stat, .metric, .astat {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.acct .stat b { font-variant-numeric: tabular-nums; }

/* Any wide table gets a horizontal scroll container feel on small screens */
.tbl { display: table; }

/* ---- Responsive: phone / tablet / desktop ---- */

/* Tablet & below: the dashboard's chart + side stack vertically */
@media (max-width: 1024px) {
  .layout { flex-direction: column; }
  .side { width: 100%; max-height: none; border-left: none; border-top: 1px solid var(--line); }
  #chart { height: 56vh; min-height: 320px; }
}

/* Narrow: header wraps, nav scrolls horizontally instead of squashing */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .nav { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .nav a { flex: 0 0 auto; padding: 7px 10px; }
  .status { margin-left: 0; flex-wrap: wrap; }
  .controls { gap: 6px; }
  .page { padding: 12px !important; }
  .card { padding: 12px; }
  /* KPI / stat grids collapse to two-up */
  .acct { grid-template-columns: repeat(2, 1fr) !important; }
  /* wide tables scroll inside their card instead of breaking the page */
  .card > .tbl, .tbl { min-width: 520px; }
  .card:has(> .tbl) { overflow-x: auto; }
}

/* Phone: single column everywhere, chart shorter, tighter type */
@media (max-width: 520px) {
  body { font-size: 13px; }
  #chart { height: 46vh; min-height: 260px; }
  .acct { grid-template-columns: 1fr !important; }
  .brand { font-size: 15px; }
  .price { font-size: 13px; }
  .card-head h3, .card h3 { font-size: 12.5px; }
}

/* ===== PRO layout (2026-08-17 redesign — reference: trade-terminal split, our palette) ===== */
.acct-pill { background: rgba(240,185,11,.12); border: 1px solid rgba(240,185,11,.4);
  color: var(--gold-lt); border-radius: 999px; padding: 4px 14px; font-weight: 700; font-size: 13px; }
.instr-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.instr-left, .instr-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.instr-mid { display: flex; align-items: baseline; gap: 12px; margin: 0 auto; }
.sym-big { font-size: 15px; font-weight: 700; min-width: 130px; }
.price-big { font-size: 26px; font-weight: 800; letter-spacing: .3px; }
.chip { border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700;
  background: var(--surface-3); }
.chip.up { color: var(--green); background: rgba(43,194,129,.12); }
.chip.dn { color: var(--red); background: rgba(239,83,80,.12); }
.daystat { font-size: 12px; color: var(--muted); }
.daystat b { color: var(--text); font-weight: 600; }
.pro-grid { align-items: stretch; }
.chart-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.chart-toolbar .sm2 { padding: 3px 9px; font-size: 12px; }
.vsep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
/* bottom tabs */
.tabbar { display: flex; gap: 4px; margin-top: 10px; border-bottom: 1px solid var(--border); }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 8px 14px; font-size: 13px; cursor: pointer; text-decoration: none; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--gold); }
.tab-btn:hover { color: var(--text); }
.tab-btn .cnt { background: var(--surface-3); border-radius: 999px; padding: 1px 8px;
  font-size: 11px; margin-left: 4px; }
.tabpane { padding: 8px 2px; min-height: 120px; max-height: 240px; overflow: auto; }
.tabpane.hidden { display: none; }
.pane-head { display: flex; justify-content: flex-end; margin-bottom: 4px; }
/* trade ticket */
.trade-panel .ticket { border: 1px solid rgba(240,185,11,.25); }
.ticket-step { font-size: 10.5px; letter-spacing: .12em; color: var(--muted);
  margin: 12px 0 6px; font-weight: 700; }
.muted-inline { font-weight: 400; letter-spacing: 0; text-transform: none; }
.dirseg { display: flex; gap: 8px; }
.dir-btn { flex: 1; padding: 9px 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); font-weight: 700; cursor: pointer; }
.dir-btn.buy.active { background: rgba(43,194,129,.16); border-color: var(--green); color: var(--green); }
.dir-btn.sell.active { background: rgba(239,83,80,.16); border-color: var(--red); color: var(--red); }
.type-btn { flex: 1; padding: 6px 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); font-size: 12px; cursor: default; }
.type-btn.active { border-color: var(--gold); color: var(--gold-lt); background: rgba(240,185,11,.10); }
.type-btn.off { opacity: .45; }
.ticket .ctrl { width: 100%; margin-top: 6px; }
.submit-btn { width: 100%; margin-top: 12px; padding: 11px 0; font-weight: 800;
  background: var(--gold); border-color: var(--gold); color: #131722; border-radius: 8px; }
.submit-btn:hover { background: var(--gold-lt); border-color: var(--gold-lt); }
@media (max-width: 900px) { .instr-mid { order: 3; width: 100%; } }

/* left vertical tool rail (reference layout) */
.chart-row { display: flex; gap: 0; }
.tool-rail { width: 44px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius) 0 0 var(--radius); background: var(--surface); }
.rail-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--muted); font-size: 15px; cursor: pointer; line-height: 1; }
.rail-btn:hover { background: var(--surface-3); color: var(--text); }
.rail-btn.active { border-color: var(--gold); color: var(--gold-lt); background: rgba(240,185,11,.10); }
.rail-btn.danger:hover { color: var(--red); }
.rail-color { width: 28px; height: 28px; padding: 1px; border: 1px solid var(--border);
  border-radius: 6px; background: none; }
.rail-gap { flex: 1; }
.chart-row #chart { border-radius: 0 var(--radius) var(--radius) 0; }

.mkt-filter { margin-left: auto; align-self: center; font-size: 12px; padding: 4px 8px; }

/* single-line instrument bar (operator 2026-08-17) */
.instr-bar { flex-wrap: nowrap; overflow-x: auto; gap: 10px; scrollbar-width: thin; }
.instr-left, .instr-right { flex-wrap: nowrap; }
.instr-mid { margin: 0 12px; flex: 0 0 auto; }
.price-big { font-size: 22px; }
.sym-big { min-width: 120px; max-width: 210px; }
.instr-bar .ctrl { padding: 5px 8px; }
.instr-bar .seg-btn { padding: 5px 10px; }
#mode { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1250px) { .daystat { display: none; } }
@media (max-width: 1080px) { #chgPill { display: none; } .price-big { font-size: 18px; } }

/* subtle ticket palette (operator: no shouting colors — soft blue like the reference) */
.trade-panel .ticket { border-color: var(--border); }
.type-btn.active { border-color: rgba(76,154,255,.55); color: var(--accent);
  background: rgba(76,154,255,.10); }
.submit-btn { background: rgba(76,154,255,.16); border: 1px solid rgba(76,154,255,.55);
  color: var(--accent); font-weight: 700; }
.submit-btn:hover { background: rgba(76,154,255,.28); border-color: var(--accent); color: #dce9ff; }
.dir-btn.buy.active { background: rgba(43,194,129,.10); }
.dir-btn.sell.active { background: rgba(239,83,80,.10); }
.acct-pill { background: rgba(76,154,255,.10); border-color: rgba(76,154,255,.4); color: var(--accent); }
.tab-btn.active { border-bottom-color: var(--accent); }
.rail-btn.active { border-color: rgba(76,154,255,.55); color: var(--accent); background: rgba(76,154,255,.10); }

/* taller chart + lower section pushed down; svg rail icons */
#chart { height: calc(100vh - 385px) !important; min-height: 420px; }
.tabpane { max-height: 190px; }
.rail-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn { display: flex; align-items: center; justify-content: center; }

/* larger rail icons (operator) + true scrolling panes */
.tool-rail { width: 52px; }
.rail-btn { width: 40px; height: 40px; }
.rail-btn svg { width: 22px; height: 22px; }
.rail-color { width: 34px; height: 34px; }
.tabpane { overflow-y: auto; }
#logsPane .logs, .tabpane .logs { max-height: none; overflow: visible; }
.ord-tag { font-size: 10px; border-radius: 5px; padding: 1px 6px; font-weight: 700; }
.ord-tag.venue { color: var(--green); background: rgba(43,194,129,.12); }
.ord-tag.armed { color: var(--accent); background: rgba(76,154,255,.12); }

/* ===== responsive: phones -> ultrawide ===== */
@media (min-width: 1700px) {
  .side { width: 420px; }
  .price-big { font-size: 26px; }
  #chart { height: calc(100vh - 360px) !important; }
}
@media (max-width: 1100px) {
  .pro-grid { flex-direction: column; }
  .side { width: 100% !important; max-height: none; border-left: none;
    border-top: 1px solid var(--border); display: grid;
    grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
  .side .card { margin: 0; }
  /* docs/179: the Open-trade ticket relocates below the chart on mobile (app.js
     moves it); the tappable header gets a visible affordance. */
  .card.ticket #otHead { cursor: pointer; user-select: none; }
  .chart-wrap .card.ticket { margin-top: 10px; }
  #chart { height: 52vh !important; min-height: 320px; }
}
@media (max-width: 700px) {
  .side { grid-template-columns: 1fr; }
  .instr-bar { flex-wrap: wrap; }
  .instr-mid { order: 3; width: 100%; justify-content: space-between; margin: 4px 0 0; }
  .daystat { display: inline; }
  .nav { display: none; }
  .tool-rail { width: 44px; }
  .rail-btn { width: 34px; height: 34px; }
  .rail-btn svg { width: 18px; height: 18px; }
  #chart { height: 46vh !important; min-height: 280px; }
  .tabpane { max-height: 160px; }
}

/* small-screen polish (operator screenshot ~360-620px) */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px; }
  .brand { font-size: 15px; }
  .status { margin-left: auto; gap: 6px; }
  .instr-bar { flex-wrap: wrap; overflow: visible; row-gap: 6px; padding: 8px 10px; }
  .instr-left { flex-wrap: wrap; width: 100%; }
  .instr-left #symbol { flex: 1 1 120px; min-width: 0; }
  .instr-right { flex-wrap: wrap; width: 100%; }
  .instr-right #strategy, .instr-right #runMode { flex: 1 1 40%; min-width: 0; }
  #startBtn { white-space: nowrap; }
  #mode { flex: 1 1 100%; max-width: none; }
  .btn { padding: 6px 10px; }
  .tabbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .tab-btn { white-space: nowrap; padding: 7px 10px; font-size: 12px; }
  .mkt-filter { flex: 0 0 auto; }
  .chart-wrap { padding: 8px; }
}
@media (max-width: 430px) {
  .rail-btn { width: 30px; height: 30px; }
  .rail-btn svg { width: 16px; height: 16px; }
  .tool-rail { width: 40px; padding: 6px 3px; }
  .price-big { font-size: 16px; }
  .acct-pill { font-size: 11px; padding: 3px 10px; }
}

/* hamburger nav on small screens (operator) */
.nav-burger { display: none; font-size: 17px; }
@media (max-width: 700px) {
  .nav-burger { display: inline-flex; }
  .topbar .nav { display: none; position: absolute; top: 54px; left: 8px;
    flex-direction: column; gap: 2px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 10px; padding: 8px 6px;
    z-index: 60; box-shadow: var(--shadow); min-width: 160px; }
  .topbar .nav.open { display: flex; }
  .topbar .nav a { padding: 8px 12px; border-radius: 8px; }
  .topbar .nav a:hover { background: var(--surface-3); }
}


/* docs/152 — the run button. It used emoji glyphs and hard-coded shouting green/red
   inline styles that ignored the theme (the same fault fixed on the tool rail). Now:
   one SVG that morphs play -> stop, theme colours, a clear working state, and no
   layout shift when the label changes. */
.btn.runbtn { display: inline-flex; align-items: center; gap: 7px; min-width: 116px;
  justify-content: center; background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text); box-shadow: none; }
.btn.runbtn .run-ico { width: 15px; height: 15px; flex: 0 0 15px; }
.btn.runbtn .run-ico .ico-play { fill: var(--green); }
.btn.runbtn .run-ico .ico-stop { display: none; }
.btn.runbtn .run-ico .ico-stop rect { fill: var(--red); }
.btn.runbtn:hover { border-color: var(--accent); background: var(--surface-2); }
.btn.runbtn.is-running { border-color: rgba(239,83,80,.5); }
.btn.runbtn.is-running .run-ico .ico-play { display: none; }
.btn.runbtn.is-running .run-ico .ico-stop { display: block; }
.btn.runbtn.is-busy { opacity: .6; pointer-events: none; }
.btn.runbtn.is-busy .run-ico { animation: runspin .8s linear infinite; transform-origin: 50% 50%; }
@keyframes runspin { to { transform: rotate(360deg); } }
