:root {
  color-scheme: light dark;
  --bg: #f5f6f7;
  --card: #ffffff;
  --line: #e1e4e8;
  --text: #15191e;
  --muted: #5d6670;
  --accent: #1f5fbf;
  --up: #0a7a3e;
  --down: #c0272d;
  --warn: #9a6200;
  --up-soft: #dcf3e4;
  --down-soft: #fbe3e3;
  --warn-soft: #fbeed2;
  --chip: #eceef1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101418;
    --card: #1a2027;
    --line: #2b333c;
    --text: #e9edf1;
    --muted: #9aa5b1;
    --accent: #7fb0f5;
    --up: #4fcf85;
    --down: #ff7b7f;
    --warn: #f0b64d;
    --up-soft: #143524;
    --down-soft: #3f1c1e;
    --warn-soft: #3b2d12;
    --chip: #262e37;
  }
}
/* The same dark values, for someone who chose dark in Settings on a light device. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --card: #1a2027;
  --line: #2b333c;
  --text: #e9edf1;
  --muted: #9aa5b1;
  --accent: #7fb0f5;
  --up: #4fcf85;
  --down: #ff7b7f;
  --warn: #f0b64d;
  --up-soft: #143524;
  --down-soft: #3f1c1e;
  --warn-soft: #3b2d12;
  --chip: #262e37;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#title { flex: 1; margin: 0; font-size: 20px; font-weight: 650; }
#status { color: var(--muted); font-size: 13px; white-space: nowrap; }
#status.live { color: var(--up); font-weight: 600; }
.ghost {
  min-width: 40px; height: 40px; padding: 0 8px;
  background: none; border: 0; border-radius: 8px;
  color: var(--accent); font-weight: 600;
}
.ghost svg { width: 22px; height: 22px; display: block; margin: auto; }
.ghost svg, #tabs svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#banner {
  padding: 8px 16px;
  background: var(--warn-soft); color: var(--warn);
  font-size: 13px; font-weight: 550;
}
main { padding: 12px 16px calc(env(safe-area-inset-bottom) + 84px); max-width: 720px; margin: 0 auto; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
#tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0;
  min-width: 0; background: none; border: 0;
  color: var(--muted); font-size: 10px; font-weight: 550; letter-spacing: -.01em;
}
#tabs span { white-space: nowrap; }
#tabs svg { width: 22px; height: 22px; }
#tabs button[aria-current="page"] { color: var(--accent); }

.meta { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.meta b { color: var(--text); font-weight: 600; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  min-height: 36px; padding: 0 12px;
  background: var(--chip); border: 0; border-radius: 18px;
  font-size: 13.5px; font-weight: 550; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--card); }
.search {
  width: 100%; height: 42px; margin-bottom: 10px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  text-transform: uppercase;
}
.search::placeholder { text-transform: none; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: block; width: 100%; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  text-align: left;
}
.row-btn { display: block; width: 100%; padding: 0; background: none; border: 0; text-align: left; }
.row-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.tk { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.push { margin-left: auto; text-align: right; white-space: nowrap; }
.time { color: var(--muted); font-size: 13px; }
.sub { margin-top: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.px { margin-top: 4px; font-size: 13.5px; }
.px b { font-weight: 650; }
.up { color: var(--up); }
.down { color: var(--down); }

.tag {
  display: inline-block; padding: 1px 7px;
  background: var(--chip); border-radius: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.tag.buy { background: var(--up-soft); color: var(--up); }
.tag.sell { background: var(--down-soft); color: var(--down); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.new { background: var(--accent); color: var(--card); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 8px 0 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.level { padding: 6px; background: var(--bg); border-radius: 8px; text-align: center; min-width: 0; }
.level span { display: block; color: var(--muted); font-size: 11px; }
.level b { display: block; font-size: 13.5px; font-weight: 650; }

.hero { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 17px; font-weight: 650; }
.dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--up); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--down); }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.problems-title { margin-top: 8px; font-size: 12.5px; font-weight: 600; }
.problems { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.problems li { padding: 4px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.section-title { margin: 12px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.positions { margin: 0; padding: 0; list-style: none; }
.positions li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.positions .tk { font-size: 14px; }
.positions .when { color: var(--muted); font-size: 12.5px; }
.bt { width: 100%; margin-top: 4px; border-collapse: collapse; font-size: 13.5px; }
.bt th { padding: 3px 0; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: right; }
.bt th:first-child, .bt td:first-child { text-align: left; color: var(--muted); }
.bt td { padding: 3px 0; text-align: right; border-top: 1px solid var(--line); }
.bt small, .levels-table small { color: var(--muted); font-size: 11.5px; }
.finder { position: relative; }
.suggest { margin: -6px 0 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.suggest a { display: flex; align-items: baseline; gap: 8px; min-height: 44px; padding: 10px 12px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.suggest a:first-child { border-top: 0; }
.suggest .name { min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.suggest .none { padding: 12px; color: var(--muted); font-size: 13.5px; }
a.tk { color: inherit; text-decoration: none; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card-actions a, .card-actions button { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; background: var(--chip); border: 0; border-radius: 18px; color: inherit; font-size: 13.5px; font-weight: 550; text-decoration: none; }
.card-actions .primary { background: var(--accent); color: var(--card); }

.tag.xbuy { background: var(--up); color: var(--card); }
.tag.xsell { background: var(--down); color: var(--card); }
.settings-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; margin-bottom: 8px; padding: 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-weight: 600; }
.settings-button small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; border-top: 1px solid var(--line); font-size: 14px; }
.toggle-row:first-child { border-top: 0; }
.toggle-row input { flex: none; width: 22px; height: 22px; accent-color: var(--accent); }
.log-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }

.pos-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 10px; padding: 10px; background: var(--bg); border-radius: 10px; }
.pos-form label { display: flex; flex: 1 1 120px; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; }
.pos-form input { width: 100%; height: 40px; padding: 0 8px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 15px; }
.card-actions .pos-save { background: var(--accent); color: var(--card); }
.kind-rows { margin: 8px 0 0; padding: 0; list-style: none; }
.kind-rows li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.kind-rows .tk { font-size: 14px; }

.sortbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.sortbar label { display: flex; flex: 1 1 200px; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sortbar select { flex: 1; min-width: 0; height: 40px; padding: 0 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 14px; }
.movers { display: flex; flex-basis: 100%; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.movers button { width: 44px; height: 36px; background: var(--chip); border: 0; border-radius: 8px; font-size: 14px; }
.positions .movers, .kind-rows .movers { margin-top: 4px; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 340px; padding: 0; text-align: center; }
.login-box img { border-radius: 16px; }
.login-box h1 { margin: 12px 0 20px; font-size: 24px; font-weight: 650; }
.login-box form { text-align: left; }
.login-box label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.login-input { margin-bottom: 12px; text-transform: none; }
.login-error { margin: 0 0 12px; color: var(--down); font-size: 14px; }
.login-button { width: 100%; min-height: 46px; background: var(--accent); border: 0; border-radius: 10px; color: var(--card); font-size: 16px; font-weight: 600; }
.login-button:disabled { opacity: .6; }

.chart-card { margin-top: 8px; }
.chart-plot svg { display: block; max-width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
.chart-plot .grid { stroke: var(--line); stroke-width: 1; }
.chart-plot .axis { stroke: var(--line); stroke-width: 1; }
.chart-plot .tick, .chart-plot .panel { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-plot .wick { stroke: var(--muted); stroke-width: 1; }
.chart-plot .up-bar { fill: var(--card); stroke: var(--muted); stroke-width: 1; }
.chart-plot .down-bar { fill: var(--text); }
.chart-plot .lab { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart-plot .lab-halo { fill: none; stroke: var(--card); stroke-width: 3; stroke-linejoin: round; font-size: 11px; font-weight: 600; }
.chart-plot .spot { stroke: var(--muted); fill: none; }
.chart-plot .moved { stroke: var(--text); fill: none; }
.chart-plot .moved-tag { fill: var(--text); }
.chart-plot .moved-text { fill: var(--card); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.line-control { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; font-size: 13px; color: var(--muted); }
.line-control span { white-space: nowrap; }
.line-control input { flex: 1; min-width: 0; min-height: 40px; accent-color: var(--accent); }
.style-row { display: grid; grid-template-columns: 26px 34px minmax(0, 1fr) 62px 86px; align-items: center; gap: 6px; min-height: 46px; border-top: 1px solid var(--line); font-size: 13px; }
.style-row:first-of-type { border-top: 0; }
.style-row input[type="checkbox"] { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.style-row input[type="color"] { width: 32px; height: 32px; padding: 0; background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.style-row select { width: 100%; height: 36px; padding: 0 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 12.5px; }
.style-row.off .style-name { color: var(--muted); }
.levels-details { margin-top: 10px; font-size: 13.5px; }
.levels-details summary { min-height: 36px; padding: 8px 0; font-weight: 600; cursor: pointer; }

.settings-card { margin-bottom: 8px; }
.settings-card > .card-title { margin-bottom: 4px; }
.settings-card .filters { margin: 4px 0 8px; }
a.settings-button { color: inherit; text-decoration: none; }
.time-row { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--muted); }
.time-row input { height: 38px; padding: 0 6px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px; }
.start-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 14px; }
.start-row select { height: 38px; padding: 0 6px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px; }
.hit { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.notice-row { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.notice-row b { font-weight: 600; }
.notice-row div { color: var(--muted); font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; }

.empty { padding: 28px 12px; color: var(--muted); text-align: center; }
.more {
  width: 100%; min-height: 44px; margin-top: 8px;
  background: var(--chip); border: 0; border-radius: 10px; font-weight: 600;
}
