/* ==========================================================================
   404 TRADE · app layer on top of PROJECT404 v2 (load after v2.css)
   Built only from v2 tokens. Adds exactly one muted pair for P&L / direction.
   Lime (--em) stays the only accent.
   ========================================================================== */
:root {
  --pos: #6cb08e;
  --neg: #cf6e66;
  --pos-soft: color-mix(in srgb, var(--pos) 10%, transparent);
  --neg-soft: color-mix(in srgb, var(--neg) 10%, transparent);
}

/* author rules beat the UA [hidden] rule, so make it stick (.btn etc. set display) */
[hidden] { display: none !important; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.dim { color: var(--dim); }
.muted { color: var(--muted); }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.sub { display: block; font-family: var(--f-mono); font-size: 11px; letter-spacing: .04em; color: var(--dim); margin-top: 3px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--em); color: #121500; padding: 8px 12px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}
.skip:focus { left: var(--gutter); }

/* ---------- Nav: service tag + operator ---------- */
.svc {
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); line-height: 1; padding: 4px 0 4px 14px; margin-left: -10px;
  border-left: 1px solid var(--line-2); transition: color .15s;
}
.svc:hover, .svc[aria-current="page"] { color: var(--fg); }
.who { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; color: var(--muted); min-width: 0; }
.who img { width: 22px; height: 22px; border-radius: 2px; border: 1px solid var(--line-2); flex: none; }
.who span:not(.chip) { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .who { padding: 12px 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 380px) {
  .nav__in { gap: 12px; }
  .svc { margin-left: -4px; padding-left: 10px; }
}

/* ---------- Buttons (additions) ---------- */
.v2 button.btn { cursor: pointer; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-2); color: var(--fg); }
.btn--em:disabled:hover { background: var(--em); border-color: var(--em); color: #121500; animation: none; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn--quiet { border-color: var(--line); color: var(--muted); }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); }
.btn--danger:hover { color: var(--bg); background: var(--neg); border-color: var(--neg); }
.btn--danger:disabled:hover { color: var(--neg); background: transparent; border-color: color-mix(in srgb, var(--neg) 45%, transparent); }

/* ---------- Chips (additions) ---------- */
.chip--xs { font-size: 10px; padding: 2px 6px; letter-spacing: .1em; }
.chip--pos { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 35%, transparent); }
.chip--neg { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.chip--fill { color: var(--em); background: var(--em-soft); border-color: color-mix(in srgb, var(--em) 55%, transparent); }
.chip--dim { color: var(--dim); border-color: var(--line); }

/* Setup status: distinct but restrained. watch + in_trade carry the lime. */
.st { display: inline-flex; align-items: center; gap: 6px; }
.st--idle { color: var(--dim); border-color: var(--line); }
.st--forming { color: var(--muted); border-style: dashed; }
.st--armed { color: var(--fg); border-color: var(--dim); }
.st--watch { color: var(--em); border-color: color-mix(in srgb, var(--em) 40%, transparent); }
.st--trade { color: var(--em); background: var(--em-soft); border-color: color-mix(in srgb, var(--em) 60%, transparent); }
.st--trade::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--em); }
.st--error { color: var(--amber); border-color: rgba(245, 184, 74, .35); }
.grade--c { color: var(--dim); border-color: var(--line); }

/* ---------- Stat blocks (mono, hairline cells like .cards) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 1px; padding: 1px; }
.stat { background: var(--bg); box-shadow: 0 0 0 1px var(--line); padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stat__l { font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.stat__v { font-family: var(--f-mono); font-size: clamp(20px, 2.2vw, 26px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__s { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px 14px 16px; }
  .stat__v { font-size: 19px; }
}

/* ---------- Landing ---------- */
.hero__in .crumb { display: block; }
.sec h3.h3 { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.15; letter-spacing: -0.015em; font-weight: 600; margin: 12px 0 12px; }
.t-up { color: var(--pos); }
.t-down { color: var(--neg); }
.t-na { color: var(--dim); }
.foot__legal { margin: 40px 0 0; max-width: 76ch; font-family: var(--f-mono); font-size: 12px; letter-spacing: .03em; line-height: 1.7; color: var(--muted); }
.record__note { margin-top: 16px; }

/* ==========================================================================
   Console (app.html)
   ========================================================================== */
.app-head { padding-block: 32px 22px; }
.app-head__t { font-family: var(--f-mark); font-weight: 900; font-size: clamp(26px, 5vw, 38px); letter-spacing: .03em; line-height: 1; margin: 14px 0 10px; }
.app-head__t b { color: var(--em); font-weight: 900; }

/* Section bar: sticky under the nav, horizontally scrollable on phones.
   Solid background on purpose: a second sticky + backdrop-filter layer freezes on iOS. */
.tabs {
  position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); z-index: 40;
  background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.tabs__in { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.tabs__in::-webkit-scrollbar { display: none; }
.tab {
  flex: none; font-family: var(--f-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 15px 12px 13px; border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab:first-child { margin-left: -12px; }
.tab:hover { color: var(--fg); }
.tab[aria-current="page"] { color: var(--fg); border-bottom-color: var(--em); }
.v2 .tab:focus-visible { outline-offset: -4px; }

.boot { padding-block: 56px 96px; }
.panel { padding-block: 32px 80px; }
.panel.is-loading .panel__body { opacity: .55; transition: opacity .2s; }
.panel__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.panel__t { font-size: clamp(26px, 3.6vw, 34px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 8px 0 0; }
.panel__acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.blk { margin-top: 44px; }
.blk__h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.blk__h h3 { font-size: 19px; font-weight: 500; letter-spacing: -0.01em; margin: 6px 0 0; }

.box { border: 1px solid var(--line-2); background: var(--bg-2); padding: 18px; min-width: 0; }
.box + .box { margin-top: 16px; }
.box__h { font-family: var(--f-mono); font-weight: 400; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-top: 16px; }
.grid2 > .box + .box, .split > .box + .box { margin-top: 0; }
.box--wide { grid-column: 1 / -1; }

/* Inline forms */
.fx { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.fx .field { flex: 1 1 130px; min-width: 0; }
.fx .field--grow { flex: 3 1 220px; }
.fx .field--xs { flex: 0 1 120px; }
.fx > .btn { flex: none; }
.field small { font-family: var(--f-mono); font-size: 11px; color: var(--dim); letter-spacing: .02em; text-transform: none; }
.inl { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.v2 input.inp-sm { width: 140px; padding: 8px 10px; flex: none; }
.v2 textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.opt:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.opt b { display: block; font-weight: 500; }
.opt small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; margin-top: 10px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; color: var(--fg); }
.check input { margin-top: 4px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 14px; }

/* Messages + working state */
.msg { font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin: 12px 0 0; overflow-wrap: anywhere; }
.msg:empty { display: none; }
.msg--err { color: var(--neg); }
.msg--err::before { content: "! "; }
.msg--ok { color: var(--fg); }
.msg--ok::before { content: "› "; color: var(--em); }
.working { display: flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.confirm .msg, .inl .msg { flex-basis: 100%; margin: 0; }
.mb-1 { margin-bottom: 16px; }
.bt { margin: 0; font-family: var(--f-mono); font-size: 14px; color: var(--fg); }
.empty { margin: 0; padding: 22px 18px; border: 1px dashed var(--line-2); color: var(--muted); font-family: var(--f-mono); font-size: 13px; }
.confirm { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.confirm__q { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

/* ---------- Data tables → stacked cards under 720px ---------- */
.tt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tt { width: 100%; border-collapse: collapse; font-size: 14px; }
.tt th { text-align: left; font-family: var(--f-mono); font-weight: 400; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tt td { padding: 14px 12px; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top; }
.tt th.r, .tt td.r { text-align: right; }
.tt tbody tr { transition: background .15s; }
.tt tbody tr:hover { background: linear-gradient(90deg, var(--em-soft), transparent 60%); }
.tt .c { min-width: 0; }
.tt__main .c { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.tt__acts .c { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.sym { color: var(--fg); font-weight: 500; font-size: 16px; letter-spacing: -0.005em; }
.c .num { color: var(--fg); }

@media (max-width: 720px) {
  .tt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tt, .tt tbody, .tt tr, .tt td { display: block; width: 100%; }
  .tt tr { border: 1px solid var(--line); background: var(--bg); padding: 4px 14px 8px; margin-bottom: 10px; }
  .tt tbody tr:hover { background: var(--bg); }
  .tt td { border: 0; padding: 8px 0; display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: baseline; }
  .tt td::before { content: attr(data-label); font-family: var(--f-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
  .tt td.r { text-align: left; }
  .tt td.tt__main { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .tt td.tt__main::before, .tt td.tt__acts::before { content: none; }
  .tt td.tt__acts { display: block; padding-top: 10px; }
  .tt__acts .c { justify-content: flex-start; }
  .tt td.is-empty { display: none; }
}

/* Plan levels */
.lv { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-family: var(--f-mono); font-size: 13px; }
.lv div { display: flex; flex-direction: column; flex: none; }
.lv dt { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.lv dd { margin: 0; color: var(--fg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lv .is-hook dt { color: var(--em); }
.lv__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .lv div { min-width: 96px; } }

/* Trend: compact row (tables) + full stack (scout) */
.trend { display: inline-flex; gap: 10px; font-family: var(--f-mono); font-size: 13px; white-space: nowrap; }
.trend__i b { font-weight: 400; font-size: 11px; color: var(--dim); margin-right: 3px; letter-spacing: .04em; }
.trend__l { display: block; font-family: var(--f-mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
.stack { list-style: none; margin: 0; padding: 0; font-family: var(--f-mono); font-size: 13px; }
.stack li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-2); color: var(--fg); }
.stack li b { font-weight: 400; color: var(--dim); }
.stack__read { color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* Feeds: alerts, news, notes, rules, log */
.feed { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.feed > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); min-width: 0; }
.feed b { color: var(--fg); font-weight: 500; }
.feed__t { font-family: var(--f-mono); font-size: 12px; color: var(--dim); min-width: 64px; }
.feed__d { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.feed__x { flex: 1 1 260px; min-width: 0; color: var(--fg); overflow-wrap: anywhere; }
.feed__end { margin-left: auto; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.box .feed { border-top: 0; }
.box .feed > li:last-child { border-bottom: 0; }
.notes__g + .notes__g { margin-top: 18px; }
.notes__g h4 { margin: 0 0 4px; }
.log { max-height: 420px; overflow-y: auto; }
.log > li { font-family: var(--f-mono); font-size: 12px; }
.log .feed__x { color: var(--muted); }

/* Scout */
.scout { margin-top: 24px; }
.scout__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.scout__sym { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -0.02em; line-height: 1; margin: 0; }
.scout__px { font-size: 22px; color: var(--fg); }
.scout__line { margin: 12px 0 0; color: var(--fg); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.scout__acts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.warn-line { margin: 12px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-family: var(--f-mono); font-size: 13px; color: var(--amber); }
.chart { position: relative; height: 400px; margin-top: 18px; border: 1px solid var(--line-2); background: var(--bg); }
.chart__msg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }
@media (max-width: 720px) { .chart { height: 320px; } }
.keys { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; color: var(--muted); }
.key { --k: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ""; width: 16px; border-top: 2px solid var(--k); }
.key--dash::before { border-top-style: dashed; }
.key--hook { --k: var(--em); }
.key--stop { --k: var(--neg); }
.key--tp { --k: var(--pos); }
.rich { color: var(--fg); font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.rich strong { font-weight: 600; }
.factors { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.factors li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding: 6px 0; color: var(--fg); }
.factors i { font-style: normal; font-family: var(--f-mono); }
.factors .fx-warn { color: var(--amber); }
.box .spec { align-self: stretch; }

/* Segmented switch (Performance source) */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 2px; }
.seg button { font-family: var(--f-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; background: transparent; color: var(--muted); border: 0; padding: 10px 14px; cursor: pointer; transition: color .15s, background .15s; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { color: var(--em); background: var(--em-soft); }

/* Equity curve (inline SVG) */
.curve { position: relative; margin-top: 16px; border: 1px solid var(--line-2); background: var(--bg); }
.curve svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.curve > .note { margin: 0; padding: 22px 18px; }
.curve svg:focus-visible { outline: 1px solid var(--em); outline-offset: -1px; }
.cv-line { fill: none; stroke: var(--em); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cv-area { fill: var(--em); opacity: .1; }
.cv-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.cv-base { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.cv-txt { fill: var(--dim); font-family: var(--f-mono); font-size: 11px; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.cv-val { fill: var(--fg); font-family: var(--f-mono); font-size: 12px; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.cv-end { fill: var(--em); stroke: var(--bg); stroke-width: 2; }
.cv-x { stroke: var(--dim); stroke-width: 1; shape-rendering: crispEdges; }
.curve__tip {
  position: absolute; top: 8px; pointer-events: none; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid var(--line-2); padding: 7px 10px;
  font-family: var(--f-mono); font-size: 11px; color: var(--muted); white-space: nowrap;
}
.curve__tip b { display: block; color: var(--fg); font-size: 14px; font-weight: 500; }
.curve + details { margin-top: 10px; }
details.data summary { cursor: pointer; font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; color: var(--dim); }
details.data summary:hover { color: var(--muted); }
details.data .tt-wrap { max-height: 320px; overflow-y: auto; margin-top: 10px; }

/* Trader */
.kill {
  width: 100%; justify-content: center; padding: 22px 20px; font-size: 15px; letter-spacing: .22em;
  color: var(--neg); border: 1px solid var(--neg); background: var(--neg-soft);
}
.kill:hover { color: var(--bg); background: var(--neg); border-color: var(--neg); }
.halted { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 18px; border: 1px solid rgba(245, 184, 74, .35); background: color-mix(in srgb, var(--amber) 6%, transparent); color: var(--fg); }

/* Ask */
.qa { border-top: 1px solid var(--line); padding: 20px 0; }
.qa:last-child { border-bottom: 1px solid var(--line); }
.qa__meta { font-family: var(--f-mono); font-size: 12px; color: var(--dim); margin: 0; }
.qa__q { color: var(--fg); font-weight: 500; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa__a { margin-top: 12px; padding-left: 14px; border-left: 1px solid var(--line-2); }

/* Footer (console) */
.foot--app { padding-block: 36px 32px; border-top: 1px solid var(--line); }
.foot--app .foot__legal { margin-top: 0; }
.foot--app .foot__base { margin-top: 24px; }
.foot__base a:hover { color: var(--em); }

/* P&L colour must win over the neutral text rules above (.stat__v, .c .num, .spec b) */
.v2 .pos, .v2 .c .num.pos, .v2 .stat__v.pos { color: var(--pos); }
.v2 .neg, .v2 .c .num.neg, .v2 .stat__v.neg { color: var(--neg); }
