:root {
  color-scheme: dark;
  --bg: #050507;
  --card: rgba(16, 15, 19, 0.88);
  --card-solid: #100f13;
  --card-2: rgba(24, 22, 27, 0.94);
  --border: rgba(232, 184, 116, 0.16);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #F4EFEA;
  --muted: #9D958D;
  --amber: #E59952;
  --gold: #F2CA85;
  --emerald: #1ED68A;
  --gain: #6FE0A8;
  --loss: #FF6F6F;
  font: 14px "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
html { touch-action: pan-x pan-y; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(50% 42% at 24% -5%, rgba(229, 153, 82, 0.14), transparent 70%),
    radial-gradient(40% 35% at 85% 0%, rgba(139, 38, 53, 0.15), transparent 72%),
    radial-gradient(45% 30% at 50% 105%, rgba(30, 214, 138, 0.07), transparent 70%);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
a { color: inherit; }

header, main { position: relative; z-index: 1; padding: 0 12px; }
header, .heading, .tools, nav, .topbar, .list-controls, #pen { display: flex; align-items: center; gap: 10px; }

/* Header Card */
header {
  height: 50px;
  margin: 8px 12px 0;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(242, 202, 133, 0.12), 0 10px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
}
.brand-avatar {
  display: block; width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover;
}
header strong { font-weight: 500; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
header span, small, label, .tools { color: var(--muted); }
.info { text-decoration: none; color: var(--muted); font-size: 14px; opacity: 0.8; }
.info:hover { color: var(--gold); opacity: 1; }
#header-controls { display: flex; align-items: center; gap: 5px; margin-left: auto; }
#header-controls button { flex: none; width: 34px; height: 34px; padding: 0; font-size: 17px; line-height: 1; }
header:has(#terminal-pages[hidden]) #invert-price,
header:has(#calendar-tab[aria-current]) #invert-price { display: none; }
output#status {
  font-size: 12px; padding: 4px 10px; border-radius: 99px;
  background: rgba(229, 153, 82, 0.1); border: 1px solid var(--border); color: var(--gold);
}
output#status[data-state=live] {
  background: rgba(30, 214, 138, 0.1); border-color: rgba(30, 214, 138, 0.28); color: var(--gain);
}

/* Login */
#login {
  position: relative; z-index: 1; max-width: 440px; margin: 12vh auto; padding: 28px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(242, 202, 133, 0.14), 0 20px 50px rgba(0, 0, 0, 0.65);
}
#login h1 { margin-top: 0; font-weight: 500; letter-spacing: 0.03em; }
#login p { line-height: 1.5; color: var(--muted); }
#login-code { font: 600 2rem var(--mono, monospace); letter-spacing: .18em; margin: 1rem 0; color: var(--gold); }
#confirm { display: inline-block; margin: 4px 14px 12px 0; color: var(--emerald); }

/* Buttons */
button {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 6px 11px; cursor: pointer; transition: all .15s ease;
}
button:hover { background: rgba(229, 153, 82, 0.12); border-color: var(--border); color: var(--gold); }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed=true] {
  background: linear-gradient(135deg, rgba(229, 153, 82, 0.22), rgba(139, 38, 53, 0.24));
  color: var(--gold); border-color: rgba(242, 202, 133, 0.45);
}

/* Topbar */
main { padding: 8px 12px 10px; }
.topbar {
  min-height: 46px; flex-wrap: wrap; gap: 7px; padding: 6px 12px; margin-bottom: 8px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  box-shadow: inset 0 1px 0 rgba(242, 202, 133, 0.1);
  font-size: 13px;
}
.topbar nav { margin: 0; }
.topbar button { padding: 5px 10px; font-size: 12.5px; }
#chart-actions { display: flex; gap: inherit; }
#frame-toggle, #actions-toggle, #mobile-indicators { display: none; }
.chevron {
  display: inline-block; width: 7px; height: 7px; margin-left: 4px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}
[aria-expanded=true] > .chevron { transform: translateY(2px) rotate(225deg); }
#ticker { font-weight: 600; font-size: 13.5px; border-color: var(--border); color: var(--gold); }
#watch-toggle { margin-left: auto; }
#frames {
  background: rgba(5, 5, 7, 0.7); border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 3px; gap: 2px;
}
#frames button { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 8px; border-radius: 6px; font-size: 12px; }
#frames button:hover { color: var(--text); }
#frames button[aria-pressed=true] { background: rgba(229, 153, 82, 0.2); color: var(--gold); border-color: rgba(242, 202, 133, 0.35); font-weight: 600; }

/* Popups & Settings */
.picker { position: relative; }
.popup, #pen {
  border: 1px solid var(--border); background: rgba(18, 16, 21, 0.96);
  backdrop-filter: blur(18px); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.8); border-radius: 12px;
}
.popup { position: absolute; z-index: 24; top: calc(100% + 7px); left: 0; width: min(320px, 88vw); padding: 10px; font-size: 13px; }
.popup input[type=search], #list-name, #watch-search {
  width: 100%; padding: 7px 10px; background: rgba(5, 5, 7, 0.8);
  border: 1px solid var(--border-soft); border-radius: 8px; color: var(--text); outline: none;
}
.popup input[type=search]:focus, #list-name:focus, #watch-search:focus { border-color: var(--gold); }
#results { max-height: min(285px, 40dvh); overflow: auto; overscroll-behavior: contain; margin-top: 6px; }
#results small { padding: 6px; color: var(--muted); }
#results button, #favorites button {
  display: flex; width: 100%; border: 0; border-radius: 7px; text-align: left; font-size: 13px;
  align-items: baseline; gap: 9px; background: transparent; color: var(--text); padding: 7px 8px;
}
#results button:hover, #favorites button:hover, #favorites button[aria-current=true] {
  background: rgba(229, 153, 82, 0.14); color: var(--gold);
}
#results span, #favorites span { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.settings { width: 270px; max-height: 68dvh; overflow: auto; }
.ind-section {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--gold); margin: 10px 0 4px; padding: 0 4px;
}
.ind-section:first-child { margin-top: 2px; }
.settings label {
  display: flex; align-items: center; gap: 8px; padding: 5px 4px;
  color: var(--text); border-bottom: 1px solid rgba(255, 255, 255, 0.04); cursor: pointer;
}
.settings input[type=checkbox] { accent-color: var(--emerald); }
#ema-indicator { border-bottom: 1px solid var(--border-soft); }
#ema-indicator summary { padding: 7px 4px; cursor: pointer; }
.ema-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 30px; gap: 7px; align-items: center; font-size: 12px; }
.settings .ema-row label { min-height: 32px; border-bottom: 0; }
.ema-row input[type=number] {
  width: 64px; min-height: 30px; padding: 3px 5px; background: var(--card);
  border: 1px solid var(--border-soft); border-radius: 6px; color: var(--text);
}
.ema-row input[type=color], #ink { width: 28px; height: 22px; padding: 0; border: 0; background: transparent; cursor: pointer; }
#ema-settings { padding: 0 4px 6px 12px; }
.channel-settings { grid-template-columns: minmax(0, 1fr) 64px; padding: 0 4px 5px 12px; }
.channel-settings[hidden] { display: none; }

/* Main Bento Desk */
.desk { display: flex; align-items: stretch; gap: 10px; }
.workspace {
  flex: 1; min-width: 0; border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  box-shadow: inset 0 1px 0 rgba(242, 202, 133, 0.12), 0 16px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.heading {
  justify-content: space-between; padding: 8px 14px; margin: 0; gap: 8px;
  border-bottom: 1px solid var(--border-soft); background: rgba(10, 9, 12, 0.65);
}
.heading > div:first-child { min-width: 0; }
.heading b { font-size: 15px; font-weight: 600; }
#frame-label { color: var(--gold); font-variant-numeric: tabular-nums; margin-left: 6px; font-size: 13px; }
.heading small { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.quote { text-align: right; font-variant-numeric: tabular-nums; max-width: 55%; }
.quote strong { font-size: 18px; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

#plot { position: relative; flex: 1; }
#chart-page:not(.tradingview-mode) #plot { touch-action: none; }
#tradingview-chart { display: block; width: 100%; height: max(290px, calc(100dvh - 210px)); border: 0; }
.tradingview-mode #plot > :not(#tradingview-chart),
.tradingview-mode #drawing-widget,
.tradingview-mode #indicator-picker,
.tradingview-mode .actions-picker,
.tradingview-mode #alerts-toggle,
.tradingview-mode .quote,
.tradingview-mode #mobile-indicators,
.tradingview-mode #chartprime-status,
.tradingview-mode #study-status,
.tradingview-mode #mxwll-status { display: none; }
#chart { height: max(290px, calc(100dvh - 210px)); border: 0; border-radius: 0; position: relative; z-index: 0; }
#overlay { position: absolute; left: 0; top: 0; overflow: hidden; pointer-events: none; z-index: 1; }
#overlay.active { pointer-events: auto; touch-action: none; cursor: crosshair; }
#overlay [data-item] { touch-action: none; cursor: move; }
#legend {
  position: absolute; pointer-events: none; left: 10px; top: 8px; z-index: 2;
  display: flex; gap: 10px; flex-wrap: wrap; max-width: 84%; font-size: 11.5px;
  padding: 4px 9px; border-radius: 8px; background: rgba(12, 11, 15, 0.72);
  backdrop-filter: blur(6px); border: 1px solid var(--border-soft);
}
#pen { position: absolute; top: 38px; left: 10px; padding: 5px 7px; font-size: 12px; z-index: 4; }
#pen select, .list-controls select {
  background: rgba(5, 5, 7, 0.85); color: var(--text); border: 1px solid var(--border-soft);
  border-radius: 7px; font-size: 12px; margin: 0; padding: 4px 6px; min-width: 0;
}
#pen button { padding: 4px 8px; font-size: 12px; }

#chart-message {
  pointer-events: none; position: absolute; z-index: 3; top: 44%; left: 50%;
  transform: translateX(-50%); text-align: center;
  background: rgba(18, 16, 21, 0.92); border: 1px solid var(--border); padding: 9px 14px; border-radius: 10px;
}

#mxwll-session {
  position: absolute; z-index: 3; top: 10px; right: 85px; margin: 0;
  display: grid; grid-template-columns: auto auto; gap: 2px 9px;
  padding: 6px 8px; max-width: calc(100% - 96px); border: 1px solid var(--border-soft);
  border-radius: 6px; background: var(--card); color: var(--text); font-size: 10px;
  pointer-events: none;
}
#mxwll-session[hidden] { display: none; }
#mxwll-session dt { color: var(--muted); }
#mxwll-session dd { margin: 0; text-align: right; }
#volume-delta-status, #macd-status, #study-status, #mxwll-status, #hint { padding: 0 14px 4px; font-size: 11.5px; }
#volume-delta-status:empty, #macd-status:empty, #study-status:empty, #mxwll-status:empty, #hint:empty { display: none; }

/* Right Watchlist Card */
#watch {
  width: min(252px, 78vw); padding: 12px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card);
  box-shadow: inset 0 1px 0 rgba(242, 202, 133, 0.1);
  font-size: 13px; display: flex; flex-direction: column;
}
#watch button { font-size: 12px; }
.list-controls { margin: 8px 0; gap: 5px; }
.list-controls select { flex: 1; }
#list { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
#list button { white-space: nowrap; max-width: 155px; overflow: hidden; text-overflow: ellipsis; padding: 4px 8px; font-size: 11.5px; }
#new-list { padding: 4px 9px; color: var(--gold); border-color: var(--border); }
#list-form { display: flex; gap: 5px; margin-bottom: 8px; }
#list-form button { padding: 5px 9px; background: linear-gradient(135deg, var(--gold), var(--amber)); color: #050507; font-weight: 600; }
#watch-matches {
  padding: 4px; max-height: min(248px, 40dvh); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.watch-match { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding-left: 6px; }
.watch-match > div { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.watch-match small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11.5px; }
#watch-matches button { min-width: 38px; min-height: 38px; padding: 4px; border-color: transparent; background: transparent; color: var(--muted); font-size: 20px; }
#watch-matches button[aria-disabled=true], #watch-matches button:hover { color: var(--gold); }
#favorites { margin-top: 8px; min-height: 0; max-height: 60dvh; overflow: auto; }
#favorites button { flex-wrap: wrap; gap: 2px; padding: 7px 6px; }
#favorites span { width: 100%; }
.watch-row { position: relative; display: flex; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
#favorites .watch-row [data-symbol] { min-width: 0; flex: 1; }
#favorites .watch-row button:last-child { width: auto; font-size: 16px; padding: 5px 7px; color: var(--muted); }
#favorites .watch-grip { width: 32px; min-height: 40px; flex: none; justify-content: center; cursor: grab; touch-action: none; }
#favorites .watch-grip:active { cursor: grabbing; }
.watch-grip::before {
  content: ""; width: 12px; height: 18px; color: var(--muted);
  background: radial-gradient(circle, currentColor 1px, transparent 1.5px) 0 0 / 6px 6px;
}
.watch-dragging { opacity: .5; }
.watch-row[data-drop]::after { content: ""; position: absolute; inset-inline: 0; height: 2px; background: var(--gold); pointer-events: none; }
.watch-row[data-drop=before]::after { top: 0; }
.watch-row[data-drop=after]::after { bottom: 0; }

.chart-attribution { padding: 0 14px 3px; font-size: 10px; color: var(--muted); }

@media (max-width: 760px) {
  .chart-attribution { display: none; }
  body:has(main:not([hidden])) {
    height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    display: flex; flex-direction: column;
  }
  header { height: 36px; flex: none; margin: 0; padding: 0 10px; gap: 8px; border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  header strong { font-size: 12px; }
  header .brand-avatar { width: 28px; height: 28px; }
  header .brand-avatar + strong + span { display: none; }
  #header-controls button { width: 30px; height: 32px; }
  output#status { font-size: 10px; padding: 2px 7px; white-space: nowrap; }
  main { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 0; }
  .desk { position: relative; flex: 1; min-height: 0; flex-direction: column; gap: 0; }
  .workspace { order: -1; display: flex; flex-direction: column; min-height: 0; border: 0; border-radius: 0; overflow: visible; box-shadow: none; }
  .heading { position: relative; z-index: 8; padding: 3px 10px; justify-content: start; gap: 8px; }
  .heading .instrument { flex: 1; min-width: 0; }
  #instrument-name { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #frame-label, #market, #barstate { display: none; }
  .tradingview-mode #market { display: block; }
  .quote strong { font-size: 14px; white-space: nowrap; }
  #mobile-indicators { display: flex; align-items: center; gap: 4px; }
  #alerts-toggle { min-height: 44px; padding: 4px 6px; font-size: 11px; }
  #ind-button { min-height: 44px; padding: 4px 8px; font-size: 11px; }
  #ind-panel { left: auto; right: 0; width: min(285px, calc(100vw - 36px)); max-height: min(64dvh, 420px); }
  .settings label { min-height: 37px; }
  #plot { min-height: 0; }
  #chart { position: absolute; inset: 0; height: auto; }
  #tradingview-chart { position: absolute; inset: 0; height: 100%; }
  #legend { top: 5px; left: 6px; max-width: 78%; gap: 4px 7px; padding: 3px 6px; font-size: 10px; }
  #legend:empty, #study-status:empty, #mxwll-status:empty, #hint:empty, #comparison-status:empty { display: none; }
  #watch {
    position: absolute; z-index: 15; right: 6px; bottom: 54px;
    background: var(--panel); box-shadow: var(--shadow);
    max-height: 65dvh; overflow: auto;
  }
  #watch-matches button { min-width: 44px; min-height: 44px; }
  .topbar {
    order: 1; z-index: 16; flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 5px; margin: 0; padding: 4px 6px; border-width: 1px 0 0; border-radius: 0; background: var(--panel); box-shadow: none;
  }
  .topbar button { min-height: 44px; padding: 4px 7px; }
  #ticker { width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
  #watch-toggle { margin: 0; }
  #frame-toggle, #actions-toggle { display: block; }
  .topbar .popup { top: auto; bottom: calc(100% + 6px); }
  #catalog { width: min(340px, calc(100vw - 26px)); }
  #results button { min-height: 44px; }
  #frames, #chart-actions {
    display: none; position: absolute; z-index: 24; bottom: calc(100% + 6px);
    background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--border); border-radius: 10px;
  }
  #frame-toggle[aria-expanded=true] + #frames { display: grid; grid-template-columns: repeat(4, 44px); right: -46px; }
  #actions-toggle[aria-expanded=true] + #chart-actions {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 200px; right: -36px; gap: 4px; padding: 5px;
  }
  #chart-actions > .picker { position: static; }
  #chart-actions > .picker > button { width: 100%; }
  #chart-actions .chart-option-panel { max-height: 53dvh; overflow: auto; }
  .popup input:is([type=search], [type=text], [type=number]) { font-size: 16px; }
  #login { margin-inline: 10px; }
}

#terminal-pages { gap: 12px; margin-left: 8px; min-width: 0; }
#terminal-pages a {
  color: var(--muted); text-decoration: none; display: inline-flex; align-items: center;
  align-self: stretch; padding: 0 3px; min-height: 36px; border-bottom: 2px solid transparent;
}
#terminal-pages a[aria-current], #terminal-pages a:hover { color: var(--text); }
#terminal-pages a[aria-current] { border-bottom-color: var(--gold); }
#terminal-pages a:focus-visible, .calendar-event a:focus-visible { outline: 2px solid var(--gold); }
header:has(#calendar-tab[aria-current]) #status { display: none; }
#calendar-page {
  width: min(100%, 940px); margin-inline: auto; padding: 24px clamp(14px, 3vw, 36px);
  overflow: auto;
}
.calendar-heading { display: flex; flex-wrap: wrap; gap: 12px 30px; align-items: center; justify-content: space-between; }
.calendar-heading h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.calendar-month, .calendar-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.calendar-month h2 { margin: 0; min-width: 112px; text-align: center; font-size: 14px; text-transform: capitalize; }
.calendar-month button, .calendar-filters button { min-height: 40px; }
#calendar-prev, #calendar-next { min-width: 40px; font-size: 22px; line-height: 1; }
.calendar-filters { margin-top: 14px; }
#calendar-status { color: var(--muted); font-size: 12px; margin: 13px 0; line-height: 1.45; }
#calendar-events { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
#calendar-events:empty { border: 0; }
.calendar-event {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) 75px;
  align-items: start; gap: 8px 16px; padding: 12px 4px;
  border-bottom: 1px solid var(--border-soft); line-height: 1.35;
}
.calendar-event .event-date, .calendar-event .event-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.calendar-event .event-time { text-align: right; white-space: nowrap; }
.calendar-event a { display: inline-block; font-weight: 600; text-underline-offset: 3px; text-decoration-color: var(--border); }
.calendar-event a:hover { text-decoration-color: currentColor; }
.calendar-event small { display: block; margin-top: 4px; font-size: 12px; }
.calendar-event[data-source=cbr] a, .calendar-event[data-source=fed] a { color: var(--gold); }
@media (max-width: 760px) {
  #terminal-pages { margin-left: 0; gap: 6px; font-size: 12px; }
  header:has(#terminal-pages:not([hidden])) .brand-avatar + strong { display: none; }
  header:has(#terminal-pages:not([hidden])) { height: 44px; }
  #terminal-pages a { min-height: 44px; padding-inline: 7px; }
  #chart-page { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  #calendar-page { min-height: 0; padding-top: 18px; }
  .calendar-heading h1 { font-size: 24px; }
  .calendar-month button, .calendar-filters button { min-height: 44px; min-width: 44px; }
  .calendar-event { grid-template-columns: 55px minmax(0, 1fr) 37px; gap: 6px; }
}

#reset-chart {
  position: absolute; z-index: 4; left: var(--chart-midpoint, 50%); bottom: 39px; transform: translateX(-50%);
  width: 36px; height: 36px; padding: 0; display: grid; place-items: center;
  font-size: 24px; line-height: 1;
}
#reset-chart:focus-visible { outline: 2px solid var(--gold); }
.calendar-flag {
  display: inline-block; width: 18px; height: 12px; margin-right: 7px;
  vertical-align: -1px; border-radius: 2px; box-shadow: 0 0 0 1px var(--border);
}
.calendar-flag-ru { background: linear-gradient(#fff 33.3%, #1856ac 33.3% 66.6%, #dc303b 66.6%); }
.calendar-flag-us { position: relative; background: repeating-linear-gradient(#ba3540 0 7.7%, #fff 7.7% 15.4%); }
.calendar-flag-us::before { content: ""; position: absolute; inset: 0 55% 46% 0; background: #304780; }
.calendar-stock-icon {
  position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px;
  margin-right: 7px; vertical-align: middle; border-radius: 50%; overflow: hidden;
  background: var(--field); box-shadow: 0 0 0 1px var(--border);
  color: var(--muted); font-size: 8px; font-weight: 700;
}
.calendar-stock-icon img { position: absolute; inset: 0; object-fit: cover; }
.event-metrics { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; font-size: 12px; }
.event-metrics dt { color: var(--muted); }
.event-metrics dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }

/* Quote columns and the movable watchlist. */
#catalog { --catalog-star-width: 44px; width: min(489px, calc(100vw - 26px)); }
.quote-grid {
  --quote-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, .9fr);
  display: grid; grid-template-columns: var(--quote-columns); align-items: center; gap: 4px;
}
.quote-grid > * { min-width: 0; }
.quote-identity { display: flex; align-items: center; gap: 6px; min-width: 0; text-align: left; }
.quote-identity .quote-logo {
  position: relative; display: grid; place-items: center; flex: 0 0 22px; height: 22px;
  overflow: hidden; border-radius: 50%; background: var(--field);
  box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); font-size: 8px; font-weight: 700;
}
.quote-logo img { position: absolute; inset: 0; object-fit: cover; }
.quote-logo img:not(.loaded) { opacity: 0; }
#results .quote-logo { font-size: 8px; }
.quote-grid .quote-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.quote-name > span, .quote-name > small {
  display: block; overflow: hidden; text-overflow: ellipsis; font-weight: normal; color: var(--muted);
}
.quote-grid .quote-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quote-value.quote-dated { text-decoration: underline dotted; text-underline-offset: 3px; }
#results button.quote-grid, #favorites button.quote-grid { display: grid; gap: 4px; }
#catalog-sort { grid-template-columns: var(--quote-columns) var(--catalog-star-width); }
.catalog-row {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--catalog-star-width);
  gap: 4px; align-items: stretch; padding-right: 8px;
}
#results .catalog-row > .quote-grid { padding-right: 0; }
#results .catalog-star { display: grid; place-items: center; min-height: 44px; padding: 0; font-size: 19px; }
#results .catalog-star[aria-pressed="true"] { color: var(--gold); }
#results .catalog-star:focus-visible { outline: 1px solid var(--gold); outline-offset: -2px; }
#results .quote-grid .quote-name, #favorites .quote-grid .quote-name { color: inherit; }
#results .catalog-family summary .quote-name {
  overflow: hidden; text-overflow: ellipsis; color: inherit; font: inherit;
}
:is(#results, #favorites, #watch-matches) .quote-value.quote-gain { color: var(--gain); }
:is(#results, #favorites, #watch-matches) .quote-value.quote-loss { color: var(--loss); }
.quote-sort { margin-top: 6px; padding: 0 8px; }
.quote-sort button, #watch .quote-sort button {
  color: var(--muted); background: transparent; padding: 4px 0; min-height: 26px;
  border: 0; text-align: right; font-size: 10px; white-space: nowrap;
}
.quote-sort button:first-child { text-align: left; }
#watch .quote-sort button[aria-pressed=true], .quote-sort button[aria-pressed=true] { color: var(--gold); }
#watch {
  align-self: flex-start; flex: none; position: relative; width: var(--watch-width, 370px);
  min-height: min(220px, 65dvh); height: var(--watch-height, max(360px, calc(100dvh - 150px)));
  max-height: max(220px, calc(100dvh - 110px)); padding: 10px 12px 14px;
}
#watch-header {
  display: flex; align-items: center; justify-content: space-between;
  height: auto; margin: 0; padding: 0; border: 0; box-shadow: none; background: none;
}
:is(#watch, #drawing-controls) .widget-move {
  min-width: 32px; min-height: 28px; padding: 0 6px; font-size: 19px;
  line-height: 1; color: var(--gold); touch-action: none; cursor: grab;
}
:is(#watch, #drawing-controls) .widget-move:active { cursor: grabbing; }
.widget-dock { min-width: 32px; min-height: 28px; padding: 2px 6px; }
.widget-dock[aria-pressed=true], #alerts-toggle[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
#watch #list-name { min-width: 0; flex: 1; }
#watch .quote-value { overflow: hidden; text-overflow: ellipsis; }
#watch.watch-floating {
  position: fixed; z-index: 30; right: auto; bottom: auto; max-height: calc(100dvh - 12px);
  background: var(--panel); box-shadow: var(--shadow);
}
#watch .watch-resize {
  position: absolute; z-index: 2; border: 0; background: transparent; padding: 0; touch-action: none;
}
#watch-resize-x { width: 14px; left: -7px; top: 12px; bottom: 12px; cursor: ew-resize; }
#watch-resize-y { height: 14px; bottom: -7px; left: 14px; right: 14px; cursor: ns-resize; }
.watch-resize::before { content: ""; display: block; margin: auto; background: var(--muted); opacity: .6; border-radius: 5px; }
.watch-resize:hover::before, .watch-resize:focus-visible::before { background: var(--gold); opacity: 1; }
#watch-resize-x::before { width: 3px; height: 22px; }
#watch-resize-y::before { width: 22px; height: 3px; }
#watch-lookup { position: relative; flex: none; z-index: 3; }
#watch-matches { position: absolute; inset-inline: 0; top: calc(100% + 4px); }
#watch-matches .quote-sort, .watch-match { grid-template-columns: var(--quote-columns) 28px; padding: 0 4px; }
#watch-matches .quote-sort { position: sticky; top: -4px; background: var(--panel); }
#watch-matches .watch-match button { min-width: 0; }
#watch-sort, #favorites button.quote-grid { grid-template-columns: var(--watch-columns, var(--quote-columns)); }
#favorites button.quote-grid { transition-property: background-color, color; }
#watch-sort, #favorites { scrollbar-gutter: stable; }
#watch-sort { position: relative; overflow: hidden; padding-inline: 29px 26px; }
.watch-sort-cell { position: relative; }
#watch-sort [data-quote-sort] {
  display: block; width: 100%; padding-inline: 5px;
  overflow: hidden; text-overflow: ellipsis; text-align: right;
}
#watch-sort .watch-sort-cell:first-child [data-quote-sort] { text-align: left; }
#watch #watch-sort-reset { position: absolute; inset-inline-end: 0; width: 20px; text-align: center; }
#watch #watch-sort .watch-column-resize {
  position: absolute; z-index: 1; inset: 0 -7px 0 auto; width: 10px;
  display: grid; place-items: center; padding: 0; cursor: col-resize; touch-action: none;
}
.watch-column-resize::before { content: ""; width: 1px; height: 14px; background: var(--muted); opacity: .65; }
.watch-column-resize:is(:hover, :focus-visible, .is-resizing)::before { width: 2px; background: var(--gold); opacity: 1; }
#favorites { flex: 1; max-height: none; }
#favorites .watch-grip { width: 23px; }
#favorites .watch-grip:disabled { visibility: hidden; }
#favorites .watch-row button:last-child { flex: 0 0 20px; justify-content: center; padding-inline: 0; }
@media (max-width:760px) {
  #watch { position: absolute; max-height: 65dvh; height: var(--watch-height, 65dvh); overflow: visible; }
  #watch-resize-y { bottom: 0; }
  #watch:not(.watch-floating) #watch-matches { top: calc(100% + 4px); max-height: min(200px, 30dvh); }
}

#chart-fullscreen {
  position: absolute; z-index: 4; right: 52px; top: 10px;
  width: 36px; height: 36px; padding: 0; display: grid; place-items: center;
  font-size: 22px; line-height: 1;
}
#plot:fullscreen, #plot.chart-expanded { width: 100%; height: 100%; background: var(--panel); }
#plot.chart-expanded { position: fixed; inset: 0; z-index: 100; }
#plot:fullscreen #chart, #plot.chart-expanded #chart { position: absolute; inset: 0; height: auto; }
#chartprime-status { padding: 0 14px 4px; font-size: 11.5px; }
#chartprime-status:empty { display: none; }

#chart-watermark {
  position: absolute; inset: 42% 12% auto; text-align: center; pointer-events: none;
  color: var(--muted); opacity: .18; font-weight: 700; font-size: clamp(30px, 6vw, 86px);
  line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#watch-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
#watch-nav button { flex: 1 0 auto; padding: 5px 4px; }
#watch-nav button[aria-pressed=true] { color: var(--gold); border-color: var(--gold); }
.watch-view { flex: 1; min-height: 0; }
#watch-list { display: flex; flex-direction: column; }
#watch-lookup { display: flex; gap: 5px; }
#watch-search { flex: 1; min-width: 0; }
#watch-add { flex: none; min-width: 38px; color: var(--gold); font-size: 18px !important; }
#watch-add-search { width: 100%; position: sticky; top: -4px; z-index: 1; }
#watch-matches .quote-sort { top: 28px; }
#watch-matches button[aria-disabled=true] { cursor: default; }
.watch-detail { overflow: auto; overscroll-behavior: contain; }
.watch-detail h2 { margin: 4px 0; font-size: 18px; }
.watch-detail h3 { margin: 16px 0 6px; font-size: 14px; }
.watch-detail p, .watch-detail small { color: var(--muted); margin: 4px 0; }
#watch-info-quotes { display: grid; grid-template-columns: 1fr auto; gap: 5px; margin: 12px 0; }
#watch-info-quotes dt { color: var(--muted); }
#watch-info-quotes dd { margin: 0; text-align: right; }
#watch-info-quotes .quote-gain { color: var(--gain); }
#watch-info-quotes .quote-loss { color: var(--loss); }
.watch-detail a { display: block; color: var(--text); padding: 7px 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.watch-detail a:hover { color: var(--gold); }
.watch-detail a small { display: block; }
#watch-alerts .alerts-dialog { width: auto; max-height: none; overflow: visible; padding: 4px 0; background: none; border: 0; box-shadow: none; }

.ema-line-settings { grid-template-columns: minmax(0, 1fr) 58px 28px 48px; }
.ema-line-settings input[type=number] { width: 100%; }
.indicator-style { margin: 0 4px 5px 19px; }
.indicator-style summary { padding: 6px 0; color: var(--muted); cursor: pointer; }
.indicator-style-row { grid-template-columns: minmax(0, 1fr) 28px 48px; min-height: 29px; }
.indicator-width { width: 48px; min-height: 26px; padding: 2px; font-size: 11px;
  color: var(--text); background: var(--card); border: 1px solid var(--border-soft); border-radius: 6px; }
.indicator-style button { margin-top: 4px; min-height: 27px; font-size: 11px; }
.settings .macd-setting-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px; }
.macd-setting-row select { width: 100%; min-width: 0; min-height: 30px; padding: 3px 4px;
  color: var(--text); background: var(--card); border: 1px solid var(--border-soft); border-radius: 6px; }
.macd-setting-row input[type=number] { width: 100%; min-width: 0; }

.catalog-family { border-bottom: 1px solid var(--border-soft); }
.catalog-family summary { min-height: 37px; display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; font-weight: 600; cursor: pointer; list-style: none; }
.catalog-family summary::-webkit-details-marker { display: none; }
.catalog-family summary::after { content: "›"; font-size: 19px; }
.catalog-family[open] summary::after { transform: rotate(90deg); }
.catalog-family summary:hover { background: var(--active); }

#tradingview-calendar { display: block; width: 100%; height: max(360px, calc(100dvh - 240px)); border: 0; }
#watch-news-market { display: flex; gap: 4px; margin: 6px 0 4px; }
#watch-news-market button { flex: 1; min-height: 32px; padding: 4px; }
#watch-news-market button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); background: var(--active); }
