/* =========================================================
   MARKET BUBBLES / TICKER LIST  (regola 5px su gap & padding)
   ========================================================= */
.mb-page {
    --mb-yellow: #FDE021;
    --mb-up: #10b981;
    --mb-up-l: #34d399;
    --mb-down: #ef4444;
    --mb-down-l: #f87171;
    --mb-border: rgba(253, 224, 33, 0.3);
    --mb-line: rgba(31, 41, 55, 0.7);
    display: flex;
    flex-direction: column;
    gap: 5px;
    height: calc(100dvh - 20px - 64px);
    min-height: 420px;
    font-variant-numeric: tabular-nums;
}
@media (min-width: 768px) {
    .mb-page { height: calc(100dvh - 20px); }
}
body.mb-focus .mb-page { height: calc(100dvh - 20px); }

/* Focus / Ticker mode: nasconde sidebar e bottom nav */
body.mb-focus #sidebar,
body.mb-focus .floating-pill-dock,
body.mb-focus #bottom-bar,
body.mb-focus > .fixed.bottom-0 { display: none !important; }
body.mb-focus main { padding-bottom: 0 !important; }

/* ---------- Toolbar ---------- */
.mb-toolbar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #1f2937;
}
.mb-toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 5px;
}
.mb-toolbar-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    width: 100%;
}
.mb-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 800;
    color: #fff;
    font-size: 14px;
    letter-spacing: -0.01em;
    margin-right: 5px;
}
.mb-title .mb-live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--mb-up);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: mb-pulse 2s infinite;
}
@keyframes mb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
    70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.mb-seg {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: #030712;
    border: 1px solid #1f2937;
    border-radius: 6px;
}
.mb-seg button {
    padding: 3px 6px;
    min-width: 32px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .04em;
    color: #6b7280;
    text-transform: uppercase;
    transition: all .15s ease;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.mb-seg button:hover { color: #e5e7eb; }
.mb-seg button.on { background: var(--mb-yellow); color: #030712; box-shadow: 0 2px 8px rgba(253,224,33,.15); }
.mb-seg button.on-soft { background: #1f2937; color: #fff; }
.mb-seg button svg { width: 11px; height: 11px; }

.mb-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 5px;
    border-radius: 6px;
    border: 1px solid #1f2937;
    background: #030712;
    color: #9ca3af;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    transition: all .15s ease;
}
.mb-btn:hover { color: #fff; border-color: #374151; }
.mb-btn.accent { border-color: var(--mb-border); color: var(--mb-yellow); }
.mb-btn svg { width: 12px; height: 12px; }
.mb-btn.spin svg { animation: mb-spin 1s linear infinite; }
@keyframes mb-spin { to { transform: rotate(360deg); } }
.mb-select {
    background: #030712;
    border: 1px solid #1f2937;
    color: #d1d5db;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 4px 5px;
    outline: none;
}
.mb-spacer { flex: 1; }
.mb-updated { font-size: 9px; color: #6b7280; font-weight: 600; white-space: nowrap; }

/* ---------- Summary strip (sempre su un unico rigo da 3 card) ---------- */
.mb-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
}
.mb-kpi {
    border: 1px solid var(--mb-border);
    border-radius: 6px;
    padding: 5px;
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
}
.mb-kpi .lbl { font-size: 7px; md:font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-kpi .val { font-size: 13px; font-weight: 900; color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-kpi .sub { font-size: 8px; md:font-size: 9px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 640px) {
    .mb-kpi .lbl { font-size: 8px; }
    .mb-kpi .val { font-size: 16px; }
    .mb-kpi .sub { font-size: 9px; }
}
.mb-up { color: var(--mb-up-l); }
.mb-down { color: var(--mb-down-l); }
.mb-flat { color: #6b7280; }

/* ---------- Stage (bubbles: senza bordo, senza sfondo) ---------- */
.mb-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    border: none;
    background: transparent;
    overflow: hidden;
    touch-action: none;
}
.mb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.mb-stage canvas.dragging { cursor: grabbing; }
.mb-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; font-size: 11px; font-weight: 600;
}

/* Popup dettaglio bolla */
.mb-pop {
    position: absolute;
    top: 5px; right: 5px;
    width: 230px;
    background: rgba(3, 7, 18, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--mb-border);
    border-radius: 8px;
    padding: 5px;
    display: flex; flex-direction: column; gap: 5px;
    box-shadow: 0 10px 40px rgba(0,0,0,.6);
    animation: mb-pop-in .18s ease-out;
    z-index: 5;
}
@keyframes mb-pop-in { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: none; } }
.mb-pop-head { display: flex; align-items: center; gap: 5px; }
.mb-pop-head img { width: 26px; height: 26px; border-radius: 50%; background: #111827; }
.mb-pop-head .sym { font-weight: 900; color: #fff; font-size: 14px; line-height: 1; }
.mb-pop-head .px { font-size: 10px; color: #9ca3af; font-family: ui-monospace, monospace; }
.mb-pop-head .x { margin-left: auto; color: #6b7280; padding: 2px; }
.mb-pop-head .x:hover { color: #fff; }
.mb-pop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.mb-pop-cell { background: #0b0f1a; border: 1px solid #1f2937; border-radius: 5px; padding: 5px; }
.mb-pop-cell .l { font-size: 7px; font-weight: 800; color: #6b7280; text-transform: uppercase; letter-spacing: .1em; }
.mb-pop-cell .v { font-size: 11px; font-weight: 800; color: #fff; font-family: ui-monospace, monospace; }
.mb-pop-tf { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.mb-pop-tf div { text-align: center; background: #0b0f1a; border-radius: 4px; padding: 3px 0; border: 1px solid #111827; }
.mb-pop-tf .l { font-size: 7px; font-weight: 900; color: #6b7280; }
.mb-pop-tf .v { font-size: 9px; font-weight: 800; }
.mb-pop-actions { display: flex; gap: 5px; }
.mb-pop-actions button { flex: 1; justify-content: center; }

.mb-legend {
    position: absolute; left: 5px; bottom: 5px;
    display: flex; gap: 5px; align-items: center;
    font-size: 8px; font-weight: 800; color: #6b7280; text-transform: uppercase; letter-spacing: .08em;
    pointer-events: none;
}
.mb-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Ticker List (iPad orizzontale) ---------- */
.mb-list-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    container-type: inline-size;
    -webkit-overflow-scrolling: touch;
}
.mb-row {
    display: grid;
    grid-template-columns:
        26px                     /* # */
        minmax(120px, 1.5fr)     /* asset */
        minmax(80px, 1fr)        /* prezzo */
        repeat(5, minmax(58px, .75fr)) /* 1H 24H 7G 30G 1A */
        minmax(80px, 1fr)        /* saldo */
        minmax(90px, 1.1fr)      /* valore */
        minmax(64px, .8fr)       /* P/L */
        110px;                   /* spark */
    align-items: center;
    gap: 5px;
    padding: 0 5px;
    min-height: 44px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.16) !important;
    transition: background .15s ease;
}
.mb-row.body { cursor: pointer; }
.mb-row.body:hover, .mb-row.body:active { background: rgba(255,255,255,0.025); }
.mb-row.head {
    position: sticky; top: 0; z-index: 2;
    min-height: 30px;
    background: #030712 !important;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.22) !important;
    font-size: 9px;
    font-weight: 800;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.mb-row.head > div { cursor: pointer; user-select: none; white-space: nowrap; display: flex; align-items: center; gap: 2px; }
.mb-row.head > div.r { justify-content: flex-end; }
.mb-row.head > div.sorted { color: var(--mb-yellow); }
.mb-row.head > div.tf-on { color: #e5e7eb; }
.mb-row .r { text-align: right; justify-content: flex-end; }
.mb-row .c { text-align: center; }
.mb-idx { font-size: 11px; color: #4b5563; font-weight: 700; }
.mb-asset { display: flex; align-items: center; gap: 5px; min-width: 0; }
.mb-asset img { width: 24px; height: 24px; border-radius: 50%; background: #111827; flex-shrink: 0; object-fit: cover; }
.mb-asset .nm { display: flex; flex-direction: column; min-width: 0; }
.mb-asset .s { font-size: 13px; font-weight: 800; color: #fff; line-height: 1.1; }
.mb-asset .src { font-size: 8px; font-weight: 700; color: #6b7280; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .04em; }
.mb-price { font-size: 13px; font-weight: 800; color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; border-radius: 4px; padding: 2px 0; }
.mb-price .cur { color: var(--mb-yellow); margin-left: 2px; }
.mb-chg { font-size: 12px; font-weight: 800; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mb-chg .tri { font-size: 8px; margin-right: 2px; }
.mb-cell-tf-on { display: inline-block; background: rgba(253,224,33,0.06); border: 1px solid rgba(253,224,33,0.12); border-radius: 4px; padding: 2px 5px; }
.mb-val .cur { color: var(--mb-yellow); margin-left: 2px; }
.mb-plcell { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.mb-sub { font-size: 8px; font-weight: 700; font-family: ui-monospace, monospace; white-space: nowrap; }
.mb-qty { font-size: 11px; color: #9ca3af; font-family: ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-val { font-size: 13px; font-weight: 800; color: #fff; font-family: ui-monospace, monospace; white-space: nowrap; }
.mb-val .w { display: block; font-size: 8px; color: #6b7280; font-weight: 700; }
.mb-spark { width: 110px; height: 28px; }
.mb-spark svg { width: 100%; height: 100%; overflow: visible; }

/* flash su variazione prezzo */
.mb-flash-up { animation: mb-flash-up 1.2s ease-out; }
.mb-flash-down { animation: mb-flash-down 1.2s ease-out; }
@keyframes mb-flash-up { 0% { background: rgba(16,185,129,.35); } 100% { background: transparent; } }
@keyframes mb-flash-down { 0% { background: rgba(239,68,68,.35); } 100% { background: transparent; } }

.mb-list-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 6px;
}
.mb-clock-white {
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.04em;
    user-select: none;
}

/* Responsive: riduce colonne su larghezze contenute (container query) */
@container (max-width: 980px) {
    .mb-row { grid-template-columns: 22px minmax(110px,1.4fr) minmax(76px,1fr) repeat(5, minmax(54px,.75fr)) minmax(86px,1.1fr) minmax(58px,.8fr) 90px; }
    .mb-row > .col-qty { display: none; }
    .mb-spark { width: 90px; }
}
@container (max-width: 820px) {
    .mb-row { grid-template-columns: 22px minmax(100px,1.4fr) minmax(76px,1fr) repeat(5, minmax(52px,.75fr)) minmax(82px,1.1fr) minmax(56px,.8fr); }
    .mb-row > .col-spark { display: none; }
}
@container (max-width: 640px) {
    .mb-row { grid-template-columns: minmax(90px,1.3fr) minmax(70px,1fr) repeat(2, minmax(52px,.8fr)) minmax(76px,1fr); min-height: 40px; }
    .mb-row > .col-idx, .mb-row > .col-1h, .mb-row > .col-30d, .mb-row > .col-1y, .mb-row > .col-pl { display: none; }
    .mb-asset .s, .mb-price, .mb-val { font-size: 12px; }
    .mb-chg { font-size: 11px; }
}

@media (max-width: 640px) {
    .mb-updated { display: none; }
    .mb-pop { width: calc(100% - 10px); }
}

/* Light Theme overrides for pure white surfaces (#ffffff) */
html.light-theme .mb-seg {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}
html.light-theme .mb-btn {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}
html.light-theme .mb-select {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}
html.light-theme .mb-pop {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.1) !important;
}
html.light-theme .mb-pop-cell {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
html.light-theme .mb-pop-tf div {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
html.light-theme .mb-row.head {
    background: #000000 !important;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.22) !important;
}
html.light-theme .mb-kpi {
    background: #000000 !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
}

