:root {
  --bg: #0d1117; --panel: #161b22; --line: #30363d; --text: #e6edf3; --muted: #8b949e;
  --up: #3fb950; --down: #f85149; --accent: #58a6ff; --warn: #d29922;
  --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--down); }
.row { display: flex; align-items: center; }
#v-rules > .row { margin-bottom: 10px; } .gap { gap: 8px; } .end { justify-content: flex-end; }
code { background: var(--panel); padding: 1px 4px; border-radius: 4px; }

button { background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--down); border: 1px solid var(--line); }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font: inherit; min-width: 0; width: 100%; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
label input { margin-top: 4px; }

.screen { padding: calc(40px + var(--safe-t)) 20px 20px; max-width: 420px; margin: auto; }
.screen form { display: grid; gap: 10px; }

header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between;
  align-items: center; padding: calc(12px + var(--safe-t)) 16px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: 18px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.pill.live { color: var(--up); } .pill.off { color: var(--warn); }

.view { padding: 12px 12px calc(84px + var(--safe-b)); max-width: 720px; margin: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }

.banner { background: #3b2e0a; color: #f0d58a; border: 1px solid #6b5313; border-radius: 12px;
  padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }

.quote { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; }
.quote .sym { font-weight: 700; font-size: 18px; }
.quote .last { font-size: 22px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.quote .chg { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.quote .sub { color: var(--muted); font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  margin-left: 6px; vertical-align: middle; }
.badge.in { background: #12361d; color: var(--up); }
.badge.below { background: #0f2a4a; color: var(--accent); }
.badge.above { background: #4a1414; color: var(--down); }

#chart { height: 60vh; min-height: 320px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 2px 10px; font-size: 13px; }
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.rule .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rule .name { font-weight: 700; }
.rule .desc { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.rule.disabled { opacity: .55; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--up); }
.switch input:checked + span::after { transform: translateX(18px); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  width: min(560px, 94vw); padding: 16px; max-height: 88vh; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.presets button { padding: 6px 10px; font-size: 13px; }
.cond { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr 1fr auto; gap: 6px; align-items: center;
  margin: 8px 0; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; }
.cond .v2 { grid-column: 4 / 5; }
.cond .x { background: transparent; color: var(--down); padding: 6px; }
.cond .opt { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cond .opt label { display: flex; gap: 6px; align-items: center; margin: 0; }
.cond .opt input { width: 90px; }
.summary { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.sum-line { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  background: #1f2630; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap; }
.chip b { color: #fff; }
.chip.sym { background: #1f6feb33; border-color: #1f6feb; color: #79c0ff; font-size: 13.5px; }
.chip.right.P { background: #f8514926; border-color: #f85149; color: #ff7b72; }
.chip.right.C { background: #3fb95026; border-color: #3fb950; color: #56d364; }
.chip.test { background: #d2992226; border-color: #d29922; color: #e3b341; }
.chip.quiet { background: transparent; color: var(--muted); font-weight: 400; }
.chip .now { font-weight: 500; padding-left: 6px; border-left: 1px solid #d2992266; }
.chip .now.yes { color: var(--up); }
.chip .now.no { color: var(--muted); }
.and { color: var(--muted); font-size: 11px; font-weight: 700; }
.and.big { width: 100%; }
.sum-box { margin: 10px 0; padding: 10px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.sum-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 480px) {
  .cond { grid-template-columns: 1fr 1fr; }
  .cond .v2 { grid-column: auto; }
}

.alert .when { color: var(--muted); font-size: 12px; }
.alert .name { font-weight: 700; }

nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 10; }
nav#tabs button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 8px 0 10px;
  font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav#tabs button span { font-size: 18px; line-height: 1.2; }
nav#tabs button.active { color: var(--accent); }

/* ---- trades / brief ---- */
.between { justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-left: auto; }
.seg button { background: transparent; color: var(--muted); border-radius: 0; padding: 8px 12px; }
.seg button.active { background: var(--line); color: var(--text); }
.card.head { padding: 10px; }
.chip.ok { background: #3fb95022; border-color: #3fb950; color: #56d364; }
.chip.warn { background: #d2992222; border-color: #d29922; color: #e3b341; }
.chip.bad { background: #f8514922; border-color: #f85149; color: #ff7b72; }
.chip.info { color: var(--muted); }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.group > summary { display: flex; gap: 6px; align-items: center; }
.group > summary .chip { margin-left: auto; }
.group, .brief { border-left-width: 4px; }
.group.ok, .brief.ok { border-left-color: var(--up); }
.group.warn, .brief.warn { border-left-color: var(--warn); }
.group.bad, .brief.bad { border-left-color: var(--down); }
.brief.info { border-left-color: var(--accent); }
.trade { padding: 10px 0 8px; border-top: 1px solid var(--line); margin-top: 8px; }
.trade .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
.trade .sub, .b-row .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.trade.closed { opacity: .7; }
.trade .actions { flex-wrap: wrap; margin-top: 8px; }
.trade .actions button { padding: 6px 10px; font-size: 13px; }
.b-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.b-head { font-weight: 600; margin-top: 3px; }
.brief[open] .b-head { margin-bottom: 6px; }
.b-row { padding: 7px 0 7px 8px; border-top: 1px solid var(--line); border-left: 2px solid transparent; }
.b-row.warn { border-left-color: var(--warn); } .b-row.bad { border-left-color: var(--down); } .b-row.ok { border-left-color: var(--up); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.leg { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
.leg input { width: 80px; }
#t-acct-add input { min-width: 0; flex: 1; }
.acct { padding: 6px 0; border-bottom: 1px solid var(--line); }
#tabs button { font-size: 10.5px; }
.sched { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.sched label { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.sched input[type=checkbox] { width: 20px; height: 20px; flex: none; }
.sched input[type=time] { width: 140px; }

/* ---- put ideas ---- */
.seg.wide { display: flex; margin: 0 0 10px; }
.seg.wide button { flex: 1; }
.wrap { flex-wrap: wrap; }
button.mini { padding: 5px 10px; font-size: 12.5px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); }
label.inline input { width: 100px; }
.acct { padding: 8px 0; border-bottom: 1px solid var(--line); }
.acct .row { margin-top: 6px; }
.acct-head { margin-top: 10px; }
details.alts > summary { padding: 6px 0 2px 8px; }
#scan-filters summary { padding: 2px 0; }
.acct select { width: auto; min-width: 150px; }
.ev { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev .chip { margin-left: 6px; font-size: 11px; padding: 1px 7px; }
#ev-form input, #ev-form select { width: auto; flex: 1; min-width: 110px; }

/* ---- alert drill-down ---- */
.alert > summary { display: block; }
.alert .why { margin-top: 6px; }
.alert[open] .why { display: none; }
.alert.crit { border-left: 4px solid var(--down); }
.mini-chip { margin-left: 6px; font-size: 10.5px; padding: 1px 7px; }
.b-head.big { font-size: 18px; margin-top: 8px; }
#trades-filter button { padding: 8px 9px; }
.acct4 { width: 70px !important; }
.sched { flex-wrap: wrap; }
.sched .row input[type=time] { width: 118px; }
#brief-seg button { padding: 9px 6px; font-size: 14px; }
#add-shares-form input, #add-shares-form select { width: auto; flex: 1; min-width: 90px; }
.c-probmax { width: 60px !important; }

/* ---- rule editor: highlighted condition + conditions-now strip ---- */
.cond.active { border: 1px solid var(--accent); box-shadow: 0 0 0 1px #58a6ff33; }
.hint-strip { margin-top: 8px; padding: 6px 8px; border-radius: 8px; border-left: 3px solid var(--line); font-size: 12.5px; }
.hint-strip.ok { border-left-color: var(--up); } .hint-strip.warn { border-left-color: var(--warn); }
.hint-strip.info { border-left-color: var(--accent); }
.hint-strip > summary { cursor: pointer; }
#preset-note:empty { display: none; }
#scan-week button, #call-week button { padding: 8px 4px; font-size: 13px; }
.acct-names { flex: 1; min-width: 0; }
.acct-names input { width: auto; min-width: 0; padding: 6px 8px; }
.acct-names .acct-name { flex: 1.3; font-weight: 700; }
.acct-names .acct-broker { flex: 1; }
.mono-box { font-family: ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; letter-spacing: .08em; word-break: break-all; }
.dev-name { width: auto !important; min-width: 0; max-width: 170px; padding: 5px 8px; font-weight: 700; }
#login-form input { margin-bottom: 8px; }
