/* TradingViews.in charting app. Loaded only on the front page (see functions.php). */
:root {
  --bg: #0f1218; --panel: #151922; --border: #262c38; --text: #d7dde6; --muted: #8a94a3;
  --up: #26a69a; --down: #ef5350; --accent: #2962ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--muted); font-weight: 500; }
.wl-foot { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
select, button { background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 8px; font: inherit; cursor: pointer; }
/* WordPress form styles can stretch selects to full width; keep the symbol picker compact */
#symbol { width: auto; min-width: 120px; padding-right: 28px; }
#intervals { display: flex; gap: 2px; }
/* Account */
.account { position: relative; }
.account[hidden], .account [hidden] { display: none; }
.guest-links { display: flex; gap: 6px; }
.btn { display: inline-block; border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px;
  color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#userBtn { display: flex; align-items: center; gap: 6px; }
#userBtn.attention .avatar { box-shadow: 0 0 0 2px #ff9800; }
.avatar { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.user-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 12; width: 240px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 8px 24px #0008; }
.user-panel a { color: var(--text); }
.sync-status { color: var(--muted); font-size: 12px; }
.sync-status[data-state="error"], .sync-status[data-state="expired"] { color: #ff9800; }
#intervals button { border-color: transparent; background: transparent; color: var(--muted); }
#intervals button.active { background: var(--accent); color: #fff; }
.ticker { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
#price { font-size: 16px; font-weight: 600; }
.up { color: var(--up); } .down { color: var(--down); }
#indBtn { display: flex; align-items: center; gap: 6px; }
#indBtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.modal { position: fixed; inset: 0; z-index: 30; background: #0009; display: flex; justify-content: center;
  align-items: flex-start; padding: 10vh 16px 16px; }
.modal[hidden] { display: none; }
.modal-box { width: min(480px, 100%); max-height: 75vh; display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 16px 48px #000a; }
.modal-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.modal-head input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 10px; font: inherit; }
#indList { overflow-y: auto; padding: 4px 0 8px; }
#indList h4 { margin: 12px 14px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); }
#indList button { display: flex; align-items: center; width: 100%; gap: 8px; border: 0; border-radius: 0;
  background: none; padding: 7px 14px; text-align: left; }
#indList button:hover { background: #1e2430; }
#indList .short { margin-left: auto; color: var(--muted); }
#indList .count { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; }
#indList .none { padding: 16px 14px; color: var(--muted); }
.popover { position: fixed; z-index: 25; width: 240px; padding: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px #0008; }
.popover[hidden] { display: none; }
.popover h3 { margin: 0 0 10px; font-size: 13px; }
.popover label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px;
  color: var(--muted); }
.popover input { width: 90px; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 6px; font: inherit; }
.popover .actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.live::before { background: var(--up); }
.status.error::before { background: var(--down); }
.workspace { flex: 1; display: flex; min-height: 0; }
.toolbar { display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--panel);
  border-right: 1px solid var(--border); }
.toolbar button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border-color: transparent; background: transparent; color: var(--muted); }
.toolbar button:hover { color: var(--text); background: #1e2430; }
.toolbar button.active { color: #fff; background: var(--accent); }
.toolbar hr { width: 100%; border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.toolbar svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
#hint { position: absolute; bottom: 40%; left: 50%; transform: translateX(-50%); z-index: 2;
  pointer-events: none; padding: 4px 10px; border-radius: 4px; background: #000a; color: var(--text); }
#hint:empty { display: none; }
#alertsBtn { display: flex; align-items: center; gap: 4px; }
#alertsBtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
#alertCount:empty { display: none; }
#alertCount { background: #ff9800; color: #000; border-radius: 8px; padding: 0 5px; font-size: 11px; font-weight: 700; }
#alertsPanel { position: absolute; top: 52px; right: 16px; z-index: 10; width: min(320px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px #0008; }
#alertsPanel[hidden] { display: none; }
#alertsPanel h3 { margin: 0; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; }
#alertForm { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
#alertForm input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 8px; font: inherit; }
#alertForm button { background: var(--accent); border-color: var(--accent); color: #fff; }
#alertList { list-style: none; margin: 0; padding: 4px 0; max-height: 300px; overflow-y: auto; }
#alertList li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; }
#alertList li:hover { background: #1e2430; }
#alertList li > span:first-child { flex: 1; font-variant-numeric: tabular-nums; }
#alertList li.done { color: var(--muted); }
#alertList li.empty { color: var(--muted); cursor: default; }
#alertList .meta { color: var(--muted); font-size: 12px; }
#alertList li:not(.done) .meta { color: #ff9800; }
#alertList button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; font-size: 16px; }
#alertList button:hover { color: var(--down); }
.link { border: 0; background: none; color: var(--muted); padding: 0; font-size: 12px; }
.link:hover { color: var(--text); }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; flex-direction: column; gap: 8px;
  max-width: calc(100vw - 32px); }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 4px; padding: 10px 14px; box-shadow: 0 8px 24px #0008; cursor: pointer; }
.toast.alert { border-left-color: #ff9800; }
.toast b { display: block; margin-bottom: 2px; }
.charts { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
#wlBtn { display: flex; align-items: center; gap: 6px; }
#wlBtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
#wlBtn.active { border-color: var(--accent); }
.watchlist { width: 280px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--border); }
.watchlist[hidden] { display: none; }
.wl-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 8px; font-weight: 600; }
.wl-head .link { font-size: 18px; line-height: 1; }
#wlForm { padding: 0 12px 8px; }
#wlInput { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 5px 8px; font: inherit; }
.wl-cols, #wlList li { display: grid; grid-template-columns: 1fr 56px 88px; align-items: center; gap: 8px; }
.wl-cols { padding: 4px 12px 4px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  border-bottom: 1px solid var(--border); }
.wl-cols span:last-child { text-align: right; }
#wlList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#wlList li { padding: 6px 12px; cursor: pointer; border-left: 2px solid transparent; }
#wlList li:hover { background: #1e2430; }
#wlList li.active { background: #1a2233; border-left-color: var(--accent); }
#wlList li.empty { display: block; color: var(--muted); cursor: default; }
.wl-sym { display: flex; align-items: baseline; gap: 2px; min-width: 0; }
.wl-sym b { font-weight: 600; }
.wl-sym .quote { color: var(--muted); font-size: 11px; }
.wl-rm { visibility: hidden; margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0 4px; font-size: 15px; line-height: 1; }
#wlList li:hover .wl-rm { visibility: visible; }
.wl-rm:hover { color: var(--down); }
.wl-spark svg { display: block; }
.wl-last { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; line-height: 1.25; }
.wl-price { border-radius: 3px; padding: 0 3px; margin-right: -3px; transition: background-color .6s; }
.wl-price.flash-up { background: #26a69a44; transition: none; }
.wl-price.flash-down { background: #ef535044; transition: none; }
.wl-chg { font-size: 12px; }
@media (max-width: 900px) {
  .workspace { position: relative; }
  .watchlist { position: absolute; top: 0; right: 0; bottom: 0; z-index: 15; max-width: 100%; box-shadow: -8px 0 24px #0008; }
}
/* With many panes the chart area scrolls rather than squeezing the price chart */
.charts { overflow-y: auto; }
#main { flex: 3 1 0; min-height: 340px; }
.pane { flex: 1 1 0; min-height: 110px; display: flex; position: relative; border-top: 1px solid var(--border); }
.pane-chart { flex: 1; min-width: 0; }
/* The chart library z-indexes its canvases; contain them so legends and their buttons stay on top */
#main, .pane-chart { position: relative; z-index: 0; }
.legend { position: absolute; z-index: 2; pointer-events: none; font-variant-numeric: tabular-nums; color: var(--muted); }
#legend { top: 8px; left: 12px; }
.pane-legend { top: 4px; left: 12px; }
.legend b { color: var(--text); font-weight: 600; }
.legend .row { margin-bottom: 2px; }
.legend .name { color: var(--text); }
.legend .tools button { pointer-events: auto; border: 0; background: none; color: var(--muted); padding: 0 3px; }
.legend .tools button:hover { color: var(--text); }
