:root {
  --bg: #0e0e10; --side: #131316; --panel: #18181b; --panel2: #1f1f23; --line: #2a2a2e; --text: #efeff1; --muted: #9a9aa5;
  --accent: #9146ff; --accent-h: #772ce8; --ok: #00c78a; --warn: #f5a524; --err: #ff5470; --blue: #3da5ff; --pink: #ff6bb3; --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: #b794ff; }
h1 { font-size: 1.7rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.boot, .msg { max-width: 520px; margin: 18vh auto; text-align: center; color: var(--muted); padding: 0 16px; }
body.plain .msg h1 { color: var(--text); margin-bottom: 8px; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; font-size: .86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* struttura */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; padding: 6px 10px 16px; font-size: 1.05rem; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 900; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.on { background: rgba(145, 70, 255, .16); color: #fff; }
.nav .ico { width: 20px; text-align: center; }
.nav .grp { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #6b6b76; padding: 14px 12px 4px; }
.side .foot { margin-top: auto; padding: 10px; font-size: .82rem; color: var(--muted); }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(14, 14, 16, .92); backdrop-filter: blur(8px); z-index: 5; }
.top .left { display: flex; align-items: center; gap: 12px; }
.btn.menu-btn { display: none; }
.content { padding: 24px; max-width: 1280px; margin: 0 auto; display: grid; gap: 20px; }
.pagehead { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.pagehead .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* componenti */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2 + .muted.small { margin-top: -8px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); text-align: center; overflow: hidden; }
.kpi .ic { padding: 10px 0 6px; font-size: 1.15rem; border-bottom: 1px solid var(--line); background: var(--panel2); }
.kpi .num { font-size: 1.9rem; font-weight: 800; margin-top: 12px; line-height: 1.1; }
.kpi .lbl { color: var(--muted); font-size: .88rem; padding: 2px 8px 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.pill.live { color: #fff; background: rgba(255, 84, 112, .18); border-color: rgba(255, 84, 112, .5); } .pill.live .dot { background: var(--err); box-shadow: 0 0 0 3px rgba(255, 84, 112, .25); }
.pill.ok { color: var(--ok); } .pill.ok .dot { background: var(--ok); } .pill.bad { color: var(--err); } .pill.bad .dot { background: var(--err); } .pill.warn { color: var(--warn); } .pill.warn .dot { background: var(--warn); }
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; padding: 6px 14px; border-radius: 8px; cursor: pointer; }
.tabs button.on { background: var(--panel2); color: #fff; } .tabs button:hover { color: #fff; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.stepper button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 800; cursor: pointer; padding: 4px 10px; border-radius: 8px; } .stepper button:hover:not(:disabled) { background: var(--panel2); color: #fff; } .stepper button:disabled { opacity: .35; cursor: default; }
.stepper span { padding: 0 10px; font-weight: 700; min-width: 110px; text-align: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; padding: 8px 16px; cursor: pointer; background: var(--accent); color: #fff; font: inherit; font-weight: 700; text-decoration: none; }
.btn:hover { background: var(--accent-h); } .btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); } .btn.ghost:hover { background: var(--panel2); }
.btn.danger { background: transparent; border: 1px solid rgba(255, 84, 112, .5); color: var(--err); } .btn.danger:hover { background: rgba(255, 84, 112, .12); }
.btn.small { padding: 4px 10px; font-size: .85rem; } .btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
label:has(> input[type=checkbox]) { display: flex; align-items: center; gap: 10px; }
label { display: grid; gap: 4px; font-weight: 700; font-size: .88rem; color: var(--muted); }
.form { display: grid; gap: 12px; } .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: #3a3a40; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + i { background: var(--accent); } .switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* tabelle ed elenchi */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; } tbody tr.click { cursor: pointer; } tbody tr.click:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.feed { display: grid; max-height: 560px; overflow-y: auto; }
.feed .it { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.feed .it:last-child { border-bottom: 0; } .feed .ic { font-size: 1.1rem; text-align: center; } .feed .who { font-weight: 800; } .feed .what { color: var(--muted); font-size: .86rem; } .feed .when { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.mod { color: var(--ok); } .chip.owner { color: #ffb066; } .chip.sub { color: #b794ff; } .chip.vip { color: var(--pink); }
.bar { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.stat-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); } .stat-row:last-child { border-bottom: 0; }
.funnel { display: grid; gap: 8px; } .funnel .stage { display: grid; grid-template-columns: 130px 1fr 70px; gap: 12px; align-items: center; } .funnel .bar { height: 26px; border-radius: 8px; } .funnel .bar > i { border-radius: 8px; }
.warn-box { border: 1px solid rgba(245, 165, 36, .4); background: rgba(245, 165, 36, .08); border-radius: 10px; padding: 10px 14px; color: #ffd28a; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 50; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.toast.err { border-color: var(--err); color: #ffb3c0; }
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
svg.chart text { fill: var(--muted); font-size: 11px; } svg.chart .grid line { stroke: var(--line); } svg.chart .tip { pointer-events: none; }
.chart-wrap { position: relative; } .chart-tip { position: absolute; pointer-events: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .82rem; white-space: nowrap; transform: translate(-50%, -110%); z-index: 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.login { max-width: 420px; margin: 14vh auto; text-align: center; display: grid; gap: 16px; padding: 0 16px; }
.login .card { padding: 28px; display: grid; gap: 14px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .18s; box-shadow: 12px 0 40px rgba(0, 0, 0, .5); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .cols, .cols.even { grid-template-columns: 1fr; }
  .content { padding: 16px; } .top { padding: 10px 16px; }
  .funnel .stage { grid-template-columns: 90px 1fr 56px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* feed, abituali, analisi */
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--err); color: #fff; font-size: .72rem; font-weight: 800; text-align: center; line-height: 20px; }
.badge[hidden] { display: none; }
.feed .it.unread { background: rgba(145, 70, 255, .08); box-shadow: inset 3px 0 0 var(--accent); }
.feed.tall { max-height: none; }
.feed .it .right { display: inline-flex; align-items: center; gap: 10px; }
.feed a.who { color: var(--text); text-decoration: none; } .feed a.who:hover { text-decoration: underline; }
.sep { display: flex; align-items: center; gap: 12px; padding: 6px 14px; color: var(--accent); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--accent); opacity: .5; }
.more { padding: 12px 14px; text-align: center; } .more:empty { display: none; }
.banner { display: block; padding: 10px 14px; border-radius: var(--r); background: rgba(145, 70, 255, .14); border: 1px solid rgba(145, 70, 255, .5); color: var(--text); text-decoration: none; font-weight: 700; margin-bottom: 14px; }
.big { font-size: 1.15rem; font-weight: 800; margin: 4px 0 10px; }
.modal.wide { max-width: 640px; width: 100%; } .modal.wide .feed { max-height: 50vh; }
.tabs + .card { margin-top: 14px; }
.funnel.wide .stage { display: block; } .funnel.wide .sh { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.funnel.wide .sh b { font-weight: 700; color: var(--muted); font-size: .85rem; } .funnel.wide .bar { height: 12px; }
