/* ============================================================
 * XAUUSD Terminal — Node 2  ·  "Briefing" edition (style only)
 * ------------------------------------------------------------
 * Visual language taken from the user's XAUUSD_Briefing.html:
 *   light paper background, hairline rules, tinted state tags,
 *   tracked uppercase micro-labels, mono tabular figures,
 *   serif display type, gold accent — no glows, no heavy chrome.
 *
 * CORE FUNCTIONS ARE UNCHANGED: every id, class, data-attribute and
 * DOM hook the JS relies on is preserved. Presentation only.
 * CSS + HTML + JS only. No frameworks, no build step, no new deps.
 * ============================================================ */

:root {
  /* --- Paper & ink (from the briefing) --- */
  --paper: #FBFAF7;
  --card: #FFFFFF;
  --ink: #13171E;
  --ink2: #3D4654;
  --mut: #6E7787;
  --faint: #9AA3B2;

  --rule: #E3DED3;
  --rule2: #EFEBE2;
  --wash: #F5F3EE;        /* hover / inset surface */

  --gold: #A67C24;
  --gold-l: #C9A227;
  --gold-bg: #FBF5E6;

  --red: #A8321F;
  --red-bg: #FBEDEA;
  --grn: #256B47;
  --grn-bg: #EAF4EE;
  --slate-bg: #EEF1F5;

  /* --- Legacy variable names, remapped so nothing breaks --- */
  --bg-0: var(--paper);
  --bg-1: var(--card);
  --bg-2: var(--wash);
  --bg-3: #EFECE4;
  --border: var(--rule);
  --border-strong: #D6D0C2;
  --text: var(--ink);
  --text-muted: var(--mut);
  --text-dim: var(--faint);

  /* Market tones — print-friendly, not neon */
  --teal: var(--grn);
  --coral: var(--red);
  --blue: #2C5C8F;
  --violet: #6B5B95;
  --pink: #9E5C74;
  --cyan: #2A7C7C;
  --green: var(--grn);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  /* Dense dashboard spacing (skill --density 8) */
  --space-xs: 2px;
  --space-sm: 4px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;
  --space-2xl: 24px;
  --space-3xl: 32px;

  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(19, 23, 30, 0.04);
  --shadow-md: 0 6px 18px rgba(19, 23, 30, 0.07);
  --shadow-lg: -18px 0 40px rgba(19, 23, 30, 0.12);

  --sidebar-w: clamp(340px, 33vw, 428px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --focus-ring: 0 0 0 2px var(--card), 0 0 0 4px var(--gold-l);

  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

::selection { background: #F3E6C0; color: var(--ink); }

button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.tnum { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--card);
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 150ms ease;
}
.skip-link:focus-visible { top: 10px; }

/* ---------- Semantic text tones ---------- */

.muted { color: var(--mut); }
.is-pos, .is-live, .is-ok, .is-above { color: var(--grn); }
.is-neg, .is-bad, .is-below { color: var(--red); }
.is-warn { color: var(--gold); }
.is-muted, .is-flat { color: var(--mut); }
.is-empty { color: var(--faint); }

/* ============================================================
 * Masthead — the top bar reads like a briefing header:
 *   brand in tracked gold caps, price as the headline figure,
 *   status as quiet tinted tags, closed by a 2px ink rule.
 * ============================================================ */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: 11px 20px 10px;
  padding-top: max(11px, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
}
.brand::-webkit-scrollbar { display: none; }

.brand-name {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold);
  flex: 0 0 auto;
}

.brand-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  padding-left: 9px;
  border-left: 1px solid var(--rule);
  flex: 0 0 auto;
}

/* Status tags: quiet, tinted, bordered — never a glowing pill */
.socket-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mut);
  white-space: nowrap;
  flex: 0 0 auto;
}
.socket-badge[data-state="live"] { color: var(--grn); background: var(--grn-bg); border-color: #CFE4D8; }
.socket-badge[data-state="stale"],
.socket-badge[data-state="connecting"],
.socket-badge[data-state="reconnecting"],
.socket-badge[data-state="warn"] { color: var(--gold); background: var(--gold-bg); border-color: #EBDCBB; }
.socket-badge[data-state="offline"],
.socket-badge[data-state="not-configured"],
.socket-badge[data-state="bad"] { color: var(--red); background: var(--red-bg); border-color: #EFD3CD; }
.contract-badges {
  letter-spacing: 0.02em;
  text-transform: none;
  font-family: var(--font-mono);
  font-weight: 500;
  background: var(--slate-bg);
  border-color: var(--rule);
  color: var(--ink2);
}

.socket-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.delayed-badge {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid #EBDCBB;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  background: var(--gold-bg);
}

.price-wrap { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

#last-price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 25px;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--ink);
  transition: color 200ms ease;
}
#last-price[data-dir="up"] { color: var(--grn); }
#last-price[data-dir="down"] { color: var(--red); }

.tps-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--card);
  white-space: nowrap;
}
.tps-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
#tps-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  color: var(--ink2);
  padding: 0;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.icon-btn:hover { background: var(--wash); color: var(--ink); border-color: var(--border-strong); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ============================================================
 * System strip — the briefing's stat row:
 *   four cells divided by hairlines on white.
 * ============================================================ */

.system-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 9px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.system-strip::-webkit-scrollbar { display: none; }

.system-id, .system-stats { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.system-stats { gap: 22px; margin: 0; }

.system-mode {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-bg);
  border: 1px solid #EBDCBB;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
}
.system-spec {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink2);
}
.system-stat {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 76px;
  padding-left: 16px;
  border-left: 1px solid var(--rule2);
}
.system-stat:first-child { padding-left: 0; border-left: 0; }
.system-stat dt {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}
.system-stat dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.system-updated {
  margin-left: auto;
  font-size: 10px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Connection banner: soft notice, gold or red edge ---------- */

.connection-banner {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  max-height: 60px;
  overflow-y: auto;
  padding: 7px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule2);
  font-size: 11.5px;
  color: var(--ink2);
}
.connection-banner[data-state="warn"] { background: var(--gold-bg); border-bottom-color: #EBDCBB; }
.connection-banner[data-state="bad"] { background: var(--red-bg); border-bottom-color: #EFD3CD; }

.banner-item { display: inline-flex; align-items: center; gap: 6px; }
.banner-item::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.banner-item.is-warn { color: var(--gold); }
.banner-item.is-warn::before { background: var(--gold-l); }
.banner-item.is-bad { color: var(--red); }
.banner-item.is-bad::before { background: var(--red); }
.integrity-line { margin-left: auto; color: var(--mut); }
.integrity-line b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Next event line ---------- */

.next-event {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--rule2);
  font-size: 12px;
  color: var(--ink2);
  min-width: 0;
}
.next-event::before {
  content: "NEXT USD";
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--faint);
  flex: 0 0 auto;
}
.ne-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.ne-when {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--mut);
}
.next-event.impact-high .ne-when { color: var(--red); }

/* ============================================================
 * Timeframe bar + drawing legend
 * ============================================================ */

.tfbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.tfbar::-webkit-scrollbar { display: none; }

.tf-tabs { display: flex; gap: 4px; flex: 0 0 auto; }

.tf {
  background: var(--card);
  border: 1px solid var(--rule);
  color: var(--mut);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-height: 28px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.tf:hover { color: var(--ink); border-color: var(--border-strong); background: var(--wash); }
.tf.active {
  color: var(--ink);
  background: var(--gold-bg);
  border-color: var(--gold-l);
}
.tf-tabs button.tf { cursor: pointer; }
.tf-tabs button.tf:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tf-static { cursor: default; }

.forming-badge {
  align-self: center;
  margin-left: 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-bg);
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  color: var(--mut);
  flex: 0 0 auto;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.legend-item.is-pending { opacity: 0.5; }
.legend-sep {
  width: 1px;
  height: 12px;
  background: var(--rule);
  flex: 0 0 auto;
}
.drawing-swatch {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
}
.drawing-swatch[data-style="dotted"] { background-size: 3px 2px !important; }
.drawing-swatch[data-style="dashed"] { background-size: 7px 2px !important; }
.drawing-swatch[data-style="rectangle"] { height: 8px; border-radius: 2px; opacity: 0.5; }
.drawing-key { max-width: 168px; overflow: hidden; text-overflow: ellipsis; }

/* A level outside the visible price range still exists — say so, quietly. */
.legend-item.offpane {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  background: var(--card);
}
.legend-item.offpane-sunday {
  border-color: var(--gold-l);
  color: var(--gold);
  font-weight: 600;
  background: var(--gold-bg);
}

/* ============================================================
 * Layout
 * ============================================================ */

.layout {
  flex: 1 1 auto;
  display: flex;
  gap: 14px;
  padding: 14px 20px 16px;
  min-height: 0;
  background: var(--paper);
}

#chart {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ---------- Right rail ---------- */

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  padding-right: 2px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.panel {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Panel head mimics the briefing's .sec-h: tracked label + hairline */
.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.panel-title {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.panel-state {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.panel-state[data-tone="live"] { color: var(--grn); }
.panel-state[data-tone="warn"] { color: var(--gold); }
.panel-state[data-tone="bad"] { color: var(--red); }

.panel-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mut);
  background: var(--slate-bg);
  border: 1px solid var(--rule);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel-body { padding: 12px 14px 13px; }

.panel-strategy.is-stale .panel-body { opacity: 0.6; }
.panel-strategy .panel-body { transition: opacity 200ms ease; }
.panel-exec .panel-body { padding-top: 11px; }

.empty {
  padding: 2px 0 4px;
  color: var(--faint);
  font-style: italic;
  font-size: 12px;
  line-height: 1.55;
}
.empty.inline { padding: 2px 0 4px; }
.empty.is-bad { color: var(--red); font-style: normal; }

/* ============================================================
 * Chips / tags
 * ============================================================ */

.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.chip {
  background: var(--card);
  border: 1px solid var(--rule);
  color: var(--mut);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.chip:hover { color: var(--ink); border-color: var(--border-strong); background: var(--wash); }
.chip.active {
  color: var(--ink);
  background: var(--gold-bg);
  border-color: var(--gold-l);
}
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.chip-static {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--slate-bg);
  font-size: 10.5px;
  color: var(--ink);
  white-space: nowrap;
}
.chip-k {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.regime-trend_up { border-color: #CFE4D8; background: var(--grn-bg); color: var(--grn); }
.regime-trend_down { border-color: #EFD3CD; background: var(--red-bg); color: var(--red); }
.vol-expanding { border-color: #EBDCBB; background: var(--gold-bg); color: var(--gold); }

/* ---------- Swatches ---------- */

.swatch {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.swatch.poc { background: var(--gold); }
.swatch.vah { background: var(--grn); }
.swatch.val { background: var(--red); }
.swatch.ps-poc { background: var(--blue); }
.swatch.cw-poc { background: var(--violet); }
.swatch.cw-vah { background: var(--pink); }
.swatch.cw-val { background: var(--cyan); }
.swatch.swing-bull-poc { background: #2E7D5B; }
.swatch.swing-bull-vah { background: #4E9C79; }
.swatch.swing-bull-val { background: #8CBFAA; }
.swatch.swing-bear-poc { background: #A8321F; }
.swatch.swing-bear-vah { background: #C05B36; }
.swatch.swing-bear-val { background: #D99775; }
.swatch.pos-entry { background: var(--gold); border-radius: 1px; width: 8px; height: 2px; }
.swatch.pos-sl { background: var(--red); border-radius: 1px; width: 8px; height: 2px; }
.swatch.pos-tp { background: var(--grn); border-radius: 1px; width: 8px; height: 2px; }

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

.strat-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}

/* The action badge is the panel's headline — set it like a serif standfirst */
.action-badge {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  line-height: 1.25;
  text-transform: capitalize;
}
.action-badge.is-buy { color: var(--grn); background: var(--grn-bg); border-color: #CFE4D8; }
.action-badge.is-sell { color: var(--red); background: var(--red-bg); border-color: #EFD3CD; }
.action-badge.is-flat { color: var(--ink2); background: var(--slate-bg); border-color: var(--rule); }
.action-badge.is-unknown { color: var(--mut); background: var(--slate-bg); border-color: var(--rule); }

.strat-symbol {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink2);
}

.engine-chip {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  color: var(--mut);
  background: var(--card);
  white-space: nowrap;
}
.engine-chip.is-on { color: var(--grn); border-color: #CFE4D8; background: var(--grn-bg); }
.engine-chip.is-off { color: var(--gold); border-color: #EBDCBB; background: var(--gold-bg); }

.strat-age {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.strat-age.is-stale { color: var(--faint); }

.strat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

/* ---------- Confidence meter ---------- */

.gauge-block { margin-bottom: 12px; }

.meter {
  position: relative;
  height: 6px;
  border-radius: 2px;
  background: var(--slate-bg);
  border: 1px solid var(--rule);
}
.meter-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: 1px;
  background: var(--gold-l);
  transition: width 200ms ease;
}
.meter-tick {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: var(--ink);
  transform: translateX(-1px);
}
.meter-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--faint);
}
.meter-legend b {
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- Score bar ---------- */

.score-block { margin-bottom: 2px; }
.score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.score-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-transform: none;
}
.score-value.is-bull { color: var(--grn); }
.score-value.is-bear { color: var(--red); }
.score-track {
  position: relative;
  height: 5px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--slate-bg);
  border: 1px solid var(--rule);
}
.score-zero {
  position: absolute;
  left: 50%;
  top: -2px; bottom: -2px;
  width: 1px;
  background: var(--border-strong);
}
.score-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 1px;
  transition: width 200ms ease;
}
.score-fill.is-bull { background: var(--grn); }
.score-fill.is-bear { background: var(--red); }
.score-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 9.5px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Key/value grid ---------- */

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 10px 0;
  padding: 0;
  border-top: 1px solid var(--rule2);
}
.kv-grid > div {
  min-width: 0;
  padding: 7px 0 6px;
  border-bottom: 1px solid var(--rule2);
}
.kv-grid > div:nth-child(odd) { padding-right: 8px; }
.kv-grid dt {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}
.kv-grid dd {
  margin: 1px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kv-grid dd .muted { font-weight: 400; font-size: 10.5px; }
.kv-wide { grid-column: 1 / -1; }

/* ---------- Sub-heads ---------- */

.subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 13px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.subhead .muted {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--faint);
}

/* ---------- Reasons ---------- */

.reasons { display: flex; flex-direction: column; gap: 9px; }

.reason-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11.5px;
}
.reason-name { flex: 1 1 auto; min-width: 0; color: var(--ink2); }
.reason-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.reason-val.is-bull { color: var(--grn); }
.reason-val.is-bear { color: var(--red); }
.reason-val.is-flat { color: var(--mut); }
.reason-weight {
  width: 42px;
  text-align: right;
  color: var(--faint);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
}
.reason-bar {
  position: relative;
  height: 4px;
  margin-top: 4px;
  border-radius: 1px;
  background: var(--slate-bg);
}
.reason-zero {
  position: absolute;
  left: 50%;
  top: -1px; bottom: -1px;
  width: 1px;
  background: var(--border-strong);
}
.reason-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 1px;
}
.reason-fill.is-bull { background: var(--grn); }
.reason-fill.is-bear { background: var(--red); }
.reason-fill.is-flat { background: var(--faint); }
.reason-detail {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--faint);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ---------- Notes / callouts ---------- */

.notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding: 9px 11px;
  background: var(--slate-bg);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.notes .note {
  font-size: 11px;
  color: var(--ink2);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.notes.is-flat {
  background: var(--gold-bg);
  border-left-color: var(--gold-l);
}
.notes.is-flat .note { color: #6B5316; }

/* ---------- Decision history ---------- */

.history-svg {
  display: block;
  width: 100%;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--rule2);
  border-radius: var(--radius-sm);
}
.hist-buy { fill: var(--grn); }
.hist-sell { fill: var(--red); }
.hist-flat { fill: var(--faint); }
.hist-line {
  stroke: var(--ink2);
  stroke-opacity: 0.4;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.hist-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 9.5px;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hist-dot {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 3px;
  border-radius: 1px;
}
.hist-dot.is-buy { background: var(--grn); }
.hist-dot.is-sell { background: var(--red); }
.hist-dot.is-flat { background: var(--faint); }

.strat-conn {
  margin-top: 10px;
  font-size: 11px;
  color: var(--gold);
  line-height: 1.55;
}

/* ---------- Loading shimmer ---------- */

.skeleton-line {
  height: 7px;
  margin-bottom: 7px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--rule2), var(--wash), var(--rule2));
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.w40 { width: 40%; }
.w55 { width: 55%; }
.w60 { width: 60%; }
.w70 { width: 70%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
  .meter-fill, .score-fill, .panel-strategy .panel-body,
  .icon-btn, .chip, .tf, #last-price, .skip-link { transition: none; }
}

/* ============================================================
 * Open position
 * ============================================================ */

.pos-head { display: flex; align-items: center; gap: 8px; }

.side-chip {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.side-chip.is-buy { color: var(--grn); background: var(--grn-bg); border-color: #CFE4D8; }
.side-chip.is-sell { color: var(--red); background: var(--red-bg); border-color: #EFD3CD; }

.pos-lots {
  font-size: 11px;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
}
.pos-pnl {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.pos-pnl.is-pos { color: var(--grn); }
.pos-pnl.is-neg { color: var(--red); }

.pos-bar {
  position: relative;
  height: 8px;
  margin: 12px 0 5px;
  border-radius: 2px;
  background: var(--slate-bg);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.pos-zone { position: absolute; top: 0; bottom: 0; }
.pos-zone.is-profit { background: #CFE4D8; }
.pos-zone.is-loss { background: #EFD3CD; }
.pos-entry {
  position: absolute;
  top: -1px; bottom: -1px;
  width: 2px;
  background: var(--ink);
  opacity: 0.7;
  transform: translateX(-1px);
}
.pos-stop {
  position: absolute;
  top: 1px; bottom: 1px;
  width: 2px;
  background: var(--red);
  transform: translateX(-1px);
}
.pos-price {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: var(--ink);
  transform: translateX(-1px);
}
.pos-price.is-buy { background: var(--grn); }
.pos-price.is-sell { background: var(--red); }

.pos-scale {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 9.5px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pos-scale span:nth-child(2) { color: var(--gold); font-weight: 600; }

.pos-last-note {
  margin-top: 10px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
  overflow-wrap: anywhere;
}
.pos-no-target {
  margin: 10px 0;
  font-size: 11px;
  font-style: italic;
  color: var(--faint);
}

/* ============================================================
 * Performance grid — briefing stat cells
 * ============================================================ */

.perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0;
  background: var(--rule2);
  border: 1px solid var(--rule2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.perf-cell { padding: 9px 10px; background: var(--card); }
.perf-cell dt {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}
.perf-cell dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.perf-cell dd.is-pos { color: var(--grn); }
.perf-cell dd.is-neg { color: var(--red); }

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

.table-scroll {
  max-height: 320px;
  overflow: auto;
  margin: 0 -14px;
  padding: 0 14px 2px;
  scrollbar-width: thin;
}
.table-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.trades-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 11.5px;
}
.trades-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  padding: 0 6px 7px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--rule);
}
.trades-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--rule2);
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
}
.trades-table tbody tr:hover { background: #FCFBF8; }
.trades-table .num { text-align: right; }
.trades-table td.is-pos { color: var(--grn); font-weight: 600; }
.trades-table td.is-neg { color: var(--red); font-weight: 600; }

/* Exit tags, exactly like the briefing's .tag variants */
.exit-chip {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.exit-chip.is-sl { color: var(--red); background: var(--red-bg); border-color: #EFD3CD; }
.exit-chip.is-tp { color: var(--grn); background: var(--grn-bg); border-color: #CFE4D8; }
.exit-chip.is-flip { color: var(--blue); background: #EAF0F7; border-color: #D2E0EE; }
.exit-chip.is-stop-out { color: #A8641F; background: #FBF0E2; border-color: #EFDCC2; }
.exit-chip.is-other { color: var(--mut); background: var(--slate-bg); border-color: var(--rule); }

/* ============================================================
 * Levels
 * ============================================================ */

.level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--rule2);
}
.level-row:last-child { border-bottom: 0; }
.level-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--mut);
}
.level-price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-weight: 600;
}

.level-anchor {
  margin: 6px -14px 0;
  padding: 5px 14px;
  background: var(--wash);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  border-top: 1px solid var(--rule2);
  border-bottom: 1px solid var(--rule2);
}
.level-meta {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--faint);
}
.level-pending .level-label { color: var(--faint); }
.level-pending .level-meta { font-style: italic; color: var(--faint); }

/* ============================================================
 * Calendar
 * ============================================================ */

.impact-high { --impact: var(--red); }
.impact-medium { --impact: var(--gold-l); }
.impact-low { --impact: var(--faint); }
.impact-holiday { --impact: var(--blue); }

.impact-bar {
  display: inline-block;
  width: 3px;
  height: 13px;
  border-radius: 1px;
  background: var(--impact, var(--faint));
  flex: 0 0 auto;
}

.day-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 -14px;
  padding: 5px 14px;
  background: var(--wash);
  border-top: 1px solid var(--rule2);
  border-bottom: 1px solid var(--rule2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mut);
}

.event-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule2);
}
.event-row.is-past { opacity: 0.55; }
.event-row.is-next {
  background: var(--gold-bg);
  box-shadow: inset 3px 0 0 var(--gold-l);
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
}

.ev-time { display: flex; flex-direction: column; gap: 1px; }
.ev-clock {
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink2);
}
.ev-countdown {
  font-size: 9.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.ev-main { min-width: 0; }
.ev-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ev-name {
  font-size: 12px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.impact-high .ev-name { font-weight: 600; }

.ev-gold {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: var(--gold-bg);
  border: 1px solid #EBDCBB;
  border-radius: var(--radius-sm);
  padding: 0 4px;
}

.ev-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
  padding-left: 9px;
  border-left: 1px solid var(--rule2);
}
.ev-val {
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-val em {
  font-style: normal;
  color: var(--faint);
  font-size: 9.5px;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ev-val.is-empty { color: var(--faint); }
.ev-val.is-above { color: var(--grn); }
.ev-val.is-below { color: var(--red); }

.cal-foot {
  padding: 9px 0 0;
  font-size: 9.5px;
  color: var(--faint);
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================================================
 * Settings drawer
 * ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(19, 23, 30, 0.3);
  backdrop-filter: blur(1.5px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(430px, 100vw);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: var(--shadow-lg);
}

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 12px;
  background: var(--card);
  border-bottom: 2px solid var(--ink);
}
.drawer-heading { flex: 1 1 auto; min-width: 0; }
.drawer-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.drawer-head h2 {
  font-family: var(--font-serif);
  margin: 2px 0 0;
  font-size: 20px;
  letter-spacing: -0.01em;
  font-weight: 600;
  color: var(--ink);
}
.drawer-stamp {
  flex: 0 0 auto;
  font-size: 9.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-b));
}

.drawer-section {
  padding: 13px 18px;
  border-bottom: 1px solid var(--rule);
}
.drawer-section:nth-child(odd) { background: var(--card); }
.drawer-section h3 {
  margin: 0 0 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}
.drawer-rows { display: flex; flex-direction: column; }

.drawer-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 12px;
}
.drawer-row:last-child { border-bottom: 0; }
.drawer-key {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--mut);
}
.drawer-val {
  flex: 0 1 auto;
  text-align: right;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.drawer-val.is-live { color: var(--grn); }
.drawer-val.is-warn { color: var(--gold); }
.drawer-val.is-bad { color: var(--red); }

.feed-chip {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  color: var(--mut);
  background: var(--slate-bg);
}
.feed-chip.is-live { color: var(--grn); background: var(--grn-bg); border-color: #CFE4D8; }
.feed-chip.is-warn { color: var(--gold); background: var(--gold-bg); border-color: #EBDCBB; }
.feed-chip.is-bad { color: var(--red); background: var(--red-bg); border-color: #EFD3CD; }

.drawer-note {
  margin: 0;
  padding: 14px 18px;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--faint);
  border-top: 1px solid var(--rule);
}

/* ============================================================
 * Execution diagnostics
 * ============================================================ */

.dry-run-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 20px;
  background: var(--gold-bg);
  border-bottom: 1px solid #EBDCBB;
  color: #6B5316;
  font-size: 11.5px;
  line-height: 1.45;
}

.dry-run-tag {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--card);
  background: var(--gold);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
}

.exec-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.exec-status[data-tone="live"] { color: var(--grn); }
.exec-status[data-tone="warn"] { color: var(--gold); }
.exec-status[data-tone="bad"] { color: var(--red); }
.exec-status[data-tone="muted"] { color: var(--mut); }

.exec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.exec-flag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid #EBDCBB;
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
}

.exec-reason {
  margin: 8px 0 0;
  padding: 8px 11px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink2);
  background: var(--slate-bg);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow-wrap: anywhere;
}
.exec-reason[data-tone="bad"] { background: var(--red-bg); border-left-color: var(--red); color: #7C2416; }
.exec-reason[data-tone="warn"] { background: var(--gold-bg); border-left-color: var(--gold-l); color: #6B5316; }
.exec-reason[data-tone="muted"] { color: var(--mut); }

.exec-note {
  margin: 9px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
  overflow-wrap: anywhere;
}
.exec-note.is-warn { color: var(--gold); }
.exec-note.is-bad { color: var(--red); }

.exec-meta {
  margin-top: 7px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
  overflow-wrap: anywhere;
}
.exec-meta .muted { margin-right: 4px; }

.exec-id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink2);
  background: var(--slate-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

.integrity {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.integrity-chip {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--mut);
  background: var(--slate-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
}
.integrity-chip b {
  margin-left: 2px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.integrity-chip.is-bad {
  color: var(--red);
  border-color: #EFD3CD;
  background: var(--red-bg);
}
.integrity-chip.is-bad b { color: var(--red); }

.exec-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 0;
}
.exec-symbol {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink2);
}
.exec-version {
  font-size: 9.5px;
  color: var(--faint);
  letter-spacing: 0.03em;
  margin-left: auto;
  overflow-wrap: anywhere;
}

.exec-intents {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 10px;
  background: var(--rule2);
  border: 1px solid var(--rule2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.exec-intent {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  background: var(--card);
}
.exec-intent-key {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}
.exec-intent b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ============================================================
 * Dense metric rows (Node 3 / Node 1 v2 panels)
 * ============================================================ */

.metrics, .detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}
.metric, .detail-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 11.5px;
}
.metric > span, .detail-row > span {
  color: var(--mut);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric > b, .detail-row > b {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.metric > b.is-live, .detail-row > b.is-live { color: var(--grn); }
.metric > b.is-warn, .detail-row > b.is-warn { color: var(--gold); }
.metric > b.is-bad, .detail-row > b.is-bad { color: var(--red); }

/* ---------- Levels board ---------- */

.node3-levels { display: flex; flex-direction: column; }
.node3-level-row {
  display: grid;
  grid-template-columns: 40px repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule2);
}
.node3-level-row:last-child { border-bottom: 0; }
.level-window {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.level-cell { display: flex; flex-direction: column; min-width: 0; }
.level-cell em {
  font-style: normal;
  font-size: 9.5px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.level-cell b {
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.level-cell.level-only {
  grid-column: span 2;
  font-size: 10.5px;
  color: var(--faint);
  font-style: italic;
}
.level-foot {
  grid-column: 1 / -1;
  font-size: 9.5px;
  color: var(--faint);
  font-family: var(--font-mono);
}

/* ---------- Setups ---------- */

.setup-group { margin-top: 12px; }
.setup-group:first-child { margin-top: 0; }
.setup-group h3 {
  margin: 8px 0 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-transform: uppercase;
  font-weight: 700;
}
.setup-card {
  padding: 11px 12px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--card);
}
.setup-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; align-items: baseline; }
.setup-head b { font-size: 12px; font-weight: 600; color: var(--ink); }
.setup-state {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid #EBDCBB;
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
}
.scanning-summary { margin-bottom: 8px; }

.projection-block {
  margin-top: 9px;
  border-top: 1px solid var(--rule2);
  padding-top: 7px;
}
.projection-label {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 5px;
  font-weight: 700;
}
.projection {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 10.5px;
  color: var(--mut);
}
.projection b {
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.projection-side { grid-column: 1 / -1; color: var(--blue); font-weight: 600; }
.projection-sizing {
  grid-column: 1 / -1;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 10px;
}
.setup-note, .panel-note {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------- Level execution state machine ---------- */

.level-board-row {
  padding: 10px 11px 11px;
  margin-bottom: 8px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
}
.level-board-row:last-child { margin-bottom: 0; }
.level-board-row.is-live { border-left-color: var(--grn); }
.level-board-row.is-ok { border-left-color: var(--grn); }
.level-board-row.is-warn { border-left-color: var(--gold-l); background: #FEFCF6; }
.level-board-row.is-bad { border-left-color: var(--red); }
.level-board-row.is-muted { opacity: 0.7; }

.board-head { display: flex; align-items: baseline; gap: 6px; }
.board-window {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid #EBDCBB;
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
.board-name { font-size: 12px; flex: 1; min-width: 0; font-weight: 600; color: var(--ink); }
.board-price {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.board-state {
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.board-state.is-live { color: var(--grn); }
.board-state.is-warn { color: var(--gold); }
.board-state.is-bad { color: var(--red); }
.board-state.is-muted { color: var(--faint); }

.pipeline { display: flex; gap: 3px; margin: 7px 0 3px; flex-wrap: wrap; }
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  background: var(--card);
}
.pipeline-step i { font-style: normal; font-size: 9px; }
.pipeline-step.is-done { color: var(--grn); border-color: #CFE4D8; background: var(--grn-bg); }
.pipeline-step.is-active { color: var(--gold); border-color: var(--gold-l); background: var(--gold-bg); }
.pipeline-step.is-failed { color: var(--red); border-color: #EFD3CD; background: var(--red-bg); }

.board-metrics { margin-top: 7px; }
.board-exec {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dotted var(--rule);
  font-size: 9.5px;
  color: var(--faint);
  font-family: var(--font-mono);
}
.board-exec-label {
  color: var(--violet);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

/* ---------- Signals / reports ---------- */

.signals-summary, .tick-metrics, .vp-summary { margin-bottom: 9px; }
.signals-table, .report-list { width: 100%; }

/* Long intent IDs scroll inside their own panel body — never widen the rail */
#signals-list {
  overflow-x: auto;
  scrollbar-width: thin;
}
#signals-list::-webkit-scrollbar { height: 6px; }
#signals-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.signals-table {
  border-collapse: collapse;
  font-size: 10.5px;
  width: auto;
  min-width: 100%;
}
.signals-table th {
  text-align: left;
  color: var(--faint);
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 6px 7px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.signals-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--rule2);
  color: var(--mut);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.signals-table td b, .signals-table td.mono { color: var(--ink); font-weight: 600; }
.signals-table td:first-child, .signals-table th:first-child {
  position: sticky;
  left: 0;
  background: var(--card);
}
.signals-table td:first-child {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink);
}

.report-row {
  display: grid;
  grid-template-columns: 1.3fr .7fr .8fr .9fr 1fr;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 10.5px;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
}

.integrity-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--slate-bg);
  font-size: 10.5px;
  color: var(--ink2);
}
.integrity-box.is-bad {
  border-color: #EFD3CD;
  border-left-color: var(--red);
  background: var(--red-bg);
  color: #7C2416;
}

.event-log { display: flex; flex-direction: column; }
.log-row {
  display: grid;
  grid-template-columns: 56px 66px 1fr;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule2);
  font-size: 10.5px;
  color: var(--faint);
  font-family: var(--font-mono);
}
.log-row b { color: var(--blue); font-weight: 600; }
.log-row.warn b, .log-row.error b { color: var(--red); }
.log-row.error { color: var(--red); }
.log-row.warn { color: var(--gold); }

/* ---------- FRVP ---------- */

.vp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 12px;
  font-size: 10.5px;
  color: var(--faint);
}
.vp-controls label { display: flex; align-items: center; gap: 5px; }
.vp-controls input {
  min-width: 0;
  min-height: 28px;
  width: 132px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color-scheme: light;
}
.vp-controls input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.vp-controls input[type="number"] { width: 62px; }

.vp-rows { display: flex; flex-direction: column; gap: 3px; }
.vp-row {
  display: grid;
  grid-template-columns: 58px 1fr 52px;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}
.vp-bar {
  position: relative;
  height: 7px;
  background: var(--slate-bg);
  border-radius: 1px;
  overflow: hidden;
}
.vp-bar > i { display: block; height: 100%; background: var(--blue); opacity: 0.18; }
.vp-bar > i.vp-up {
  position: absolute;
  left: 0; top: 0;
  background: var(--grn);
  opacity: 0.32;
}

/* ---------- Published work fields ---------- */

.diagnostics-all {
  margin-top: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 8px;
  font-size: 10.5px;
  color: var(--mut);
}
.diagnostics-all > summary {
  cursor: pointer;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.diagnostics-all > summary:hover { color: var(--ink); }

/* ---------- Paper engine ---------- */

.demo-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.demo-strip::-webkit-scrollbar { display: none; }
.demo-strip.is-off { opacity: 0.6; }

.demo-id { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.demo-mode {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-bg);
  border: 1px solid #EBDCBB;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
}
.demo-spec { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.demo-engine {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
  border: 1px solid #EFD3CD;
  background: var(--red-bg);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
}
.demo-stats {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.demo-stat {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 76px;
  padding-left: 16px;
  border-left: 1px solid var(--rule2);
}
.demo-stat:first-child { padding-left: 0; border-left: 0; }
.demo-stat dt {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  white-space: nowrap;
}
.demo-stat dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.demo-stat dd.is-pos { color: var(--grn); }
.demo-stat dd.is-neg { color: var(--red); }
.demo-stat dd.is-warn { color: var(--gold); }
.demo-updated {
  flex: 0 0 auto;
  font-size: 9.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.demo-summary { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.demo-trades { display: flex; flex-direction: column; gap: 2px; }
.demo-row {
  grid-template-columns: minmax(0, 1.4fr) 80px minmax(0, 1fr) minmax(0, 1fr) 80px;
  align-items: baseline;
}
.demo-row b { text-align: right; }
.demo-row .is-ok, .demo-row .is-bad { white-space: nowrap; }

/* ============================================================
 * Responsive
 * ============================================================ */

@media (max-width: 980px) {
  :root { --sidebar-w: 336px; }
  .demo-stats, .system-stats { gap: 14px; }
  .demo-stat, .system-stat { min-width: 68px; }
}

@media (max-width: 820px) {
  .layout { padding: 12px 14px 14px; }
  .tfbar, .system-strip, .demo-strip, .next-event, .connection-banner { padding-left: 14px; padding-right: 14px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
}

@media (max-width: 720px) {
  /* Masthead stays one row: badges scroll, price stays pinned. */
  .topbar { flex-wrap: nowrap; align-items: center; gap: 8px; }
  .brand {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .brand::-webkit-scrollbar { display: none; }
  .brand-sub { display: none; }
  .price-wrap { flex: 0 0 auto; gap: 6px; }

  .layout { flex-direction: column; padding: 10px; gap: 10px; }
  #chart { flex: 1 1 46%; min-height: 250px; }
  .sidebar { flex: 0 0 54%; width: 100%; }

  .panel-head { padding: 9px 12px; }
  .panel-body { padding: 10px 12px 12px; }
  .level-anchor { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .day-head { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .table-scroll { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .event-row.is-next { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .vp-controls { padding-left: 12px; padding-right: 12px; }

  /* Comfortable touch targets */
  .chip { min-height: 30px; padding: 5px 11px; }
  .tf { min-height: 32px; padding: 6px 13px; }
  .icon-btn { width: 36px; height: 36px; }
  .event-row, .level-row { padding-top: 10px; padding-bottom: 10px; }

  .demo-strip { flex-wrap: wrap; gap: 8px 14px; overflow: visible; padding: 8px 12px; }
  .demo-stats { flex-wrap: wrap; gap: 8px 18px; width: 100%; }
  .demo-updated { display: none; }
  .demo-row { grid-template-columns: 1fr 1fr; row-gap: 2px; }

  .dry-run-banner { padding: 6px 12px; font-size: 11px; }
  .connection-banner { max-height: 74px; }
  .system-strip { flex-wrap: wrap; gap: 8px 14px; }
  .system-stats { flex-wrap: wrap; width: 100%; }
  .system-stat, .demo-stat { padding-left: 0; border-left: 0; }
  .system-updated { display: none; }

  .metrics, .detail-grid { grid-template-columns: 1fr; }
  .node3-level-row { grid-template-columns: 36px repeat(3, minmax(0, 1fr)); }
  .report-row { grid-template-columns: 1fr 1fr; }
  .vp-controls input { width: 118px; }
}

@media (max-width: 420px) {
  .contract-badges, #node3-stream-badge { display: none; }
  .system-mode, .system-spec { display: none; }
  .banner-item::before { display: none; }
  .tps-label { display: none; }
  #last-price { font-size: 21px; }
  .demo-stat { min-width: 62px; }
  .demo-stat dd { font-size: 11.5px; }
  .ev-values { padding-left: 0; border-left: 0; }
  .legend-sep { display: none; }
  .action-badge, .exec-status { font-size: 15px; }
}

/* Landscape phones: keep the chart tall, rail beside it */
@media (max-width: 920px) and (max-height: 500px) and (orientation: landscape) {
  .layout { flex-direction: row; }
  #chart { flex: 1 1 auto; min-height: 0; }
  .sidebar { flex: 0 0 272px; width: 272px; }
  .tfbar, .next-event, .demo-strip, .system-strip { padding-top: 4px; padding-bottom: 4px; }
}

/* ---------------------------------------------------------------- positions
 * Recent positions: the live book (at most one open position) above the
 * newest closes. Tabular numbers, no colour except P&L and
 * side. Every value is published by Node 4; this only adds rhythm.
 * ------------------------------------------------------------------------ */
/* `.report-row` is a five-column grid for a different panel. A position needs
 * two lines at the sidebar's width, so it opts out of that grid entirely:
 * line one is identity and P&L, line two is the price bracket. */
.report-list .position-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  white-space: normal;
  font-size: 11px;
}

.report-list .position-row:last-child { border-bottom: 0; }

.position-row.is-closed { opacity: 0.85; }

.position-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.position-line.muted { font-size: 10.5px; }

.position-side {
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

.position-level {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-size { flex: 0 0 auto; }

.position-pnl {
  flex: 0 0 auto;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.position-prices { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.position-brackets,
.position-result,
.position-when { flex: 0 0 auto; }

.position-when { margin-left: auto; }

#positions-note { margin: 0.35rem 0 0; }

/* Wrap, never truncate: on a narrow rail the price line falls to a third row.
 * (An earlier rule hid SL/TP here — that is exactly the information the panel
 * exists to show.) */
@media (max-width: 720px) {
  .report-list .position-row { padding: 0.55rem 0; }
  .position-line { flex-wrap: wrap; row-gap: 2px; }
  .position-level { flex: 1 1 60%; }
  .position-when { margin-left: 0; }
}
