:root {
  --bg: #0e1015;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2a2f3a;
  --text: #e9ecf2;
  --muted: #8b93a3;
  --accent: #f5b942;
  --accent-ink: #1a1405;
  --green: #3ecf8e;
  --yellow: #f5b942;
  --red: #f0605d;
  --blue: #5aa9ff;
  --radius: 14px;
  --tabs-h: 64px;
}
:root[data-theme="light"] {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --line: #e1e4ea;
  --text: #14171d;
  --muted: #6b7280;
  --accent: #d8951a;
  --accent-ink: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
a { color: var(--blue); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-size: 16px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--accent); }
.bulb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px 2px color-mix(in srgb, var(--accent) 60%, transparent);
}

main { padding: 14px 16px 24px; max-width: 760px; margin: 0 auto; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px;
}
.tabs a .ti { font-size: 19px; filter: grayscale(1) opacity(.7); }
.tabs a.active { color: var(--accent); }
.tabs a.active .ti { filter: none; }

h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 64px; resize: vertical; }
label.field { display: block; font-size: 12px; color: var(--muted); }
label.field > input, label.field > textarea { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.btn:disabled { opacity: .5; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.lamp { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--muted); }
.lamp.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.lamp.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.lamp.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.lamp.big { width: 44px; height: 44px; }

.hero { display: flex; gap: 14px; align-items: center; }
.hero img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--surface-2); }
.score { text-align: right; }
.score b { font-size: 28px; display: block; line-height: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.flags { list-style: none; padding: 0; margin: 0; }
.flags li { display: flex; gap: 10px; padding: 9px 0; align-items: flex-start; }
.flags li + li { border-top: 1px solid var(--line); }
.flags .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.dot.green { background: var(--green); } .dot.info { background: var(--blue); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 11px; color: var(--muted); }

.graph-toggle { position: absolute; top: 8px; right: 8px; z-index: 2; }
.graph { position: relative; height: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; background: var(--surface); }
tr + tr td { border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.cl { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #111; text-align: center; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.parent { color: var(--blue); } .tag.child { color: var(--red); } .tag.sibling { color: var(--yellow); }

.heat td.cell { width: 30px; min-width: 30px; height: 28px; padding: 0; border-left: 1px solid var(--line); }
.heat th.vert { writing-mode: vertical-rl; transform: rotate(180deg); height: 90px; padding: 6px 4px; text-transform: none; font-size: 11px; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }

.pos-head { display: flex; justify-content: space-between; align-items: baseline; }
.mult { font-size: 22px; font-weight: 700; }
.up { color: var(--green); } .down { color: var(--red); }
.steps { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.steps li { padding: 3px 0; color: var(--muted); }
.steps li.done { color: var(--green); } .steps li.fired { color: var(--accent); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: 90%;
}
.muted { color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .graph { height: 320px; }
}

.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-top: 12px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

.signal .sig-title { font-weight: 600; margin-top: 6px; }
.signal .sig-body { color: var(--muted); font-size: 14px; margin-top: 2px; }
.signal .sig-body a, .signal .sig-title a { color: var(--blue); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.radar.off { opacity: .6; }
.param { margin-top: 12px; }
.param input[type=range] { width: 100%; accent-color: var(--accent); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }

.spark { width: 100%; height: 56px; display: block; }
.chip.up { color: var(--green); } .chip.down { color: var(--red); }

.plan-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.plan-row { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.plan-row select, .plan-row input[type=text] { padding: 8px; }
.plan-sell { display: flex; align-items: center; gap: 6px; }
.plan-sell input { flex: 1; min-width: 0; accent-color: var(--accent); }
.plan-sell span { font-size: 12px; min-width: 34px; text-align: right; }
.plan-hint { grid-column: 1 / -1; font-size: 12px; }
.plan-sell { grid-column: 1 / -1; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); cursor: pointer; }
.tile:active { transform: scale(.98); }
.tile .tile-icon { font-size: 22px; margin-bottom: 4px; }
.tile.soon { opacity: .5; cursor: default; }
.card.base { margin-top: 12px; }
tr.hl td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.wrap { white-space: normal; min-width: 120px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: 0 4px 4px 0; }
.badge.t-profit, .badge.t-took_out { border-color: var(--green); color: var(--green); }
.badge.t-sniper, .badge.t-dev { border-color: var(--accent); color: var(--accent); }
.badge.t-cluster, .badge.t-fresh, .badge.t-loss { border-color: var(--red); color: var(--red); }
.list-item img.ico { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
