/* GOLD DESK — scheda «Grafico» (stessi colori e regole del design system in app.css) */
body[data-view="grafico"] .layout { grid-template-columns: minmax(0, 1fr); }
body[data-view="grafico"] .rail { display: none; }

#v-grafico.on {
  display: grid; gap: var(--s2); height: 100%; min-height: 0;
  grid-template-columns: 42px minmax(0, 1fr) 270px; grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "barra barra barra" "strum centro lato";
}
#v-grafico.g-senza-lato { grid-template-columns: 42px minmax(0, 1fr) 0; }
#v-grafico.g-senza-lato .g-lato { display: none; }

.g-barra { grid-area: barra; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r); }
.g-barra .seg button { padding: 4px 8px; }
.g-symbtn { font-weight: 700; color: var(--gold-2); min-width: 86px; justify-content: center; letter-spacing: .02em; }
.g-sel { background: var(--bg); color: var(--text-2); border: 1px solid var(--line); border-radius: 7px; height: 28px; padding: 0 6px; font: 600 var(--fs-xs) var(--font); }
.g-sel:focus-visible, .g-in:focus-visible { outline: 2px solid var(--gold-line); outline-offset: 1px; }
.g-chk { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-2); cursor: pointer; }
.g-chk input { accent-color: var(--gold); margin: 0; }
.g-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.g-dx { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.btn.tog[aria-pressed="true"] { color: var(--gold-2); border-color: var(--gold-line); background: var(--gold-soft); }

.g-strumenti { grid-area: strum; display: flex; flex-direction: column; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r); align-items: center; }
.g-strumenti button { width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.g-strumenti button:hover { background: var(--surface-3); color: var(--text); }
.g-strumenti button[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold-2); }
.g-strumenti svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.g-strumenti .g-sep { width: 20px; height: 1px; margin: 4px 0; }

.g-centro { grid-area: centro; position: relative; min-width: 0; min-height: 0; }
.g-griglia { display: grid; gap: var(--s2); height: 100%; min-height: 0; }
.g-griglia[data-griglia="1"] { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.g-griglia[data-griglia="2"] { grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr)); }
.g-griglia[data-griglia="2v"] { grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1fr); }
.g-griglia[data-griglia="3"] { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.g-griglia[data-griglia="3"] .gc:first-child { grid-row: span 2; }
.g-griglia[data-griglia="4"] { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.g-vuoto { display: grid; place-items: center; height: 100%; color: var(--text-2); text-align: center; padding: var(--s5); border: 1px dashed var(--line-2); border-radius: var(--r); }

.gc { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.gc.attiva { border-color: var(--gold-line); }
.g-griglia[data-griglia="1"] .gc.attiva { border-color: var(--line); }
.gc-panes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.gc-pane { position: relative; flex: 1 1 0; min-height: 60px; border-top: 1px solid var(--line); }
.gc-pane.main { flex: 3.2 1 0; border-top: 0; }
.gc-tela { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; }
.g-disegno .gc-tela, body.g-scelta .gc-tela { cursor: crosshair; }
.gc-carica { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; pointer-events: none; text-align: center; padding: 20px; }

.gc-leg { position: absolute; left: 8px; top: 6px; z-index: 5; pointer-events: none; font-size: var(--fs-xs); max-width: calc(100% - 100px); }
.gc-tit { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.gc-sym { pointer-events: auto; border: 0; background: none; padding: 0; color: var(--text); font: 700 var(--fs) var(--font); cursor: pointer; }
.gc-sym:hover { color: var(--gold-2); }
.gc-tf { color: var(--text-2); font-weight: 600; }
.gc-ohlc { font-family: var(--mono); color: var(--text-3); }
.gc-ohlc b { font-weight: 500; }
.gc-ohlc.su b { color: var(--up); }
.gc-ohlc.giu b { color: var(--down); }
.gc-ind { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; }
.gc-iv { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-family: var(--mono); width: max-content; padding: 1px 4px; border-radius: 4px; }
.gc-iv.off { opacity: .5; }
.gc-iv button { pointer-events: auto; border: 0; background: none; color: var(--text-3); padding: 0 2px; cursor: pointer; font-size: 11px; opacity: 0; }
.gc-iv:hover { background: rgba(12,16,22,.85); }
.gc-iv:hover button, .gc-iv.off button { opacity: 1; }
.gc-iv button:hover { color: var(--gold-2); }
@media (hover: none) { .gc-iv button { opacity: 1; } }

.gc-replay { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--surface-2); border: 1px solid var(--public); border-radius: 999px; box-shadow: 0 12px 30px -12px #000; font-size: var(--fs-xs); white-space: nowrap; }
.gc-replay button, .gc-replay select { border: 1px solid var(--line-2); background: var(--bg); color: var(--text); border-radius: 6px; height: 26px; padding: 0 8px; font: 600 var(--fs-xs) var(--font); cursor: pointer; }
.gc-replay .pri { background: var(--public-soft); color: var(--public); border-color: var(--public); min-width: 34px; }

.g-sel-barra { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 10px; }
.g-sel-barra .sw { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.g-sel-barra .sw.on { border-color: var(--text); }
.g-sel-barra select { background: var(--bg); color: var(--text-2); border: 1px solid var(--line); border-radius: 6px; height: 26px; }

.g-lato { grid-area: lato; display: grid; grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--s2); min-height: 0; }
.g-liste, .g-alerts { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-xs); }
.gl-h { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.gl-h select { flex: 1; min-width: 80px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; height: 28px; font: 600 var(--fs-xs) var(--font); }
.gl-h .faint { margin-right: auto; }
.gl-r { display: grid; grid-template-columns: 1fr auto 58px 18px; gap: 6px; align-items: center; padding: 5px 8px; border-bottom: 1px solid rgba(28,36,49,.6); cursor: pointer; }
.gl-r:hover { background: var(--surface-2); }
.gl-r.gl-tit { cursor: default; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }
.gl-r.gl-tit:hover { background: none; }
.gl-r .num { text-align: right; font-family: var(--mono); }
.gl-r button { border: 0; background: none; color: var(--text-3); cursor: pointer; opacity: 0; padding: 0; }
.gl-r:hover button { opacity: 1; }
.su { color: var(--up); } .giu { color: var(--down); }
.ga-r { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; border-bottom: 1px solid rgba(28,36,49,.6); }
.ga-r > div { display: flex; flex-direction: column; min-width: 0; }
.ga-r.off b { color: var(--text-3); }
.ga-r .x { border: 0; background: none; color: var(--text-3); cursor: pointer; }
.ga-r .x:hover { color: var(--down); }
.switch.sm { width: 34px; height: 20px; }
.switch.sm::after { width: 14px; height: 14px; }
.switch.sm[aria-checked="true"]::after { transform: translateX(14px); }

.g-dlg { width: min(560px, calc(100vw - 32px)); max-height: min(78vh, 720px); padding: 0; color: var(--text); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; display: none; flex-direction: column; }
.g-dlg[open] { display: flex; }
.g-dlg::backdrop { background: rgba(3,5,8,.62); backdrop-filter: blur(2px); }
.g-dlg .card-b { overflow: auto; }
.g-in { width: 100%; height: 36px; padding: 0 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; font: var(--fs) var(--font); }
.gs-lista { display: flex; flex-direction: column; margin-top: 8px; max-height: 50vh; overflow: auto; }
.gs-r { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; text-align: left; padding: 7px 8px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text-2); cursor: pointer; font: var(--fs-sm) var(--font); }
.gs-r:hover, .gs-r:focus-visible { background: var(--surface-3); color: var(--text); }
.gs-r b { color: var(--text); }
.gs-r i { font-style: normal; color: var(--text-3); font-size: var(--fs-xs); }
.g-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); color: var(--text-2); }
.g-form label[hidden] { display: none; }
.g-form input, .g-form select { height: 32px; padding: 0 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px; font: var(--fs-sm) var(--font); }
.g-form input[type="color"] { padding: 2px; }
.g-form .chk { flex-direction: row; align-items: center; grid-column: 1 / -1; }
.g-form .chk input { height: auto; accent-color: var(--gold); }
.g-azioni { display: flex; justify-content: flex-end; margin-top: 12px; }
.g-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

@media (max-width: 1400px) { #v-grafico.on { grid-template-columns: 42px minmax(0, 1fr) 0; } #v-grafico .g-lato { display: none; } }
@media (max-width: 860px) {
  body[data-view="grafico"] .layout { display: block; }
  #v-grafico.on { height: calc(100dvh - 150px); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "barra" "strum" "centro"; }
  .g-strumenti { flex-direction: row; overflow-x: auto; }
  .g-strumenti .g-sep { width: 1px; height: 20px; margin: 0 4px; }
  .g-dx { margin-left: 0; }
  .g-barra { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .g-barra > * { flex: none; }
  .g-barra .g-chk, .g-barra #g-griglie, .g-barra .g-sep, #g-lay-nuovo, #g-lay-copia, #g-lay-via, #g-pann { display: none; }
  .g-form { grid-template-columns: 1fr; }
}

/* ── aspetto TradingView (tema scuro classico) ── */
.gc { background: #131722; border-color: #2a2e39; }
.gc.attiva { border-color: #2962ff; }
.gc-leg { font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif; }
.gc-sym { font-family: inherit; color: #d1d4dc; }
.gc-ohlc { font-family: inherit; }
.gc-ohlc.su b { color: #089981; } .gc-ohlc.giu b { color: #f23645; }
.gc-iv { font-family: inherit; color: #b2b5be; }
.gc-pane { border-top-color: #2a2e39; }
.g-strumenti button[aria-pressed="true"] { background: rgba(41,98,255,.18); color: #5b8cff; }

/* «+» sulla scala dei prezzi */
.gc-piu { position: absolute; z-index: 7; width: 20px; height: 20px; padding: 0; border: 1px solid #434651; border-radius: 4px;
  background: #2a2e39; color: #d1d4dc; font: 600 15px/18px system-ui; cursor: pointer; }
.gc-piu:hover { background: #2962ff; border-color: #2962ff; color: #fff; }
.gc-piu[hidden] { display: none; }

/* menu del tasto destro */
.g-menu { position: fixed; z-index: 1000; min-width: 240px; padding: 6px 0; background: #1e222d; border: 1px solid #363a45; border-radius: 6px; box-shadow: 0 12px 32px -8px rgba(0,0,0,.7); }
.g-menu[hidden] { display: none; }
.g-menu button { display: flex; width: 100%; justify-content: space-between; gap: 24px; padding: 7px 14px; border: 0; background: none; color: #d1d4dc; font: 13px -apple-system, "Trebuchet MS", Roboto, sans-serif; text-align: left; cursor: pointer; }
.g-menu button:hover { background: #2a2e39; }
.g-menu button span { color: #787b86; font-size: 12px; }
.g-menu hr { border: 0; border-top: 1px solid #363a45; margin: 5px 0; }

/* modelli di indicatori */
.g-modelli { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.g-modelli select { height: 28px; background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; min-width: 120px; }
