/* ==========================================================================
   Features - sign-in screen and the TradingView-style workspace: top toolbar,
   drawing rail, chart with floating legend and bottom bar, watchlist with
   symbol details, widget bar, and dialogs.
   ========================================================================== */

/* ================================================================ branding */

.logo { width: 28px; height: 28px; flex: none; }
.logo-lg { width: 46px; height: 46px; }
.logo-bg { fill: var(--accent); }
.logo-body { fill: var(--accent-fg); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  flex: none;
}

.avatar-lg { width: 38px; height: 38px; font-size: var(--fs-xl); }

/* ============================================================ sign-in screen */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  background: var(--panel-bg);
  overflow: hidden;
}

.auth-panel { position: relative; display: flex; align-items: center; justify-content: center; padding: var(--sp-10) var(--sp-8); overflow-y: auto; }
.auth-theme { position: absolute; top: var(--sp-8); right: var(--sp-8); color: var(--text-3); }

.auth-card {
  width: min(390px, 100%);
  padding: var(--sp-12) var(--sp-10);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2xl);
  background: var(--panel-bg);
  box-shadow: var(--sh-lg);
}

.auth-brand { display: flex; align-items: center; gap: var(--sp-6); }
.auth-brand h1 { font-size: var(--fs-3xl); }
.auth-byline { margin-top: 3px; color: var(--text-3); font-size: var(--fs-sm); }
.auth-lead { margin: var(--sp-9) 0 var(--sp-7); color: var(--text-2); font-size: var(--fs-lg); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.auth-form > label { margin-top: var(--sp-2); }
.auth-form > input { width: 100%; height: 40px; margin-bottom: var(--sp-2); }
.auth-form .btn { height: 40px; margin-top: var(--sp-3); }
.auth-import { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); color: var(--text-2); font-size: var(--fs-sm); cursor: pointer; }
.auth-error { min-height: 18px; color: var(--down); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.auth-foot { margin-top: var(--sp-8); color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-normal); text-align: center; }

.auth-showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--sp-12);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(110% 80% at 85% 5%, rgba(0, 111, 207, 0.5), transparent 60%),
    radial-gradient(80% 60% at 5% 100%, rgba(102, 169, 226, 0.18), transparent 60%),
    #00175a;
}

.auth-showcase::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.6;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 78%);
  pointer-events: none;
}

.auth-showcase > * { position: relative; }
.auth-showcase .eyebrow { color: #99c5ec; letter-spacing: 0.16em; }
.showcase-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); }
.showcase-title { max-width: 22ch; margin-bottom: var(--sp-6); color: #fff; font-size: clamp(28px, 3vw, 42px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.08; }
.showcase-title em { color: #66a9e2; font-style: normal; }
.showcase-lead { max-width: 48ch; color: rgba(204, 209, 222, 0.85); font-size: var(--fs-lg); line-height: var(--lh-normal); }
.showcase-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-9); max-width: 620px; }
.showcase-feature { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-6) var(--sp-7); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--r-lg); background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.86); font-size: var(--fs-sm); }
.showcase-feature svg { width: 17px; height: 17px; color: #66a9e2; }
.showcase-foot { color: rgba(255, 255, 255, 0.5); font-size: var(--fs-xs); }
.showcase-status { display: inline-flex; align-items: center; gap: var(--sp-3); color: #1fb58f; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.showcase-status .dot { background: currentColor; box-shadow: 0 0 8px currentColor; }

.auth-checking .auth-card,
.auth-checking .auth-foot,
.auth-checking .auth-showcase > * { visibility: hidden; }
.auth-pending .app-shell { visibility: hidden; }

/* ================================================================ app shell */

/* Panels sit on the seam colour with a 4px gap between them, as in TradingView. */
.app-shell {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  height: 100%;
  min-height: 0;
  background: var(--app-bg);
}

.panel { background: var(--panel-bg); border-radius: var(--r-sm); }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: relative;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--topbar-h);
  padding: 0 var(--sp-3);
  flex: none;
  background: var(--panel-bg);
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar::-webkit-scrollbar { display: none; }
.topbar > * { flex-shrink: 0; }
.topbar .spacer { flex: 1 1 auto; flex-shrink: 1; }

.topbar .tb-btn { height: 30px; padding: 0 var(--sp-3); border-radius: var(--r-sm); color: var(--text-1); font-size: var(--fs-lg); }
.topbar .tb-btn.icon-only { width: 34px; }
.topbar .tb-btn svg { width: 20px; height: 20px; }
.topbar .tb-btn:hover { background: var(--surface-hover); }
.tb-label { font-size: var(--fs-lg); }

.tb-sep { width: 1px; height: 22px; margin: 0 var(--sp-2); background: var(--border-1); }

.account-btn { padding: 0; }

.symbol-btn { gap: var(--sp-3); min-width: 110px; font-weight: var(--fw-semibold); }
.symbol-btn svg { width: 17px !important; height: 17px !important; color: var(--text-1); }
#symbolName { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }

.tb-intervals { display: inline-flex; align-items: center; gap: 1px; }

.tb-intervals button {
  height: 30px;
  min-width: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-1) var(--ease-std);
}

.tb-intervals button:hover { background: var(--surface-hover); }
.tb-intervals button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-semibold); }

.interval-select { display: none; flex: none; width: 70px; height: 30px; font-weight: var(--fw-semibold); }

.save-btn { gap: var(--sp-2); }
.save-btn svg { width: 18px !important; height: 18px !important; }
.save-btn.saving svg { color: var(--accent-text); animation: pulse-op 1s ease-in-out infinite; }
.save-btn.error { color: var(--down) !important; }

@keyframes pulse-op { 50% { opacity: 0.35; } }

/* ------------------------------------------------------------- account menu */

.menu-head { display: flex; align-items: center; gap: var(--sp-5); padding: var(--sp-4) var(--sp-5) var(--sp-6); }
.menu-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.menu-who b { color: var(--text-1); overflow: hidden; text-overflow: ellipsis; }
.menu-who small { color: var(--text-3); font-size: var(--fs-xs); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5); color: var(--text-2); font-size: var(--fs-md); }

/* ---------------------------------------------------------------- workspace */

.workspace {
  display: flex;
  gap: var(--gap);
  flex: 1 1 auto;
  min-height: 0;
}

/* ------------------------------------------------------------- drawing rail */

.draw-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: var(--rail-w);
  flex: none;
  padding: var(--sp-3) 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.draw-rail::-webkit-scrollbar { display: none; }

/* Each chart has its own rail of drawing tools; only the active chart's is shown. */
.draw-rail > .rail { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.draw-rail > .rail[hidden] { display: none; }

.rail-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 34px;
  flex: none;
  border-radius: var(--r-sm);
  color: var(--text-1);
  transition: background-color var(--dur-1) var(--ease-std), color var(--dur-1) var(--ease-std);
}

.rail-btn:hover { background: var(--surface-hover); }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn.active { background: var(--blue-soft); color: var(--blue); }
.rail-btn.active:hover { background: var(--blue-soft-strong); }

.rail-btn .rail-more {
  position: absolute;
  right: 0;
  bottom: 2px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-bottom: 4px solid currentColor;
  opacity: 0.5;
}

.rail-sep { width: 28px; height: 1px; margin: var(--sp-3) 0; background: var(--border-1); flex: none; }
.rail-flyout .menu-item svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------- chart area */

.chart-area {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* One or two panes; with two, the seam colour shows between them as it does between panels. */
.charts {
  display: grid;
  gap: var(--gap);
  flex: 1 1 auto;
  min-height: 0;
  background: var(--app-bg);
}

.charts[data-layout="1"] { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.charts[data-layout="2v"] { grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr)); }
.charts[data-layout="2h"] { grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1fr); }

.pane { position: relative; min-width: 0; min-height: 0; background: var(--chart-bg); }
.pane[hidden] { display: none; }

/* The active chart (the one the toolbar acts on) is outlined, as in TradingView's multi-chart layouts. */
.charts:not([data-layout="1"]) .pane.active::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  border: 1px solid var(--blue);
  pointer-events: none;
}

.chart-wrap { position: absolute; inset: 0; overflow: hidden; background: var(--chart-bg); }
.chart { position: absolute; inset: 0; overflow: hidden; }

.chart-msg {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
  color: var(--text-3);
  font-size: var(--fs-lg);
  text-align: center;
  pointer-events: none;
}

.chart-msg.error { color: var(--down); }

/* "Scroll to the most recent bar": floats in the plot's bottom-right corner (ChartView sets right/bottom). */
.to-live {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  background: var(--panel-bg);
  color: var(--text-1);
  box-shadow: var(--sh-md);
  cursor: pointer;
}
.to-live:hover { background: var(--surface-hover); }
.to-live svg { width: 16px; height: 16px; }

/* Fullscreen: the chart area (chart + bottom bar) fills the screen. */
.chart-area:fullscreen { border-radius: 0; }

/* ------------------------------------------------------------------- legend */

/* Floating over the chart's top-left corner, TradingView-style: no box, just text on the canvas. */
.legend {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-4);
  z-index: 4;
  max-width: calc(100% - 120px);
  color: var(--text-1);
  font-size: var(--fs-md);
  pointer-events: none;
}

.lg-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--sp-5); }
.lg-head { display: inline-flex; align-items: baseline; gap: var(--sp-4); }
.lg-title { color: var(--text-1); font-family: var(--font-display); font-size: var(--fs-xl); font-weight: var(--fw-regular); white-space: nowrap; }
.lg-note { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }

.lg-ohlc { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-4); color: var(--text-1); font-size: var(--fs-md); }
.lg-ohlc span { white-space: nowrap; }
.lg-ohlc b, .lg-vals b { font-family: var(--font-num); font-size: var(--fs-md); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums; }
.lg-ohlc .up b, .lg-ohlc .lg-chg.up { color: var(--up); }
.lg-ohlc .down b, .lg-ohlc .lg-chg.down { color: var(--down); }
.lg-chg { font-variant-numeric: tabular-nums; }

.lg-inds { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin-top: var(--sp-2); }

.lg-ind {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  max-width: 100%;
  min-height: 24px;
  padding: 0 var(--sp-2) 0 var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-1);
  white-space: nowrap;
  pointer-events: auto;
}

.lg-ind:hover { border-color: var(--border-1); background: var(--panel-bg); }
.lg-ind:hover .lg-actions, .lg-ind:hover .lg-style-btn { opacity: 1; }
.lg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.lg-ind.hidden-ind .lg-name, .lg-ind.hidden-ind .lg-vals { opacity: 0.4; }
.lg-vals { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Show / settings / remove / style appear on hover like TradingView, and stay reachable by keyboard. */
.lg-actions, .lg-style-btn { display: inline-flex; gap: 1px; opacity: 0; transition: opacity var(--dur-1) var(--ease-std); }
.lg-ind:hover .lg-actions, .lg-ind:focus-within .lg-actions, .lg-ind:hover .lg-style-btn, .lg-ind:focus-within .lg-style-btn { opacity: 1; }

.lg-actions button, .lg-style-btn {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  color: var(--text-2);
}

.lg-actions button:hover { background: var(--surface-hover); color: var(--text-1); }
.lg-actions svg { width: 16px; height: 16px; }

.lg-toggle {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 18px;
  margin-top: var(--sp-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  background: var(--panel-bg);
  color: var(--text-2);
  pointer-events: auto;
}

.lg-toggle:hover { color: var(--text-1); border-color: var(--border-2); }
.lg-toggle svg { width: 14px; height: 14px; }
.lg-toggle span { display: none; }
.legend.collapsed .lg-inds { display: none; }

/* Floating toolbar for the selected drawing. */
.drawing-bar {
  position: absolute;
  top: var(--sp-5);
  left: 50%;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  background: var(--panel-bg);
  box-shadow: var(--sh-md);
  transform: translateX(-50%);
}

.drawing-bar .db-title { padding: 0 var(--sp-4) 0 var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.drawing-bar .db-sep { width: 1px; height: 20px; margin: 0 var(--sp-2); background: var(--border-1); }
.drawing-bar .icon-btn { width: 30px; height: 30px; color: var(--text-1); }
.drawing-bar .icon-btn.on { background: var(--blue-soft); color: var(--blue); }

.swatch { width: 20px; height: 20px; margin: 0 1px; border: 2px solid var(--panel-bg); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-2); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.width-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-sm); color: var(--text-1); }
.width-btn:hover { background: var(--surface-hover); }
.width-btn.on { background: var(--blue-soft); color: var(--blue); }
.width-btn i { display: block; width: 16px; background: currentColor; border-radius: 2px; }

/* Floating style panel for indicators (TradingView-style). */
.ind-style-panel {
  position: absolute;
  top: calc(100% + var(--sp-3));
  left: 50%;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  background: var(--panel-bg);
  box-shadow: var(--sh-md);
  transform: translateX(-50%);
  white-space: nowrap;
}
.ind-style-panel .isp-title { padding: 0 var(--sp-4) 0 var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.ind-style-panel .isp-sep { width: 1px; height: 20px; margin: 0 var(--sp-2); background: var(--border-1); }
.ind-style-panel .isp-group { display: flex; align-items: center; gap: 1px; }
.ind-style-panel .icon-btn { width: 30px; height: 30px; color: var(--text-1); }
.ind-style-panel .icon-btn.on { background: var(--blue-soft); color: var(--blue); }
.ind-style-panel .swatch { width: 20px; height: 20px; margin: 0 1px; border: 2px solid var(--panel-bg); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-2); cursor: pointer; }
.ind-style-panel .swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.ind-style-panel .width-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-sm); color: var(--text-1); }
.ind-style-panel .width-btn:hover { background: var(--surface-hover); }
.ind-style-panel .width-btn.on { background: var(--blue-soft); color: var(--blue); }
.ind-style-panel .width-btn i { display: block; width: 16px; background: currentColor; border-radius: 2px; }

.text-editor {
  position: absolute;
  z-index: var(--z-overlay);
  min-width: 160px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--panel-bg);
  box-shadow: var(--sh-md);
  color: var(--text-1);
  font-size: var(--fs-lg);
  outline: none;
}

/* --------------------------------------------------------------- bottom bar */

.bottom-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--bottom-h);
  padding: 0 var(--sp-3);
  flex: none;
  border-top: 1px solid var(--border-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.bottom-bar::-webkit-scrollbar { display: none; }
.bottom-bar > * { flex-shrink: 0; }
.ranges { display: inline-flex; gap: 1px; }

.ranges button,
.bb-btn {
  display: inline-grid;
  place-items: center;
  height: 26px;
  min-width: 28px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-md);
  transition: background-color var(--dur-1) var(--ease-std);
}

.ranges button:hover, .bb-btn:hover { background: var(--surface-hover); }
.ranges button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-semibold); }
.bb-btn.active { background: var(--accent-soft); color: var(--accent-text); font-weight: var(--fw-semibold); }
.bb-btn.icon-only { width: 28px; padding: 0; }
.bb-btn svg { width: 18px; height: 18px; }
.bb-sep { width: 1px; height: 18px; margin: 0 var(--sp-3); background: var(--border-1); }

.clock { color: var(--text-1); font-size: var(--fs-md); font-variant-numeric: tabular-nums; white-space: nowrap; }

.feed-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: default;
}

.feed-status .dot { width: 7px; height: 7px; background: var(--text-3); }
.feed-status.ok { color: var(--up); }
.feed-status.ok .dot { background: var(--up); }
.feed-status.demo, .feed-status.warn { color: var(--warn); }
.feed-status.demo .dot, .feed-status.warn .dot { background: var(--warn); }
.feed-status.err { color: var(--down); }
.feed-status.err .dot { background: var(--down); }

/* ------------------------------------------------------- watchlist + details */

.right-panel {
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  flex: none;
  min-height: 0;
  overflow: hidden;
  --wl-price: 76px;
  --wl-caret: 10px;
  --wl-chg: 64px;
  --wl-pad: var(--sp-5);
  --wl-gap: var(--sp-3);
}

body.wl-hidden .right-panel { display: none; }

.wl-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 44px;
  flex: none;
  padding: 0 var(--sp-3) 0 var(--sp-6);
}

.wl-title { color: var(--text-1); font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.wl-sub { color: var(--text-3); font-size: var(--fs-xs); }
.wl-head .tb-btn { color: var(--text-1); }

.wl-cols,
.wl-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--wl-price) var(--wl-caret) var(--wl-chg);
  align-items: center;
  gap: var(--wl-gap);
  padding: 0 var(--wl-pad);
}

.wl-cols {
  height: 26px;
  flex: none;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.wl-cols span:nth-child(1) { grid-column: 1; }
.wl-cols span:nth-child(2) { grid-column: 2; text-align: right; }
.wl-cols span:nth-child(3) { grid-column: 4; text-align: right; white-space: nowrap; }

.wl-list { position: relative; flex: 1 1 auto; min-height: 60px; overflow-y: auto; overflow-x: hidden; }

.wl-item {
  position: relative;
  height: 34px;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-std);
}

.wl-item:hover { background: var(--surface-hover); }
.wl-item.active { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--accent); }

.wl-sym { grid-area: 1 / 1 / 2 / 2; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.wl-sym-text { display: flex; align-items: baseline; gap: var(--sp-3); min-width: 0; overflow: hidden; }
.wl-sym .name { overflow: hidden; color: var(--text-1); font-size: var(--fs-md); font-weight: var(--fw-semibold); text-overflow: ellipsis; white-space: nowrap; }
.wl-sym .ex { display: none; }

.wl-grip { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 10px; height: 20px; margin-left: -6px; color: var(--text-3); opacity: 0; cursor: grab; touch-action: none; }
.wl-grip svg { width: 10px; height: 10px; }
.wl-item:hover .wl-grip { opacity: 1; }
.wl-grip:active { cursor: grabbing; }

.wl-item.wl-dragging {
  position: absolute;
  left: 0;
  right: 0;
  z-index: var(--z-menu);
  display: grid;
  background: var(--panel-bg);
  box-shadow: var(--sh-lg);
  pointer-events: none;
}

.wl-placeholder { background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--accent-border); }

.wl-item .ltp { grid-area: 1 / 2 / 2 / 3; }
.wl-tick { grid-area: 1 / 3 / 2 / 4; }
.wl-item .chg { grid-area: 1 / 4 / 2 / 5; }

.wl-item .ltp,
.wl-item .chg {
  justify-self: end;
  color: var(--text-1);
  font-family: var(--font-num);
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
}

.wl-item .chg { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.wl-item .chg-pts { font-size: var(--fs-sm); }
.wl-item .chg-pct { font-size: var(--fs-xs); }
.wl-item .chg.up { color: var(--up); }
.wl-item .chg.down { color: var(--down); }
.wl-tick { justify-self: center; font-size: 8px; color: transparent; pointer-events: none; }
.wl-tick.up { color: var(--up); }
.wl-tick.down { color: var(--down); }

.wl-del {
  position: absolute;
  right: 2px;
  top: 50%;
  display: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  background: var(--panel-bg);
  color: var(--text-2);
  transform: translateY(-50%);
  z-index: 2;
}

.wl-del svg { width: 12px; height: 12px; }
.wl-item:hover .wl-del { display: grid; }
.wl-del:hover { color: var(--down); }
.wl-empty .empty-state { padding: var(--sp-8); }

/* Symbol details under the watchlist, like TradingView's details widget. */
.details {
  flex: none;
  padding: var(--sp-6) var(--sp-6) var(--sp-7);
  border-top: 1px solid var(--border-1);
}

.dt-head { display: flex; align-items: center; gap: var(--sp-5); }

.dt-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

.dt-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.dt-names b { overflow: hidden; color: var(--text-1); font-size: var(--fs-lg); text-overflow: ellipsis; white-space: nowrap; }
.dt-names span { overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }

.dt-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-6); }
.dt-ltp { color: var(--text-1); font-size: 22.5px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dt-ccy { color: var(--text-3); font-size: var(--fs-xs); }
.dt-chg { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.dt-price.up .dt-chg { color: var(--up); }
.dt-price.down .dt-chg { color: var(--down); }

.dt-session { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); color: var(--text-3); font-size: var(--fs-sm); }
.dt-session .dot { width: 7px; height: 7px; }
.dt-session.open { color: var(--up); }
.dt-session.open .dot { background: var(--up); }
.dt-session.pre .dot { background: var(--warn); }

.dt-range { margin-top: var(--sp-7); }
.dt-range-labels { display: flex; justify-content: space-between; margin-bottom: var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.dt-range-labels span:first-child, .dt-range-labels span:last-child { color: var(--text-1); }

.range-bar { position: relative; display: block; height: 4px; border-radius: var(--r-pill); background: var(--surface-3); }
.range-bar i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--border-strong); }

.range-bar b {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid var(--panel-bg);
  border-radius: 50%;
  background: var(--text-1);
  transform: translate(-50%, -50%);
  transition: left var(--dur-3) var(--ease-std);
}

.dt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); margin: var(--sp-7) 0 0; }
.dt-stats div { min-width: 0; }
.dt-stats dt { color: var(--text-3); font-size: var(--fs-xs); }
.dt-stats dd { margin: 2px 0 0; overflow: hidden; color: var(--text-1); font-size: var(--fs-md); font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }

/* Watchlist toggle in the top bar, highlighted while the panel is open. */
.topbar #wlToggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

/* ---------------------------------------------------------------- dialogs */

.dlg {
  width: min(560px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 64px));
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--panel-bg);
  color: var(--text-1);
  box-shadow: var(--sh-xl);
  overflow: hidden;
}

.dlg[open] { display: flex; flex-direction: column; animation: dlg-in var(--dur-2) var(--ease-out); }

@keyframes dlg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.dlg::backdrop { background: var(--overlay-scrim); }
.dlg form { display: flex; flex-direction: column; min-height: 0; }

.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-6); flex: none; padding: var(--sp-8) var(--sp-5) var(--sp-6) var(--sp-9); }
.dlg-head-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dlg-title { color: var(--text-1); font-family: var(--font-display); font-size: 17.5px; font-weight: var(--fw-semibold); }
.dlg-sub { color: var(--text-3); font-size: var(--fs-sm); }
.dlg-close { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--r-sm); color: var(--text-2); }
.dlg-close:hover { background: var(--surface-hover); color: var(--text-1); }
.dlg-close svg { width: 18px; height: 18px; }

.dlg-msg { padding: var(--sp-6) var(--sp-9); color: var(--text-3); font-size: var(--fs-sm); text-align: center; }
.dlg-msg:empty { display: none; }
.dlg-msg[role="alert"]:not(:empty) { color: var(--down); }

.dlg-foot { display: flex; align-items: center; gap: var(--sp-4); flex: none; padding: var(--sp-6) var(--sp-9); border-top: 1px solid var(--divider); }

.search-dlg { width: min(720px, calc(100vw - 32px)); height: min(620px, calc(100vh - 64px)); }
.search-dlg .search-box,
.ind-dlg .search-box { margin: 0 var(--sp-9) var(--sp-4); border-width: 0 0 1px; border-radius: 0; padding: 0; box-shadow: none !important; }
.search-dlg .search-box input,
.ind-dlg .search-box input { height: 40px; font-size: var(--fs-xl); text-transform: none; }
.search-dlg .search-box input { text-transform: uppercase; }
.search-dlg .search-box input::placeholder { text-transform: none; }
.search-dlg .tabs, .ind-dlg .tabs { padding: 0 var(--sp-9); border-bottom: 0; }

.tabs button { border-radius: var(--r-pill); padding: var(--sp-2) var(--sp-6); }
.tabs button.active { background: var(--blue); color: var(--blue-fg); }
.tabs button.active::after { display: none; }

.results { flex: 1 1 auto; min-height: 0; padding: var(--sp-4) 0; overflow-y: auto; }

.results li {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  min-height: 42px;
  padding: var(--sp-3) var(--sp-9);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.results li:hover,
.results li.sel { background: var(--blue-soft); }
.results li.r-group { min-height: 0; padding: var(--sp-5) var(--sp-9) var(--sp-2); border: 0; color: var(--text-3); font-size: var(--fs-xs); cursor: default; }
.results li.r-group:hover { background: none; }

.r-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-size: var(--fs-2xs); font-weight: var(--fw-bold); }
.r-icon svg { width: 15px; height: 15px; }
.r-icon.plain { background: var(--surface-3); color: var(--text-2); }
.results .r-sym { min-width: 90px; overflow: hidden; color: var(--text-1); font-size: var(--fs-md); font-weight: var(--fw-semibold); text-overflow: ellipsis; white-space: nowrap; }
.results .r-name { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--text-2); font-size: var(--fs-md); text-overflow: ellipsis; white-space: nowrap; }
.results .r-tag { flex: none; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.results .r-add { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: var(--r-sm); color: var(--text-3); }
.results .r-add:hover { background: var(--surface-active); color: var(--text-1); }
.results .r-add.in { color: var(--green); }
.results .r-add svg { width: 16px; height: 16px; }
.results li:not(:hover):not(.sel) .r-add[data-script-action] { opacity: 0.5; }
.results li[data-script-id] .r-sym { flex: 1 1 auto; }
.results li[data-script-id] .r-name { display: none; }

.fields {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: var(--sp-5) var(--sp-8);
  padding: var(--sp-2) var(--sp-9) var(--sp-8);
  overflow-y: auto;
}

.fields-group { grid-column: 1 / -1; margin-top: var(--sp-4); padding-top: var(--sp-6); border-top: 1px solid var(--divider); color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.fields-group:first-child { margin-top: 0; padding-top: var(--sp-2); border-top: 0; }
.fields input, .fields select { width: 100%; max-width: 260px; }
.fields input[type="number"] { max-width: 140px; }
.fields input[type="color"] { max-width: 56px; }
.fields input[type="checkbox"] { justify-self: start; }
.fields select { min-width: 140px; }
.fields .field-hint { grid-column: 2; margin-top: -6px; color: var(--text-3); font-size: var(--fs-xs); }

.set-dlg, .goto-dlg, .form-dlg { width: min(440px, calc(100vw - 32px)); }

.confirm-dlg { width: min(420px, calc(100vw - 32px)); }
.confirm-body { display: flex; gap: var(--sp-7); padding: var(--sp-10) var(--sp-9) var(--sp-9); }
.confirm-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--down-soft); color: var(--down); }
.confirm-icon svg { width: 20px; height: 20px; }
.confirm-dlg.info .confirm-icon { background: var(--blue-soft); color: var(--blue); }
.confirm-text { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-md); line-height: var(--lh-normal); }

.pine-dlg { width: min(900px, calc(100vw - 24px)); }

.pine-dlg #pineSource {
  margin: 0 var(--sp-9) var(--sp-5);
  padding: var(--sp-6);
  min-height: 200px;
  height: min(420px, 52vh);
  resize: vertical;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
}

.pine-status { color: var(--text-3); font-size: var(--fs-sm); }
.pine-error { padding: 0 var(--sp-9) var(--sp-5); color: var(--down); font-family: var(--font-mono); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.pine-error:empty { display: none; }

.about-content { display: flex; flex-direction: column; gap: var(--sp-5); padding: 0 var(--sp-9) var(--sp-9); color: var(--text-2); font-size: var(--fs-md); line-height: var(--lh-normal); }
.about-content p:first-child { color: var(--text-1); font-weight: var(--fw-medium); }

.admin-dlg { width: min(880px, calc(100vw - 32px)); }
.admin-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); padding: 0 var(--sp-9) var(--sp-5); color: var(--text-3); font-size: var(--fs-sm); }
.admin-table-wrap { flex: 1 1 auto; min-height: 0; padding: 0 0 var(--sp-5); overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.admin-table th { position: sticky; top: 0; z-index: 1; padding: var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border-1); background: var(--panel-bg); color: var(--text-3); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-align: left; text-transform: uppercase; white-space: nowrap; }
.admin-table td { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--divider); text-align: left; white-space: nowrap; }
.admin-table tbody tr:hover { background: var(--surface-hover); }
.admin-table td:first-child { color: var(--text-1); font-weight: var(--fw-semibold); }
.admin-table td:nth-child(5),
.admin-table td:nth-child(n+6) { white-space: normal; overflow-wrap: anywhere; }

.admin-restart-wrap { flex: none; border-top: 1px solid var(--divider); }
.admin-restart-wrap .dlg-msg { padding: var(--sp-5) var(--sp-9) 0; }
.admin-restart { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-5) var(--sp-9) 0; color: var(--text-3); font-size: var(--fs-sm); }
.admin-restart[hidden] { display: none; }
.admin-restart b { color: var(--text-1); font-family: var(--font-mono, monospace); letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.admin-restart input { width: 96px; height: 28px; padding: 0 var(--sp-4); border: 1px solid var(--border-1); border-radius: var(--r-sm); background: var(--panel-bg); color: var(--text-1); letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }
.admin-restart input:focus { border-color: var(--accent); outline: none; }
.admin-restart-foot { padding: var(--sp-5) var(--sp-9) var(--sp-8); border-top: 0; }
.admin-restart-foot .dlg-sub { max-width: 46ch; }

@media (max-width: 640px) {
  .admin-restart-foot { flex-wrap: wrap; }
}

/* Banner inside the shell. */
.app-shell > .banner { margin: 0; border-radius: var(--r-sm); }

/* ==========================================================================
   Candle Data Pane — right side panel showing OHLCV for each candle
   ========================================================================== */

.candle-data-pane {
  width: 360px;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--border-1);
}

.candle-data-pane[hidden] { display: none; }

/* Body class for candle data pane visibility */
body.cdp-hidden .candle-data-pane { display: none !important; }
body.has-candle-data .candle-data-pane { display: flex; }

.cdp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-1);
  flex: none;
}

.cdp-title {
  color: var(--text-1);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}

.cdp-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-1);
  flex: none;
}

.cdp-select {
  height: 28px;
  padding: 0 var(--sp-6) 0 var(--sp-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.cdp-select:focus { border-color: var(--accent); outline: none; }

.cdp-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.cdp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.cdp-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.cdp-table th {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
  background: var(--panel-bg);
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.cdp-table td {
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--divider);
  color: var(--text-1);
  white-space: nowrap;
}

.cdp-table tbody tr:hover { background: var(--surface-hover); }

.cdp-table td:first-child {
  color: var(--text-2);
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-xs);
}

.cdp-table .cdp-up { color: var(--up); }
.cdp-table .cdp-down { color: var(--down); }

.cdp-empty {
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* Right panel adjustments for candle data pane visibility */
.charts.has-candle-data .right-panel.candle-data-pane { display: flex; }

/* When candle data pane is open, adjust watchlist position */
#main[style*="grid-template-columns"] .right-panel.candle-data-pane { }
