:root {
  --bg: #0b0e14;
  --panel: #141821;
  --panel-alt: #1b202c;
  --border: #262c3a;
  --text: #e6e9ef;
  --text-dim: #8b93a7;
  --accent: #4f8cff;
  --accent-dim: #2c4a80;
  --green: #2ecc71;
  --red: #ff5c5c;
  --amber: #e8a33d;
  --radius: 8px;
  --border-strong: #3d4763;
  /* Fourth elevation tone -- lighter than --panel-alt, reserved for things
     that should read as floating ABOVE card level (toasts, popovers) so
     they have visual depth distinct from in-flow panels. */
  --panel-float: #232a3a;
  --transition-fast: 140ms ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }

#app { min-height: 100vh; display: flex; flex-direction: row; }

.topnav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 20px 12px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  border-bottom: none;
  width: 220px;
  min-width: 220px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.topnav-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.brand { font-weight: 700; font-size: 16px; padding: 0 12px; margin-bottom: 0; }
.nav-toggle {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  margin-right: 8px;
  flex: 0 0 auto;
}
/* FX session-hours widget (sessionClock.js) -- lives in the nav on every
   page, always visible (outside the collapsible .nav-links/.nav-user
   sections below) so it's readable without opening the mobile menu. */
.session-clock {
  padding: 0 12px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.session-clock-time { font-weight: 600; color: var(--text); font-size: 12px; margin-bottom: 6px; }
.session-clock-sessions { display: flex; gap: 8px; flex-wrap: wrap; }
.session-pill { display: inline-flex; align-items: center; gap: 4px; letter-spacing: 0.03em; }
.session-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.session-dot.open { background: var(--green); box-shadow: 0 0 4px var(--green); }
.session-clock-overlap { color: var(--amber); font-weight: 600; }

.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; flex-wrap: nowrap; }
.nav-link {
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 14px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav-link:hover { background: var(--panel-alt); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: #fff; }
.nav-user {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: auto;
  padding: 12px 12px 0;
  border-top: 1px solid var(--border);
}
.nav-email { color: var(--text-dim); font-size: 12px; word-break: break-all; }

.content { flex: 1; min-width: 0; padding: 20px; width: 100%; }

@media (max-width: 900px) {
  #app { flex-direction: column; }
  .topnav {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 0;
    overflow: visible;
  }
  .topnav-header { margin-bottom: 0; }
  .nav-toggle { display: inline-flex; }
  .session-clock { padding: 8px 0 0; margin-bottom: 0; border-bottom: none; }
  .session-clock-sessions { font-size: 10px; }
  /* Collapsed by default on mobile/tablet -- expanded only via .nav-open,
     toggled by the hamburger button. Replaces the old "wrap everything into
     a horizontal strip" behavior, which crammed 12 nav links + email +
     sign-out into one crowded row at phone widths. */
  .nav-links, .nav-user {
    display: none;
    flex-direction: column;
    width: 100%;
    flex-wrap: nowrap;
  }
  .nav-user {
    margin-top: 8px;
    padding: 8px 0 0;
    border-top: 1px solid var(--border);
  }
  .topnav.nav-open .nav-links,
  .topnav.nav-open .nav-user {
    display: flex;
  }
  .topnav.nav-open .nav-links { margin-top: 8px; }
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}
.btn:hover { border-color: var(--accent); background: var(--panel-float); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

/* Opt-in lift-on-hover for cards that represent a distinct, "look at me"
   item in a list (dashboard tiles, mentor cards) -- not applied to every
   .card globally, since a whole page of cards all lifting on every mouse
   pass reads as noisy rather than polished. */
.card-hover:hover { transform: translateY(-2px); border-color: var(--border-strong); }

/* Lighter-touch accent border for cards that want a quick-scan category
   color without the full Signals-page treatment below -- just a colored
   left edge on top of the normal .card border. */
.card-accent-blue { border-left: 3px solid var(--accent); }
.card-accent-green { border-left: 3px solid var(--green); }
.card-accent-red { border-left: 3px solid var(--red); }
.card-accent-amber { border-left: 3px solid var(--amber); }

.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

/* Live Scan signal cards — a stack of many peer cards needs a bolder,
   higher-contrast edge than the default .card border (tuned for a single
   always-present panel) so the eye can tell one card from the next at a
   glance while scrolling. Three layered accents, all keyed off the same
   direction color (green for long, red for short), set inline per card:
   a thin thin translucent border hugging the card, a bolder thick
   translucent ring offset outside it for a "framed" look, and the
   original bright solid left edge kept as the fastest at-a-glance cue.
   Translucent rather than full-bright on the two perimeter lines so they
   don't visually compete with the left edge or the red/green text inside. */
.signal-card {
  border: 1.5px solid var(--border-strong);
  border-left-width: 5px;
  outline: 3px solid transparent;
  outline-offset: 5px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
  transition: outline-color var(--transition-fast), border-color var(--transition-fast);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; }
td { padding: 8px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--panel-alt); }

input, select, textarea {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
}
/* The width:100% above is meant for text/number/select fields -- applied to
   a checkbox or radio it stretches the native control to fill its
   container's full width (and the 8px/10px padding balloons its hit box
   further), which is why the checklist and every other on/off checkbox in
   the app rendered as a huge misshapen box instead of a normal tickbox.
   flex-shrink:0 keeps it from getting squeezed to nothing when it's a flex
   child next to a label (see .checklist-item below). */
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  flex-shrink: 0;
}
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; margin-top: 10px; }
form { display: flex; flex-direction: column; }

/* Pre-trade checklist -- shared widget (see buildChecklistWidget in
   router.js), used on Paper Trading and the Trading Desk's Paper Trading
   tab. A plain label (not a <label> with default block/margin-top styling
   above) so each item reads as one tappable row on mobile without the
   checkbox and its text drifting apart. */
.checklist-item {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 13px;
  margin: 0;
  padding: 4px 0;
}
@media (max-width: 480px) {
  .checklist-item { font-size: 14px; padding: 6px 0; }
  input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; }
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  margin-right: 4px;
  margin-bottom: 4px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
/* Tinted background (not just an outline) so provenance reads at a glance
   in a dense tag list, not only on close reading of the border color. */
.tag-public { background: rgba(46, 204, 113, 0.12); border-color: rgba(46, 204, 113, 0.4); color: #6be3a0; }
.tag-private { background: rgba(232, 163, 61, 0.12); border-color: rgba(232, 163, 61, 0.4); color: #f0bc6b; }

.pill-long { color: var(--green); }
.pill-short { color: var(--red); }
/* Direction glyph ahead of the text everywhere a pill class is used
   (tables, signal card headers, live-signal panels) -- color alone isn't
   enough of a cue for colorblind users, and it reads faster at a glance
   even for everyone else. One CSS rule covers every existing call site,
   no per-page changes needed. */
.pill-long::before { content: "▲ "; }
.pill-short::before { content: "▼ "; }

.error-banner { background: #3a1a1a; border: 1px solid var(--red); color: var(--red); padding: 12px; border-radius: var(--radius); }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card { width: 360px; }

/* Toasts float above card level -- panel-float (the 4th elevation tone)
   instead of panel-alt gives them a subtle "raised above the page" depth
   that a same-tone-as-cards background didn't. */
.toast-root { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { padding: 10px 16px; border-radius: var(--radius); background: var(--panel-float); border: 1px solid var(--border-strong); font-size: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.toast-error { border-color: var(--red); color: var(--red); }
.toast-success { border-color: var(--green); color: var(--green); }

/* Confidence meter -- thin fill bar under a signal's confidence %,
   color matched to the card's direction accent, width set inline per
   instance to the confidence value. */
.confidence-meter { height: 4px; background: var(--panel-alt); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.confidence-meter-fill { height: 100%; transition: width var(--transition-fast); }

/* Skeleton loading placeholders -- swapped in for plain "Loading…" text
   on the highest-traffic pages so the shape of what's coming is visible
   immediately instead of a blank line. */
@keyframes skeleton-shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
.skeleton { background: linear-gradient(90deg, var(--panel-alt) 25%, var(--panel-float) 37%, var(--panel-alt) 63%); background-size: 600px 100%; animation: skeleton-shimmer 1.6s infinite linear; border-radius: 4px; }
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line:last-child { margin-bottom: 0; }

.chart-container { width: 100%; height: 560px; }

/* Signals page's per-card chart resize handle -- same drag-a-bar-to-resize
   idea as .workspace-resize-handle on the Trading Desk page, but this one
   sits in plain block flow (a signal card, not a fixed-viewport flex
   shell), so no flex/JS accounting is needed for what's below it to move
   out of the way -- growing or shrinking the chart container above this
   handle just pushes the rest of the card, and every card after it, down
   or back up on its own. touch-action:none stops the browser from trying
   to scroll the page while dragging on a phone. */
.chart-resize-handle {
  width: 100%;
  height: 14px;
  margin-top: 2px;
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.chart-resize-handle::before {
  content: "";
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background-color var(--transition-fast);
}
.chart-resize-handle:hover::before, .chart-resize-handle.dragging::before { background: var(--accent); }
@media (max-width: 640px) {
  .chart-resize-handle { height: 22px; }
}

.muted { color: var(--text-dim); }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* Chat / Roundtable (§9) */
.chat-layout { display: flex; gap: 16px; align-items: flex-start; }
.chat-sidebar { width: 260px; min-width: 260px; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-conversation-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  margin-top: 4px;
}
.chat-conversation-item:hover { background: var(--panel-alt); }
.message-list {
  flex: 1;
  min-height: 320px;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-top: 8px;
  background: var(--panel-alt);
}
.chat-message { padding: 6px 0; font-size: 14px; }
.chat-message.mentor strong { color: var(--accent); }
.video-tiles { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.video-tiles video { width: 220px; border-radius: var(--radius); background: #000; }
/* Charting tools (§9.4) — vertical toolbar docked to the chart's left
   edge, TradingView-style, instead of the small unlabeled corner buttons
   this used to be (which were easy to miss entirely). */
.charting-toolbar {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.drawing-tool-btn {
  width: auto;
  min-width: 56px;
  height: 28px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.drawing-tool-btn:hover { background: var(--panel-alt); }
.drawing-tool-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.drawing-tool-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* Persistent label showing the active tool + next step, docked to the top
   of the chart next to the toolbar -- previously the only feedback that a
   tool was selected was a subtle highlight on its icon. */
.charting-status-label {
  position: absolute;
  top: 8px;
  left: 74px;
  z-index: 3;
  display: none;
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.chart-type-toggle { display: flex; gap: 4px; }

/* Charting tools (§9.4) */
.charting-indicator-bar { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.charting-indicator-bar label { display: flex; gap: 4px; align-items: center; font-weight: 400; color: var(--text-dim); }

/* Mobile / tablet responsiveness (§ PWA pass) — the nav already collapses
   under 900px above; this block handles phone-width layout for content
   that would otherwise overflow or crowd: tables, the chat two-column
   layout, the auth card, chart height, and the drawing toolbar. */
@media (max-width: 640px) {
  .content { padding: 12px; }
  .chart-container { height: 360px; }

  /* Tables scroll horizontally as a unit rather than squeezing columns
     unreadably thin -- internal thead/tbody/tr/td keep their table display
     values even though the <table> itself becomes a block scroll container. */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  th, td { padding: 6px 8px; font-size: 13px; }

  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }

  .chat-layout { flex-direction: column; }
  .chat-sidebar { width: 100%; min-width: 0; }
  .message-list { max-height: 320px; }
  .video-tiles video { width: 100%; max-width: 280px; }

  .auth-card { width: 100%; max-width: 360px; padding: 0 12px; }

  .charting-toolbar { padding: 3px; gap: 1px; }
  .drawing-tool-btn { min-width: 44px; height: 24px; font-size: 10px; padding: 0 4px; }
  .charting-status-label { left: 60px; font-size: 11px; padding: 4px 8px; }

  .flex, .flex-between { flex-wrap: wrap; row-gap: 8px; }
}

@media (max-width: 420px) {
  .chart-container { height: 300px; }
  .topnav .brand { font-size: 14px; }
  .nav-link { padding: 6px 8px; font-size: 13px; }
}

/* Trading Desk workspace (#/workspace) — chart is the dominant element,
   everything else (tabs + panel) is a compact strip underneath so the
   whole page fits in roughly one viewport instead of scrolling for ages.
   `.content`'s own 20px top+bottom padding is accounted for in the calc. */
.workspace-shell { display: flex; flex-direction: column; height: calc(100vh - 40px); min-height: 480px; }
.workspace-main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.workspace-topbar { flex: 0 0 auto; }
.workspace-chart-card {
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  margin: 8px 0;
}
.workspace-chart { flex: 1 1 auto; min-height: 0; width: 100%; }
/* flex:1 so the panel directly trades space with the chart above it as the
   resize handle is dragged -- growing the chart shrinks this by the exact
   same amount (down to workspace-panel's min-height, where it scrolls
   internally instead of shrinking further), instead of the chart being
   capped by a guessed reserve. */
.workspace-side { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.workspace-resize-handle {
  flex: 0 0 auto;
  height: 12px;
  margin: 2px 0;
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.workspace-resize-handle::before {
  content: "";
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.workspace-resize-handle:hover::before, .workspace-resize-handle.dragging::before { background: var(--accent); }
.workspace-shell.view-side .workspace-resize-handle { display: none; }
.workspace-tabs { flex: 0 0 auto; gap: 6px; }
.workspace-panel {
  flex: 1 1 auto;
  min-height: 60px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 6px;
}
.workspace-panel .card-title { font-size: 11px; margin-bottom: 6px; }
.workspace-panel input, .workspace-panel select { padding: 5px 8px; font-size: 13px; }
.workspace-panel label { margin-top: 6px; margin-bottom: 2px; }

/* View-mode variants, switchable from the page itself and remembered via
   localStorage. "Fit" (default) clamps everything to one viewport. */
.workspace-shell.view-comfortable { height: auto; min-height: 0; }
.workspace-shell.view-comfortable .workspace-chart-card { min-height: 460px; }
.workspace-shell.view-comfortable .workspace-panel { max-height: 50vh; font-size: 14px; }

.workspace-shell.view-side { flex-direction: row; }
.workspace-shell.view-side .workspace-side { flex: 0 0 340px; margin-left: 12px; }
.workspace-shell.view-side .workspace-panel { flex: 1 1 auto; max-height: none; }
.workspace-shell.view-side .workspace-tabs { flex-direction: column; }

@media (max-width: 900px) {
  .workspace-shell, .workspace-shell.view-side { height: auto; min-height: 0; flex-direction: column; }
  .workspace-chart-card { min-height: 320px; }
  .workspace-panel, .workspace-shell.view-side .workspace-panel { max-height: none; }
  .workspace-shell.view-side .workspace-side { flex: 0 0 auto; margin-left: 0; }
  .workspace-shell.view-side .workspace-tabs { flex-direction: row; }
}
