/* MarketMind — the look.
 *
 * THE COLOUR RULE, and everything else follows from it:
 *
 *   BLUE is the interface. WHITE is the text.
 *   GREEN and RED mean the market, and nothing else — ever.
 *
 * The first cut used neon green for the chrome as well, which quietly wrecked
 * the signal: when the active tab, the buttons and the panel glow are all the
 * same green as "price up", green stops meaning anything. Semantic colour has
 * to be reserved to stay semantic, so the accent moved to blue and green/red
 * now appear only on prices, P&L, candles, win/loss and trade verdicts.
 *
 * Single theme on purpose — a lit terminal in a dark room. Every colour is
 * still declared explicitly, so nothing inherits from the browser.
 */

:root {
  /* ground — very slightly blue-biased, so the neutrals read as chosen */
  --ground:   #070A10;
  --surface:  #0D131C;
  --raised:   #141C28;
  --sunken:   #090D14;
  --line:     #1C2534;
  --line-2:   #2A3648;

  /* the interface */
  --accent:      #4D9CFF;
  --accent-dim:  #2F6FD0;
  --accent-deep: #143966;
  --glow:        rgba(77, 156, 255, .30);

  /* text */
  --ink:    #F2F6FB;
  --ink-2:  #BCC9DA;
  --muted:  #7C8CA4;
  --faint:  #4C5A6E;

  /* THE MARKET — these four are never used for chrome */
  --up:       #2FD97A;
  --up-soft:  rgba(47, 217, 122, .12);
  --down:     #FF4D5E;
  --down-soft:rgba(255, 77, 94, .12);
  --warn:     #FFB020;

  --r: 10px;
  --r-lg: 14px;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Source Sans 3", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --display: Archivo, var(--sans);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1100px 460px at 50% -190px, rgba(77,156,255,.07), transparent 70%);
  background-attachment: fixed;
}

::selection { background: var(--accent-deep); color: var(--ink); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--sunken); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-deep); }

/* ============================================================ chrome ==== */

.shell { max-width: 1440px; margin: 0 auto; padding: 0 22px 64px; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(var(--ground) 78%, rgba(7,10,16,.9));
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; display: block; }
.brand .name {
  font-family: var(--display); font-weight: 800; font-size: 17px;
  letter-spacing: -.02em; color: var(--ink);
}
.brand .name b { color: var(--accent); font-weight: 800; }

.tabs { display: flex; gap: 3px; margin-left: 8px; }
.tab {
  font: inherit; font-family: var(--display); font-weight: 600; font-size: 13.5px;
  cursor: pointer; background: none; border: 1px solid transparent;
  border-radius: var(--r); color: var(--muted); padding: 8px 15px;
}
.tab:hover { color: var(--ink-2); background: var(--surface); }
.tab.on {
  color: var(--ink); background: var(--surface); border-color: var(--line-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok   { background: var(--accent); box-shadow: 0 0 9px var(--glow); }
.dot.bad  { background: var(--down); }
.dot.busy { background: var(--warn); }

/* ============================================================= views ==== */

.view { display: none; padding-top: 24px; }
.view.on { display: block; }

.grid { display: grid; gap: 18px; }
.grid.home { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.grid.wide { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1080px) { .grid.home { grid-template-columns: minmax(0, 1fr); } }

/* ============================================================= panel ==== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel.lit { box-shadow: 0 0 0 1px rgba(77,156,255,.09), 0 0 34px -22px var(--glow); }
.panel > .head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 17px; border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--raised), var(--surface));
}
.panel > .head h2 {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .17em; text-transform: uppercase; color: var(--muted); margin: 0;
}
.panel > .head .spacer { margin-left: auto; }
.panel > .body { padding: 17px; }
.panel > .body.tight { padding: 11px; }
.panel > .body.flush { padding: 0; }

/* ========================================================== calendar ==== */

.calhead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.calhead .month {
  font-family: var(--display); font-weight: 800; font-size: 21px;
  letter-spacing: -.02em; color: var(--ink);
}
.calhead .runday { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.calhead .runday b { color: var(--accent); font-weight: 600; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal .dow {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--faint); text-align: center; padding-bottom: 5px;
}
.day {
  position: relative; aspect-ratio: 1 / .82; border-radius: 8px;
  background: var(--sunken); border: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 6px 7px;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.day:hover { border-color: var(--line-2); background: var(--raised); }
.day.blank { background: none; border-color: transparent; cursor: default; }
.day .n {
  font-family: var(--mono); font-size: 12px;
  font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.day.out .n { color: var(--faint); }
/* Today is the INTERFACE marking a date, so it is blue. */
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(77,156,255,.28); }
.day.today .n { color: var(--accent); font-weight: 600; }
/* A day's tint is its P&L — market, therefore green or red. */
.day.win  { background: linear-gradient(var(--sunken), var(--up-soft)); border-color: rgba(47,217,122,.32); }
.day.loss { background: linear-gradient(var(--sunken), var(--down-soft)); border-color: rgba(255,77,94,.30); }
.day.flat { border-color: var(--line-2); }
.day .pnl {
  margin-top: auto; font-family: var(--mono); font-size: 10.5px;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.day.win .pnl { color: var(--up); }
.day.loss .pnl { color: var(--down); }
.day .marks { position: absolute; top: 7px; right: 7px; display: flex; gap: 3px; }
.day .mk { width: 5px; height: 5px; border-radius: 50%; }
.mk.trade { background: var(--accent); }
.mk.note  { background: var(--warn); }
.mk.brief { background: var(--ink-2); }

.callegend {
  display: flex; gap: 15px; flex-wrap: wrap; margin-top: 13px;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.callegend span { display: flex; align-items: center; gap: 5px; }

/* ============================================================ prices ==== */

.tick {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px;
  padding: 13px 15px; border-bottom: 1px solid var(--line);
  align-items: center; cursor: pointer;
}
.tick:last-child { border-bottom: none; }
.tick:hover { background: var(--raised); }
.tick .sym { font-family: var(--display); font-weight: 800; font-size: 15px; color: var(--ink); }
.tick .role {
  font-family: var(--mono); font-size: 9px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--faint); display: block; margin-top: 1px;
}
.tick .px {
  font-family: var(--mono); font-size: 18px; font-weight: 600;
  font-variant-numeric: tabular-nums; text-align: right;
  letter-spacing: -.01em; color: var(--ink);
}
.tick .chg {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums; text-align: right;
}
.tick .spark { grid-column: 1 / -1; height: 26px; margin-top: 2px; }

/* the only two classes allowed to carry market colour */
.up   { color: var(--up); }
.down { color: var(--down); }

/* ============================================================== news ==== */

.newsitem {
  display: block; padding: 11px 15px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.newsitem:last-child { border-bottom: none; }
.newsitem:hover { background: var(--raised); }
.newsitem .t { font-size: 14px; line-height: 1.42; color: var(--ink); }
.newsitem .m {
  margin-top: 4px; font-family: var(--mono); font-size: 10px;
  color: var(--faint); letter-spacing: .04em; text-transform: uppercase;
}
.newsitem:hover .t { color: var(--accent); }

/* ============================================================ tables ==== */

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
  background: var(--raised); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--raised); }
td.num, th.num {
  text-align: right; font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* =========================================================== metrics ==== */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px; background: var(--line); border-radius: var(--r); overflow: hidden;
}
.stat { background: var(--surface); padding: 13px 15px; }
.stat .k {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted); display: block;
}
.stat .v {
  font-family: var(--mono); font-size: 23px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  display: block; margin-top: 3px; color: var(--ink);
}
.stat .sub { font-size: 11.5px; color: var(--faint); display: block; }

/* ============================================================= forms ==== */

label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 11px; }
.fld {
  display: flex; align-items: center; gap: 7px; margin-top: 5px;
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: 8px; padding: 0 11px;
}
.fld:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(77,156,255,.10); }
.fld input, .fld select, .fld textarea {
  flex: 1; min-width: 0; background: none; border: none; color: var(--ink);
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums; padding: 10px 0; outline: none;
}
.fld textarea { font-family: var(--sans); resize: vertical; line-height: 1.6; }
.fld input::-webkit-outer-spin-button, .fld input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.fld .pre, .fld .suf {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }

.btn {
  font: inherit; font-family: var(--display); font-weight: 600; font-size: 13px;
  cursor: pointer; padding: 9px 16px; border-radius: 8px;
  background: var(--raised); color: var(--ink-2); border: 1px solid var(--line-2);
}
.btn:hover { color: var(--ink); border-color: var(--accent-dim); }
.btn.go {
  background: linear-gradient(180deg, rgba(77,156,255,.20), rgba(77,156,255,.07));
  color: var(--accent); border-color: rgba(77,156,255,.45);
}
.btn.go:hover { box-shadow: 0 0 22px -8px var(--glow); color: #9CC6FF; }
.btn.ghost { background: none; border-color: var(--line); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btnrow { display: flex; gap: 9px; flex-wrap: wrap; }

.seg {
  display: flex; gap: 3px; background: var(--sunken); padding: 3px;
  border: 1px solid var(--line); border-radius: 9px;
}
.seg button {
  flex: 1; font: inherit; font-family: var(--mono); font-size: 11.5px;
  font-weight: 600; cursor: pointer; padding: 7px 9px; border-radius: 6px;
  background: none; border: none; color: var(--muted);
}
.seg button.on { background: var(--raised); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
/* Long/Short is a market choice, so it keeps market colour. */
.seg button.on[data-dir="long"]  { color: var(--up);   box-shadow: inset 0 -2px 0 var(--up); }
.seg button.on[data-dir="short"] { color: var(--down); box-shadow: inset 0 -2px 0 var(--down); }

/* ============================================================= misc ===== */

/* Offline is amber, not red: nothing is broken and the journal still works —
   but prices and news are frozen, and that must not go unsaid. */
.offlinebar {
  margin: 14px 0 0; padding: 11px 16px; border-radius: var(--r);
  background: rgba(255,176,32,.08); border: 1px solid rgba(255,176,32,.34);
  color: var(--warn); font-size: 13px; line-height: 1.5;
}
.offlinebar b { font-family: var(--display); }
/* Anything whose value depends on being current gets dimmed while offline, so
   a frozen price cannot be mistaken for a live one at a glance. */
.is-offline .tick .px,
.is-offline .tick .chg,
.is-offline #posBody { opacity: .55; }

.stale { color: var(--warn) !important; }

.note { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.note.warn { color: var(--warn); }
.note.bad  { color: var(--down); }
.empty { padding: 32px 18px; text-align: center; color: var(--faint); font-size: 13.5px; }

.pill {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase; padding: 3px 8px;
  border-radius: 5px; background: var(--raised); color: var(--muted);
  border: 1px solid var(--line);
}
.pill.win  { color: var(--up); border-color: rgba(47,217,122,.32); }
.pill.loss { color: var(--down); border-color: rgba(255,77,94,.32); }
.pill.open { color: var(--warn); border-color: rgba(255,176,32,.32); }
.pill.demo { color: var(--ink-2); }

/* A verdict is a judgement about a TRADE, so it stays market-coloured. */
.verdict { padding: 12px 15px; border-radius: 9px; border: 1px solid; font-size: 13px; line-height: 1.5; }
.verdict b { display: block; font-family: var(--display); font-size: 14px; margin-bottom: 2px; }
.verdict.ok   { background: var(--up-soft);   border-color: rgba(47,217,122,.34); color: var(--up); }
.verdict.warn { background: rgba(255,176,32,.07); border-color: rgba(255,176,32,.34); color: var(--warn); }
.verdict.bad  { background: var(--down-soft); border-color: rgba(255,77,94,.34); color: var(--down); }

.kv {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 6px 0; font-size: 13px; color: var(--ink-2);
}
.kv b {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.kv.line { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.kv.sub { font-size: 11.5px; color: var(--muted); }
.kv.sub b { font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* --------------------------------------------------------- logbook --- */
/* The spine of dated tabs. Blue is the interface, per THE COLOUR RULE — a tab
   is a navigation control and says nothing about the market, so it never
   borrows green or red. */
.logtabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.logtabs::-webkit-scrollbar { display: none; }
.logtab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  font: inherit; font-family: var(--display); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 6px 11px; border-radius: 999px;
  background: var(--sunken); color: var(--muted);
  border: 1px solid var(--line); transition: color .12s, border-color .12s, background .12s;
}
.logtab:hover { color: var(--ink-2); border-color: var(--line-2); }
.logtab.on {
  background: var(--accent-deep); color: var(--ink);
  border-color: rgba(77, 156, 255, .45);
}
.logtab .latest {
  font-size: 9px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
.logtab.on .latest { color: var(--ink); }
.logbody { padding: 18px 16px 26px; overflow-x: auto; }
.logmeta {
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  letter-spacing: .04em; margin-bottom: 14px;
}
/* The relay's state. Amber while it is someone else's turn to act, because a
   spinner that cannot say WHY it is waiting is indistinguishable from a hang. */
.briefstatus {
  margin: 0; padding: 11px 16px; font-size: 12.5px; font-weight: 500;
  border-bottom: 1px solid var(--line); color: var(--ink-2);
  background: rgba(255, 176, 32, .07);
}
.briefstatus b { color: var(--warn); font-weight: 600; }
.briefstatus.done { background: rgba(77, 156, 255, .07); }
.briefstatus.done b { color: var(--accent); }
.briefstatus.failed { background: var(--down-soft); }
.briefstatus.failed b { color: var(--down); }

.md { font-size: 14.5px; line-height: 1.68; color: var(--ink-2); }
.md h1 { font-family: var(--display); font-size: 25px; margin: 0 0 14px; letter-spacing: -.02em; color: var(--ink); }
.md h2 { font-family: var(--display); font-size: 17px; margin: 26px 0 9px; color: var(--accent); }
.md h3 { font-family: var(--display); font-size: 15px; margin: 20px 0 7px; color: var(--ink); }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin-bottom: 5px; }
.md strong { color: var(--ink); }
.md code {
  font-family: var(--mono); font-size: .9em; background: var(--raised);
  padding: 1px 5px; border-radius: 4px; color: var(--ink);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.md table { margin-bottom: 14px; }
.md blockquote {
  margin: 0 0 12px; padding-left: 14px;
  border-left: 2px solid var(--accent-deep); color: var(--ink-2);
}
.md a { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--raised); border: 1px solid var(--line-2); color: var(--ink);
  padding: 11px 18px; border-radius: 9px; font-size: 13.5px; z-index: 90;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.toast.bad { border-color: rgba(255,77,94,.42); color: var(--down); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
