/* Componenti comuni dei mockup. Palette e struttura stanno in ogni variante. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font-ui); overflow: hidden; -webkit-font-smoothing: antialiased; font-size: 1rem; line-height: 1.35; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
small { font-size: .78em; color: var(--muted); font-weight: 450; margin-left: .4em; letter-spacing: 0; }
kbd { font-family: var(--font-ui); font-size: .72rem; color: var(--muted); border: 1px solid var(--line-2); border-radius: .3rem; padding: 0 .3rem; line-height: 1.3rem; min-width: 1.3rem; text-align: center; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.icw { display: inline-flex; width: 1.15rem; height: 1.15rem; flex: none; }
.ic { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: .9rem; height: .9rem; }
.ti { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ti .u { stroke: var(--c-up); fill: var(--c-up); }
.ti .d { stroke: var(--c-down); fill: var(--c-down); }
.ti rect.u[fill="none"] { fill: none; }
.ti .a { fill: color-mix(in srgb, var(--c-up) 25%, transparent); stroke: none; }
.ti .f { fill: currentColor; stroke: none; }
.ti .h1 { fill: var(--c-hm-4); } .ti .h2 { fill: var(--c-hm-3); } .ti .h3 { fill: var(--c-hm-2); }

/* ---------- popover ---------- */
.pop { position: fixed; z-index: 50; background: var(--pop-bg, var(--panel)); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.99); transform-origin: top left; transition: opacity .14s ease, transform .14s ease, visibility 0s .14s; }
.pop.open { opacity: 1; visibility: visible; transform: none; transition: opacity .14s ease, transform .14s ease; }
.pop-title { display: flex; align-items: baseline; gap: .6rem; font-weight: 600; padding: .9rem 1rem .5rem; }
.pop-title span { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* ---------- menu indicatori ---------- */
.imenu { display: flex; flex-direction: column; min-height: 0; }
.imenu-search { display: flex; align-items: center; gap: .6rem; margin: .75rem .75rem .25rem; padding: 0 .75rem; height: 2.5rem; border-radius: var(--r-md); background: var(--field); border: 1px solid var(--line); color: var(--muted); }
.imenu-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.imenu-q { flex: 1; border: 0; outline: 0; background: none; color: var(--text); min-width: 0; }
.imenu-q::placeholder { color: var(--muted); }
.imenu-body { display: grid; grid-template-columns: 17rem 1fr; min-height: 0; flex: 1; border-top: 1px solid var(--line); margin-top: .5rem; }
.imenu-cats { padding: .5rem; border-right: 1px solid var(--line); overflow: auto; }
.imenu-sep { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .8rem .65rem .35rem; }
.imenu-catbtn { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .36rem .65rem; border-radius: var(--r-sm); text-align: left; color: var(--text-2); }
.imenu-catbtn:hover { background: var(--hover); color: var(--text); }
.imenu-catbtn.on { background: var(--accent-soft); color: var(--text); }
.imenu-catname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imenu-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); min-width: 1.9rem; text-align: right; padding: .05rem .4rem; border-radius: 99rem; background: var(--chip); }
.imenu-catbtn.on .imenu-count { color: var(--accent-text); background: transparent; }
.imenu-list { overflow: auto; padding: .5rem; min-height: 0; }
.imenu-head { display: flex; align-items: baseline; gap: .2rem; padding: .5rem .65rem .6rem; }
.imenu-head b { font-weight: 600; font-size: 1.02rem; }
.imenu-head span { color: var(--muted); font-size: .85rem; margin-left: .5rem; }
.imenu-head .cnt { margin-left: auto; font-family: var(--font-mono); font-size: .8rem; }
.imenu-item { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .48rem .65rem; border-radius: var(--r-sm); text-align: left; transition: background .12s; }
.imenu-item:hover { background: var(--hover); }
.imenu-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imenu-cat { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.imenu-add { color: var(--muted); opacity: 0; transition: opacity .12s; display: inline-flex; }
.imenu-item:hover .imenu-add { opacity: 1; color: var(--accent-text); }
.imenu-item.on .imenu-add { opacity: 1; color: var(--accent-text); }
.imenu-item.flash { animation: flash .5s ease; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.imenu-empty { color: var(--muted); padding: 1rem .65rem; }
.imenu-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.imenu-foot b { color: var(--text); font-weight: 600; font-family: var(--font-mono); }
.imenu-studio { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-2); }
.imenu-studio .icw { width: 1rem; height: 1rem; }

/* fisarmonica */
.imenu-acc { overflow: auto; padding: .25rem .5rem .5rem; flex: 1; min-height: 0; }
.imenu-acc-head { display: flex; align-items: center; gap: .45rem; width: 100%; padding: .5rem .5rem; border-radius: var(--r-sm); text-align: left; }
.imenu-acc-head:hover { background: var(--hover); }
.imenu-acc-head .chev { display: inline-flex; color: var(--muted); transition: transform .15s; }
.imenu-acc-head.on .chev { transform: rotate(90deg); }
.imenu-acc-head small { margin-left: 0; white-space: nowrap; overflow: hidden; }
.imenu-acc-head .imenu-catname { flex: 0 1 auto; }
.imenu-acc-head .imenu-count { margin-left: auto; }
.imenu-acc-body { padding: 0 0 .4rem 1.1rem; border-left: 1px solid var(--line); margin-left: 1rem; }
.imenu-acc .imenu-list { padding: 0; overflow: visible; }

/* schede */
.imenu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: .5rem; padding: .75rem; overflow: auto; flex: 1; align-content: start; min-height: 0; }
.imenu-grid.listing { display: flex; flex-direction: column; gap: 0; padding: .25rem .5rem; }
.imenu-card { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 't n' 'e e'; gap: .2rem .5rem; text-align: left; padding: .75rem .85rem; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card); transition: border-color .12s, background .12s, transform .12s; }
.imenu-card:hover { border-color: var(--accent); background: var(--hover); }
.imenu-card-n { grid-area: n; font-family: var(--font-mono); font-size: 1.35rem; font-weight: 600; color: var(--accent-text); line-height: 1; letter-spacing: -.02em; }
.imenu-card-t { grid-area: t; font-weight: 600; }
.imenu-card-t small { display: block; margin: .1rem 0 0; }
.imenu-card-ex { grid-area: e; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imenu-back { align-self: flex-start; color: var(--accent-text); padding: .4rem .65rem; font-size: .88rem; }

/* ---------- menu tipi di grafico ---------- */
.tmenu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.tmenu-col { border-right: 1px solid var(--line); }
.tmenu-col:nth-child(3) { border-right: 0; }
.tmenu-col .tmenu-group + .tmenu-group { border-top: 1px solid var(--line); }
.tmenu-group { padding: .6rem; }
.tmenu-head { display: flex; align-items: baseline; gap: .5rem; padding: .35rem .5rem .55rem; }
.tmenu-head b { font-weight: 600; }
.tmenu-hint { color: var(--muted); font-size: .8rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmenu-count { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); background: var(--chip); padding: .05rem .45rem; border-radius: 99rem; }
.tmenu-items { display: flex; flex-direction: column; }
.tmenu-item { display: flex; align-items: center; gap: .65rem; padding: .38rem .5rem; border-radius: var(--r-sm); text-align: left; color: var(--text-2); }
.tmenu-item:hover { background: var(--hover); color: var(--text); }
.tmenu-item.on { background: var(--accent-soft); color: var(--text); }
.tmenu-name { white-space: nowrap; flex: none; }
.tmenu-item small { margin-left: 0; white-space: nowrap; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tmenu-star { width: 1rem; height: 1rem; margin-left: auto; color: var(--muted); opacity: 0; display: inline-flex; flex: none; }
.tmenu-star .ic { width: 1rem; height: 1rem; }
.tmenu-item:hover .tmenu-star { opacity: .8; }
.tmenu-foot { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: .6rem 1.1rem; font-size: .82rem; color: var(--muted); }
.tmenu-foot b { color: var(--text); font-family: var(--font-mono); }
/* versione a tessere (pannello stretto) */
.tmenu-tiles { grid-template-columns: 1fr; }
.tmenu-tiles .tmenu-group { border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem .25rem .75rem; }
.tmenu-tiles .tmenu-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.tmenu-tiles .tmenu-item { flex-direction: column; gap: .35rem; padding: .6rem .3rem .5rem; text-align: center; border: 1px solid var(--line); background: var(--card); }
.tmenu-tiles .tmenu-item .ti { width: 1.6rem; height: 1.6rem; }
.tmenu-tiles .tmenu-name { white-space: normal; font-size: .8rem; line-height: 1.2; min-height: 2em; display: flex; align-items: center; }
.tmenu-tiles .tmenu-item small, .tmenu-tiles .tmenu-star { display: none; }
.tmenu-tiles .tmenu-item.on { border-color: var(--accent); }
.tmenu-tiles .tmenu-foot { border-top: 0; padding: .75rem .5rem; }

/* ---------- timeframe ---------- */
.tf { display: flex; align-items: center; gap: .25rem; position: relative; }
.tf-chips { display: flex; gap: .125rem; }
.tf-chip { font-family: var(--font-mono); font-size: .86rem; padding: 0 .55rem; height: 2rem; border-radius: var(--r-sm); color: var(--text-2); display: inline-flex; align-items: center; gap: .3rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tf-chip:hover { background: var(--hover); color: var(--text); }
.tf-chip.on { background: var(--sel-bg); color: var(--sel-text); }
.tf-chip.temp { box-shadow: inset 0 0 0 1px var(--line-2); background: transparent; color: var(--text); }
.tf-pin { width: .9rem; height: .9rem; display: inline-flex; color: var(--muted); }
.tf-pin:hover { color: var(--accent-text); }
.tf-inw { position: relative; }
.tf-in { width: 9.5rem; height: 2rem; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--field); padding: 0 .6rem; outline: 0; font-family: var(--font-mono); font-size: .82rem; }
.tf-compact .tf-in { width: 7.5rem; }
.tf-in::placeholder { color: var(--muted); font-family: var(--font-ui); }
.tf-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tf-hint { position: absolute; top: calc(100% + .35rem); left: 0; white-space: nowrap; font-size: .78rem; padding: .3rem .55rem; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line-2); color: var(--text-2); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 40; box-shadow: var(--shadow-pop); }
.tf-hint.show { opacity: 1; }
.tf-hint.bad { color: var(--c-down); }
.tf-more { height: 2rem; width: 1.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); color: var(--muted); }
.tf-more:hover { background: var(--hover); color: var(--text); }
.tf-pop { width: 46rem; }
.tf-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .25rem; padding: 0 .6rem .4rem; }
.tf-colh { font-size: .78rem; color: var(--muted); padding: .3rem .4rem; font-weight: 600; white-space: nowrap; }
.tf-colh small { display: block; margin: 0; font-weight: 400; }
.tf-row { display: flex; align-items: center; border-radius: var(--r-sm); }
.tf-row:hover { background: var(--hover); }
.tf-row.on { background: var(--accent-soft); }
.tf-row-l { flex: 1; text-align: left; padding: .3rem .4rem; font-family: var(--font-mono); font-size: .86rem; }
.tf-row-s { width: 1.6rem; height: 1.6rem; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); opacity: .45; }
.tf-row-s .ic { width: .95rem; height: .95rem; }
.tf-row-s.fav { color: var(--star); opacity: 1; }
.tf-row-s.fav .ic { fill: var(--star); }
.tf-pop-foot { border-top: 1px solid var(--line); padding: .6rem 1rem; color: var(--muted); font-size: .82rem; }
.tf-pop-foot code { font-family: var(--font-mono); color: var(--text); background: var(--chip); padding: .05rem .35rem; border-radius: .25rem; }

/* ---------- impostazioni ---------- */
.set { display: flex; flex-direction: column; }
.set-block { padding: .75rem 1rem 1rem; border-bottom: 1px solid var(--line); }
.set-label { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.set-hint { display: flex; gap: .6rem; color: var(--muted); font-size: .86rem; line-height: 1.45; padding: .7rem .75rem; border: 1px dashed var(--line-2); border-radius: var(--r-md); }
.set-hint .icw { margin-top: .1rem; }
.set-sel-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.set-sel-head b { font-weight: 600; }
.set-sel-head small { margin: 0; }
.dot { width: .62rem; height: .62rem; border-radius: 50%; flex: none; }
.set-sec { border-bottom: 1px solid var(--line); }
.set-sec summary { list-style: none; display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; cursor: pointer; font-weight: 600; }
.set-sec summary::-webkit-details-marker { display: none; }
.set-sec summary small { flex: 1; margin-left: .2rem; }
.set-sec summary .icw { color: var(--muted); transition: transform .15s; width: .9rem; height: .9rem; }
.set-sec[open] summary .icw { transform: rotate(180deg); }
.set-sec summary:hover { background: var(--hover); }
.set-body { padding: 0 1rem .8rem; }
.srow { display: flex; align-items: center; gap: .6rem; min-height: 2.25rem; padding: .15rem 0; cursor: default; }
.swrap > .srow { cursor: pointer; border-radius: var(--r-sm); margin: 0 -.4rem; padding: .15rem .4rem; }
.swrap > .srow:hover { background: var(--hover); }
.srow-l { flex: 1; min-width: 0; color: var(--text-2); }
.srow-l small { margin-left: .35rem; }
.sw-hex { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); }
.sw { width: 1.6rem; height: 1.6rem; border-radius: var(--r-sm); background: var(--sw); box-shadow: inset 0 0 0 1px rgba(127,127,127,.35); flex: none; }
.swrap.open .sw { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--accent); }
.pal { margin: .25rem 0 .6rem; padding: .6rem; border-radius: var(--r-md); background: var(--field); border: 1px solid var(--line); animation: drop .16s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.pal-grid { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; }
.pal-grays { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; margin-top: 4px; }
.pal-c { aspect-ratio: 1; border-radius: 3px; transition: transform .1s; }
.pal-c:hover { transform: scale(1.25); position: relative; z-index: 1; box-shadow: 0 0 0 1.5px var(--text); }
.pal-c.on { box-shadow: 0 0 0 1.5px var(--text); }
.pal-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; margin-top: .55rem; font-size: .78rem; color: var(--muted); }
.pal-foot label { display: flex; align-items: center; gap: .35rem; }
.pal-hex { width: 5.4rem; height: 1.8rem; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel); padding: 0 .4rem; font-family: var(--font-mono); font-size: .8rem; color: var(--text); }
.pal-alpha-l { flex: 1; min-width: 0; }
.pal-alpha { flex: 1; min-width: 0; width: 100%; accent-color: var(--accent); }
.pal-more { color: var(--text-2); cursor: pointer; }
.pal-native { width: 1.4rem; height: 1.4rem; border: 0; padding: 0; background: none; }
.sel, .num { height: 2rem; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--field); padding: 0 .45rem; color: var(--text); }
.num { width: 4.6rem; text-align: right; }
.sel { max-width: 11rem; }
.range { width: 7rem; accent-color: var(--accent); }
.set-val { color: var(--muted); font-family: var(--font-mono); font-size: .82rem; }
.seg-mini { display: inline-flex; gap: 2px; padding: 2px; background: var(--field); border-radius: var(--r-sm); }
.seg-mini button { width: 2rem; height: 1.6rem; display: flex; align-items: center; justify-content: center; border-radius: calc(var(--r-sm) - 2px); }
.seg-mini button i { width: 1.1rem; background: var(--text-2); border-radius: 2px; display: block; }
.seg-mini button.on { background: var(--panel); box-shadow: 0 0 0 1px var(--line-2); }
.set-actions { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.btn-s { height: 2rem; padding: 0 .75rem; border-radius: var(--r-sm); border: 1px solid var(--line-2); color: var(--text-2); font-size: .86rem; }
.btn-s:hover { color: var(--text); background: var(--hover); }
.btn-s.danger:hover { color: var(--c-down); }
.set-note { color: var(--muted); font-size: .84rem; line-height: 1.45; margin-bottom: .6rem; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.theme { display: flex; flex-direction: column; gap: .4rem; padding: .5rem; border-radius: var(--r-md); border: 1px solid var(--line); font-size: .82rem; text-align: left; }
.theme.on { border-color: var(--accent); }
.theme-sw { display: flex; height: 1.4rem; border-radius: .3rem; overflow: hidden; }
.theme-sw i { flex: 1; }
.hm-bar { height: .7rem; border-radius: 99rem; margin: .2rem 0 .6rem; }

/* legenda sul grafico */
.legend { position: absolute; top: .6rem; left: .75rem; display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; pointer-events: none; z-index: 3; max-width: 70%; }
.lg-title { display: flex; align-items: baseline; gap: .75rem; font-size: .88rem; color: var(--text-2); padding: .15rem .35rem; }
.lg-title b { color: var(--text); font-weight: 600; }
.lg-ohlc { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); display: flex; gap: .75rem; }
.lg-ohlc i { font-style: normal; color: var(--text-2); }
.lg-row { white-space: nowrap; pointer-events: auto; display: flex; align-items: center; gap: .45rem; font-size: .84rem; padding: .12rem .35rem; border-radius: var(--r-sm); color: var(--text-2); cursor: pointer; transition: background .12s; }
.lg-row:hover, .lg-row.sel { background: var(--legend-hover); color: var(--text); }
.lg-row.sel { box-shadow: inset 0 0 0 1px var(--accent); }
.lg-row.off { opacity: .45; }
.lg-row .v { font-family: var(--font-mono); font-size: .8rem; }
.lg-row .acts { display: none; gap: .1rem; margin-left: .2rem; }
.lg-row:hover .acts, .lg-row.sel .acts { display: inline-flex; }
.lg-row .acts button { width: 1.5rem; height: 1.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: .3rem; color: var(--muted); }
.lg-row .acts button:hover { color: var(--text); background: var(--hover); }
.lg-row .acts .icw { width: 1rem; height: 1rem; }
.lg-mod { pointer-events: auto; display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); padding: .1rem .35rem; }
.lg-mod .dot { width: .5rem; height: .5rem; }

.toast { position: fixed; left: 50%; bottom: 3rem; transform: translateX(-50%) translateY(8px); background: var(--toast-bg, var(--text)); color: var(--toast-text, var(--bg)); padding: .55rem .9rem; border-radius: var(--r-md); font-size: .88rem; opacity: 0; transition: opacity .16s, transform .16s; pointer-events: none; z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%); }
[hidden] { display: none !important; }
