:root {
  color-scheme: dark;
  --base: #15171c;
  --panel: #1d2027;
  --control: #272b33;
  --edge: #373d48;
  --ink: #e4e7ed;
  --muted: #b0b8c5;
  --quiet: #8f9aa9;
  --teal: #83dbc8;
  --warm: #ec9b7a;
  --mono: 'Cascadia Code', Consolas, monospace;
  font: 14px 'Segoe UI', 'Leelawadee UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--base); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button, select, input { border: 1px solid var(--edge); border-radius: 6px; background: var(--control); min-height: 32px; }
button { padding: 5px 10px; white-space: nowrap; cursor: pointer; }
select { padding: 4px 6px; cursor: pointer; }
input { padding: 5px 8px; min-width: 0; width: 100%; }
button:hover:not(:disabled), select:hover { border-color: #687383; background-color: #303642; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
button:disabled, input:disabled { opacity: .45; cursor: default; }
button[aria-pressed='true'] { color: var(--teal); background: #173635; border-color: #356561; }
.accent { background: var(--teal); border-color: var(--teal); color: #0c2926; font-weight: 700; }
.accent:hover:not(:disabled) { color: #0c2926; background: #a1ffeb; }
h1, h2, p { margin: 0; }
h2 { font-size: 15px; font-weight: 650; }
p { color: var(--muted); }
a { color: var(--teal); text-underline-offset: 3px; }
time, .quote strong, .pnl strong, .chart-ohcl, td { font-variant-numeric: tabular-nums; }
.topbar { min-height: 56px; padding: 7px 20px; border-bottom: 1px solid var(--edge); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #191c22; }
.brand, .top-actions { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #4b4542; border-radius: 8px; color: var(--warm); background: #302620; font-size: 23px; line-height: 1; }
.brand h1 { font-size: 22px; line-height: 1; letter-spacing: -.035em; }
.brand p { font-size: 11px; margin-top: 5px; letter-spacing: .05em; }
.data-status { color: var(--muted); font-size: 12px; }
.data-status::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin: 0 8px 1px 0; }
.data-status.error::before { background: var(--warm); }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at top, #253332, var(--base) 60%); }
.login-card { width: min(100%, 400px); display: grid; gap: 20px; padding: clamp(22px, 6vw, 36px); border: 1px solid var(--edge); border-radius: 12px; background: var(--panel); }
.login-card h2 { font-size: 19px; }
.login-card form { display: grid; gap: 15px; }
.login-card input, .login-card button { min-height: 44px; font-size: 16px; }
.account-hint { margin-top: -11px; font-size: 12px; }
.account-actions { display: flex; align-items: center; gap: 5px; }
.account-button { display: inline-flex; align-items: center; min-height: 32px; padding-inline: 10px; border: 1px solid var(--edge); border-radius: 6px; color: var(--ink); background: var(--control); text-decoration: none; white-space: nowrap; }
.account-button:hover { border-color: #687383; }
.workspace { max-width: 2200px; margin: 0 auto; padding: 9px 12px 18px; display: grid; grid-template-columns: minmax(0, 1fr) 278px; gap: 8px; align-items: stretch; }
.terminal, .order-panel, .journal { min-width: 0; border: 1px solid var(--edge); background: var(--panel); border-radius: 7px; overflow: hidden; }
.terminal { display: flex; flex-direction: column; }
.workspace-bar, .replay-bar { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 7px 9px; flex-wrap: wrap; }
.workspace-bar { border-bottom: 1px solid var(--edge); }
.toolbar-group, .playback, .time-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.toolbar-group button { font-size: 12px; min-height: 29px; padding: 4px 8px; }
.workspace-bar { position: relative; z-index: 2; }
.tool-menu { position: relative; }
.tool-menu > summary { list-style: none; min-height: 29px; padding: 5px 8px; border: 1px solid var(--edge); border-radius: 6px; background: var(--control); font-size: 12px; cursor: pointer; white-space: nowrap; }
.tool-menu > summary::after { content: ' ▾'; }
.tool-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; position: absolute; top: calc(100% + 5px); right: 0; padding: 9px; width: max-content; max-width: min(360px, 90vw); border: 1px solid var(--edge); border-radius: 8px; background: var(--panel); box-shadow: 0 10px 25px #04080a90; }
.tool-sheet div { display: grid; gap: 3px; align-content: start; }
.tool-sheet strong { font-size: 11px; padding: 3px 4px; color: var(--muted); }
.tool-sheet button { text-align: left; }
#frames button:not([aria-pressed='true']) { background: transparent; border-color: transparent; color: var(--muted); }
#frames button:hover { border-color: var(--edge); }
.chart-workspace { display: grid; grid-template-columns: 46px minmax(0, 1fr); flex: 1; }
.draw-tools { display: flex; flex-direction: column; align-items: center; padding: 7px 5px; gap: 4px; border-right: 1px solid var(--edge); background: #20232a; }
.draw-tools button { display: grid; place-items: center; width: 33px; min-height: 32px; padding: 0; font-size: 19px; font-family: 'Segoe UI Symbol', sans-serif; }
.draw-tools button:not([aria-pressed='true']):not(:hover) { background: transparent; border-color: transparent; color: var(--muted); }
.draw-tools button:is([data-tool='long'], [data-tool='short'], [data-tool='fib']) { font: 650 11px var(--mono); }
.tool-divider { border-bottom: 1px solid var(--edge); width: 21px; margin: 3px 0; }
.charts { display: grid; grid-template-columns: clamp(208px, calc(var(--main-chart-width, 66.7%) - 4px), calc(100% - 216px)) 8px minmax(208px, 1fr); min-height: clamp(500px, calc(100vh - 260px), 1030px); background: #1a1d24; }
.charts.single { grid-template-columns: minmax(0, 1fr); }
.chart-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); border-bottom: 1px solid var(--edge); }
.chart-divider { display: grid; place-items: center; background: var(--edge); cursor: col-resize; touch-action: none; }
.chart-divider::before { content: ''; width: 2px; height: 34px; border-radius: 2px; background: var(--muted); }
.chart-divider:is(:hover, :focus-visible)::before { background: var(--teal); }
.chart-panel.selected .chart-dot { background: var(--teal); }
.chart-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; padding: 6px 8px 5px 10px; align-items: center; border-bottom: 1px solid var(--edge); }
.chart-title { min-width: 0; display: flex; align-items: center; gap: 6px; }
.axis-actions { display: flex; gap: 3px; justify-self: end; }
.axis-actions button { min-height: 23px; padding: 2px 5px; color: var(--muted); background: transparent; font: 11px var(--mono); }
.chart-dot { height: 6px; width: 6px; background: #63798b; border-radius: 50%; }
.instrument, .sub-frame { font-weight: 650; min-height: 27px; font-size: 12px; }
.instrument { color: var(--ink); }
.instrument-name { color: var(--muted); min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-ohcl { grid-column: 1 / -1; min-width: 0; min-height: 14px; color: var(--ink); font: 11px var(--mono); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.chart-ohcl.down { color: var(--warm); }
.frame-tag { padding: 3px 6px; border: 1px solid var(--edge); border-radius: 4px; font: 11px var(--mono); color: var(--ink); }
.plot { position: relative; min-width: 0; min-height: 0; }
.plot canvas { position: absolute; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.order-tags { position: absolute; inset: 0; pointer-events: none; }
.order-tag { position: absolute; display: flex; align-items: center; gap: 2px; transform: translateY(-50%); padding: 2px; border-radius: 5px; background: #1a2a30; pointer-events: auto; color: var(--teal); font: 11px var(--mono); }
.choosing-replay .order-tag { pointer-events: none; }
.order-tag.order-short { background: #372a26; color: var(--warm); }
.order-tag.order-stop { background: #392826; color: #f0917b; }
.order-tag.order-target { background: #1a3030; color: #55d7ba; }
.order-tag button, .order-tag span { min-height: 23px; padding: 3px 6px; background: transparent; color: inherit; white-space: nowrap; }
.order-tag .order-handle { cursor: ns-resize; touch-action: none; }
.order-tag .order-caption { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.order-tag { max-width: calc(100% - 82px); }
.ict-bias { position: absolute; bottom: 30px; right: 80px; padding: 3px 7px; color: #e0e7ec; background: #252b35; border: 1px solid var(--edge); border-radius: 5px; font: 10px var(--mono); pointer-events: none; }
.chart-order-actions { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#chart-order-error { margin-top: 8px; }
#chart-order { width: min(325px, calc(100% - 16px)); }
.replay-bar { min-height: 52px; }
.replay-scrub { flex: 1 0 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding-inline: 2px; color: var(--muted); font-size: 11px; }
.replay-scrub input { width: 100%; min-width: 0; margin: 0; accent-color: var(--teal); }
.replay-scrub output { min-width: 17ch; text-align: right; font: 10px var(--mono); }
.playback, .time-controls { column-gap: 7px; }
#play { min-width: 65px; }
.clock { display: flex; flex-direction: column; min-width: 111px; padding: 0 4px; }
.clock span, .inline-label span { color: var(--muted); font-size: 10px; }
.clock time { font: 12px var(--mono); }
.inline-label { gap: 5px; display: flex; align-items: center; }
.order-panel { padding: 14px; display: flex; flex-direction: column; }
.side-heading, .journal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-heading > span { color: var(--teal); letter-spacing: .05em; font: 12px var(--mono); }
.quote { display: flex; align-items: baseline; gap: 7px; margin: 5px 0 14px; }
.quote strong { font: 600 23px var(--mono); }
.quote > span, .pnl span { font-size: 11px; color: var(--muted); }
.quote-quality { color: #f1c579; font-size: 11px; margin: -10px 0 8px; }
.quote-quality:empty { display: none; }
#fee-source { color: var(--muted); font-size: 10px; }
form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
form label > input, form label > select { color: var(--ink); }
form label > input::placeholder { color: var(--quiet); }
#order-form, #import-form { display: grid; gap: 9px; }
.field-grid, .trade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.trade-buttons button { min-height: 36px; font-weight: 700; }
.buy { background: #17463f; border-color: #326d61; color: #87fbe0; }
.sell { background: #482c29; border-color: #71483e; color: #ffc0ae; }
.feedback { color: var(--teal); font-size: 12px; min-height: 25px; margin-top: 5px; }
.error, .feedback.error, #import-status.error { color: var(--warm); }
.positions-heading { padding-top: 10px; border-top: 1px solid var(--edge); }
.positions { padding: 7px 0; display: grid; gap: 6px; }
.position { padding: 7px; border: 1px solid var(--edge); border-radius: 6px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.position strong, .position small { display: block; }
.position small { color: var(--muted); }
.position button { font-size: 11px; min-height: 28px; }
.positions > p { color: var(--quiet); font-size: 12px; }
.pnl { border-top: 1px solid var(--edge); margin-top: auto; padding-top: 10px; display: grid; gap: 5px; }
.pnl > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pnl strong { font: 600 13px var(--mono); }
.profit { color: var(--teal); }
.loss { color: var(--warm); }
.journal { grid-column: 1 / -1; }
.journal-header { padding: 10px 13px; }
.journal-header > div { display: flex; gap: 12px; align-items: baseline; }
#summary { color: var(--muted); font-size: 12px; }
.table-scroll { max-height: 270px; overflow: auto; border-top: 1px solid var(--edge); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th, td { white-space: nowrap; padding: 8px 12px; }
th { color: var(--muted); font-weight: 600; background: #242730; position: sticky; top: 0; }
tbody tr { border-top: 1px solid var(--edge); }
tbody .empty { color: var(--quiet); padding: 15px 12px; }
dialog { border: 1px solid #415466; border-radius: 12px; padding: 17px; width: min(465px, calc(100% - 28px)); color: var(--ink); background: var(--panel); }
dialog::backdrop { background: #070b10c9; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dialog-header h2 { font-size: 17px; }
dialog p, dialog a { font-size: 12px; }
#jump-form { display: grid; gap: 7px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.data-ranges { display: grid; gap: 8px; margin-bottom: 13px; }
.data-ranges > div { padding: 8px; border: 1px solid var(--edge); border-radius: 6px; }
.data-ranges strong { display: block; margin-bottom: 3px; }
.data-ranges summary { font-size: 12px; cursor: pointer; }
.setting-section { margin: 0 0 10px; min-width: 0; border: 1px solid var(--edge); border-radius: 7px; padding: 8px; }
.setting-section legend { color: var(--muted); font-size: 12px; }
.setting-section input[type='color'] { padding: 2px; min-width: 50px; }
form label.check { display: flex; align-items: center; }
.check input { width: auto; min-height: 0; accent-color: var(--teal); }
.wide-field { grid-column: 1 / -1; }
#draw-select { margin-bottom: 8px; }
#draw-symbol { color: var(--teal); }
#draw-error { margin: 8px 0; }
.fib-colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 7px; }
.fib-colors > div { display: flex; align-items: end; gap: 4px; }
.fib-colors label { flex: 1; min-width: 0; }
.fib-colors input[type='color'] { min-width: 0; }
.fib-colors button { padding-inline: 5px; }
#draw-fib-style summary { cursor: pointer; color: var(--muted); font-size: 12px; }
#draw-box-opacity { accent-color: var(--teal); }
#draw-box-opacity-value { color: var(--ink); }
.preset-fields { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 5px 8px; padding-bottom: 8px; }
.preset-actions { display: flex; gap: 5px; align-items: end; flex-wrap: wrap; }
@media (max-width: 1160px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 250px; padding-inline: 8px; }
  .instrument-name { display: none; }
  .order-panel { padding: 11px; }
}
@media (max-width: 875px) {
  .workspace { grid-template-columns: minmax(0, 1fr); padding-inline: 8px; }
  .topbar { padding-inline: 11px; }
  .charts { grid-template-columns: minmax(0, 1fr); min-height: 505px; grid-template-rows: minmax(270px, 1.2fr) minmax(220px, 1fr); }
  .charts.single { grid-template-rows: minmax(490px, 1fr); }
  .chart-divider { display: none; }
  .order-panel { min-height: 0; }
}
@media (max-width: 480px) {
  .brand-mark { display: none; }
  .login-card .brand-mark { display: grid; }
  .brand h1 { font-size: 20px; }
  .top-actions { gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
  .top-actions button, .account-button { padding-inline: 6px; font-size: 11px; }
  .data-status { flex-basis: 100%; order: 1; text-align: right; font-size: 10px; }
  .chart-workspace { grid-template-columns: minmax(0, 1fr); }
  .draw-tools { flex-direction: row; overflow-x: auto; padding: 3px 5px; border-right: 0; border-bottom: 1px solid var(--edge); }
  .draw-tools button { flex: 0 0 40px; }
  .draw-tools .tool-divider { height: 20px; flex: 0 0 1px; border-right: 1px solid var(--edge); }
  .charts, .charts.single { min-height: 360px; }
  .charts.single { grid-template-rows: minmax(360px, 52svh); }
  .chart-head { gap: 3px 6px; padding-inline: 6px; }
  .chart-ohcl { font-size: 10px; }
  .tool-sheet { left: 0; right: auto; max-height: 58svh; overflow-y: auto; }
}
@media (pointer: coarse) {
  .playback button, .time-controls button, .draw-tools button { min-height: 40px; }
  .replay-scrub input { min-height: 38px; }
}
