/* ═══════════════════════════════════════════════════════
   Main Layout, Topbar, Chart
   ═══════════════════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 14px; gap: 10px;
  background: var(--panel); flex-shrink: 0;
}
/* Symbol input & pair label */
.symbol-wrap { position: relative; display: flex; align-items: center; }
.symbol-input {
  position: absolute; top: 50%; left: 0; transform: translateY(-50%);
  font-family: var(--font-ui); font-weight: 700; font-size: 1.13rem;
  background: var(--card); color: var(--text); border: 1px solid var(--blue);
  border-radius: var(--radius-sm); padding: 2px 8px; width: 140px; outline: none;
  display: none; z-index: 5;
}
.symbol-input.visible { display: block; }
.pair {
  font-family: var(--font-ui); font-weight: 700; font-size: 1.13rem;
  cursor: pointer; transition: color .15s;
}
.pair:hover { color: var(--blue); }
.pair.loading { color: var(--text-muted); animation: pulse-text 1s ease-in-out infinite; }
@keyframes pulse-text { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.price { font-family: var(--font-ui); font-size: 1.07rem; font-weight: 600; }
.price.up { color: var(--green); }
.price.down { color: var(--red); }

.badge { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; padding: 3px 7px; border-radius: var(--radius-sm); }
.badge.up { background: var(--green-dim); color: var(--green); }
.badge.down { background: var(--red-dim); color: var(--red); }

.spacer { flex: 1; }
.stat { text-align: right; }
.stat .lbl { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.stat .val { font-family: var(--font-ui); font-size: .85rem; font-weight: 500; color: var(--text-dim); }
.stat .val.up { color: var(--green); }
.stat .val.down { color: var(--red); }
.stat .val.flat { color: var(--text-dim); }

#chartArea { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; position: relative; }
#chartWrap { flex: 1; position: relative; background: var(--bg); overflow: hidden; min-height: 0; }
#optProfileCanvas, .vol-profile-canvas, .vol-profile-range-canvas { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 5; }
#chartLogo { position: absolute; bottom: 32px; left: 12px; display: flex; align-items: center; gap: 8px; opacity: 1; pointer-events: none; z-index: 10; }
#chartLogo img { width: 32px; height: 32px; flex-shrink: 0; }
#chartLogo span { font-family: var(--font-ui); font-size: 22px; font-weight: 600; color: var(--text-bright); white-space: nowrap; letter-spacing: 0.02em; }
.chart-loading {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .3s ease;
}
.chart-loading.hidden { opacity: 0; pointer-events: none; }
.cl-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cl-spinner { width: 36px; height: 36px; animation: cl-rotate .9s linear infinite; }
.cl-spinner circle {
  stroke: var(--blue); stroke-linecap: round;
  stroke-dasharray: 90, 150; stroke-dashoffset: -35;
  animation: cl-dash 1.4s ease-in-out infinite;
}
.cl-text {
  font-family: var(--font-ui);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
  animation: cl-pulse 1.6s ease-in-out infinite;
}
@keyframes cl-rotate { to { transform: rotate(360deg); } }
@keyframes cl-dash {
  0%   { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50%  { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}
@keyframes cl-pulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }

.ohlc-bar {
  position: absolute; top: 8px; left: 12px; z-index: 10;
  pointer-events: none;
  display: flex; gap: 12px;
  font-family: var(--font-ui); font-size: .87rem;
}
.ohlc-bar .item { display: flex; gap: 4px; }
.ohlc-bar .lbl { color: var(--text-muted); }
.ohlc-bar .val { color: var(--text-dim); font-weight: 500; }

/* Performance bar — sotto ohlc-bar, stessa famiglia visiva */
.perf-bar {
  position: absolute; top: 30px; left: 12px; z-index: 10;
  pointer-events: none;
  display: flex; gap: 12px;
  font-family: var(--font-ui); font-size: .87rem;
}
.perf-bar .item { display: flex; gap: 4px; }
.perf-bar .lbl { color: var(--text-muted); }
.perf-bar .val { color: var(--text-dim); font-weight: 500; }
.perf-bar .val.up { color: var(--green); }
.perf-bar .val.down { color: var(--red); }
.perf-bar .val.flat { color: var(--text-dim); }

/* Symbol logo (loaded from FMP, fallback: iniziale in pallino) */
.topbar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
  margin-left: 4px;
}
.topbar-logo img {
  width: 24px; height: 24px;
  border-radius: 5px;
  object-fit: contain;
  background: rgba(255,255,255,.05);
}
.topbar-logo-fb {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6b7280, #374151);
  color: #fff;
  font: 600 .82rem/1 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: -.01em;
  user-select: none;
}

/* Market name in topbar (ex ohlc-exchange spostato nell'header) */
.topbar-market {
  font-family: var(--font-ui);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: .01em;
  padding: 0 8px;
  max-width: 420px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.draw-banner {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 20;
  background: var(--blue-dim);
  border: 1px solid var(--blue-focus);
  color: var(--blue);
  font-size: .93rem; font-weight: 600;
  padding: 5px 14px; border-radius: var(--radius-sm);
  display: none;
  font-family: var(--font-ui);
  pointer-events: none;
}
.draw-banner.visible { display: block; }

/* Copyright toast (global right-click) */
.ss-copyright-toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  font-family: var(--font-ui);
  font-size: .82rem; font-weight: 500;
  color: var(--text-dim);
  box-shadow: 0 8px 24px var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 9999;
  white-space: nowrap;
}
.ss-copyright-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

