:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --line: #e6e8ec; --line-strong: #d5d9e0;
  --text: #101318; --text-2: #4f5663; --muted: #7b8392;
  --accent: #2a78d6; --accent-soft: #e6f0fc; --on-accent: #fff;
  --good: #18864b; --good-soft: #e3f4ea; --warn: #a86400; --warn-soft: #fdf1dc; --bad: #c0352b; --bad-soft: #fbe6e4;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6;
  --shadow: 0 1px 2px rgba(16, 19, 24, .04), 0 4px 16px rgba(16, 19, 24, .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f13; --surface: #16191f; --surface-2: #1b1f26; --line: #252a33; --line-strong: #323844;
    --text: #eef0f4; --text-2: #b8bfcc; --muted: #828b9b;
    --accent: #3987e5; --accent-soft: #16263d; --on-accent: #fff;
    --good: #4cc386; --good-soft: #12291d; --warn: #f0a640; --warn-soft: #2d2213; --bad: #ff6b5e; --bad-soft: #321816;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f13; --surface: #16191f; --surface-2: #1b1f26; --line: #252a33; --line-strong: #323844;
  --text: #eef0f4; --text-2: #b8bfcc; --muted: #828b9b;
  --accent: #3987e5; --accent-soft: #16263d;
  --good: #4cc386; --good-soft: #12291d; --warn: #f0a640; --warn-soft: #2d2213; --bad: #ff6b5e; --bad-soft: #321816;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; }
.num { font-variant-numeric: tabular-nums; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; margin: 0; letter-spacing: -.01em; }
p { margin: 4px 0; }

/* controlli */
label { display: block; margin: 12px 0; font-size: 13px; color: var(--text-2); font-weight: 500; }
input, select { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-weight: 400; }
label.check input { width: auto; margin: 3px 0 0; }
/* regola dei pulsanti: azzurro = si può toccare; grigio = non ancora (manca qualcosa da scegliere o compilare) */
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, opacity .15s; background: var(--accent); color: var(--on-accent); }
button:hover:not(:disabled) { filter: brightness(1.07); }
.primary { background: var(--accent); color: var(--on-accent); }
/* azioni secondarie: azzurro chiaro, sempre riconoscibili come cliccabili */
.ghost, label.button { background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); }
label.button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; }
button:disabled, button:disabled.primary, button:disabled.ghost, button:disabled.danger, button:disabled.soft, button:disabled.soft.bad { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); cursor: not-allowed; filter: none; opacity: 1; }
/* piccoli: azzurri; quelli che tolgono, bloccano o disconnettono: rossi */
.soft { background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); padding: 6px 11px; font-size: 13px; }
.soft.bad, .danger { background: var(--bad); color: #fff; border: 1px solid transparent; }
.seg button.bad { color: var(--bad); }
/* piani: ogni scelta col suo colore, quella attuale piena (non grigia) */
.seg button.plan-premium { color: var(--s7); }
.seg button.plan-advanced { color: var(--warn); }
.seg button.plan-free { color: var(--muted); }
.seg button.plan-premium.on, .seg button.plan-premium.on:disabled { background: var(--s7); color: #fff; opacity: 1; }
.seg button.plan-advanced.on, .seg button.plan-advanced.on:disabled { background: var(--warn); color: #fff; opacity: 1; }
.seg button.plan-free.on, .seg button.plan-free.on:disabled { background: var(--muted); color: #fff; opacity: 1; }
.seg button.bad.on { background: var(--bad); color: #fff; }
.seg button.bad:hover:not(:disabled):not(.on) { background: var(--bad-soft); }
.link { background: none; padding: 0; color: var(--accent); font-weight: 500; }
.wide { width: 100%; justify-content: center; margin-top: 8px; padding: 11px; }

/* accesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card .logo { margin-bottom: 26px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.code { font-size: 26px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; margin: 18px 0 6px; }
#enroll-qr { display: block; width: 200px; height: 200px; margin: 16px auto 8px; background: #fff; border-radius: 12px; padding: 8px; }

.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo em { font-style: normal; font-weight: 500; color: var(--muted); }
.mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; background: linear-gradient(135deg, #2a78d6, #6250d6); }

/* struttura */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: calc(22px + env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); border-right: 1px solid var(--line); background: var(--surface); }
.side .logo { padding: 0 8px; }
/* il menu scorre dentro la barra laterale: logo in alto e profilo in basso restano sempre visibili */
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
nav button { background: none; color: var(--text-2); font-weight: 500; justify-content: flex-start; gap: 10px; padding: 9px 10px; width: 100%; position: relative; white-space: nowrap; text-align: left; }
nav button .label { overflow: hidden; text-overflow: ellipsis; }
nav button svg { width: 18px; height: 18px; flex: none; opacity: .8; }
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.active { background: var(--accent-soft); color: var(--accent); }
nav button.active svg { opacity: 1; }
nav .count { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.me { display: flex; gap: 10px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--line); flex: none; }
.side .logo { flex: none; }
.content { padding: calc(28px + env(safe-area-inset-top)) calc(32px + env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) 32px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }

@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { flex-direction: row; overflow-x: auto; order: 3; flex-basis: 100%; }
  nav button { width: auto; flex: none; }
  .me { border: 0; padding: 0; margin-left: auto; }
  .content { padding: 20px 16px 48px; }
}

/* blocchi */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
/* online: pallino verde accanto al nome (grigio tenue se non online) */
.online-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--line-strong); }
.online-dot.on { background: #22c55e; box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 25%, transparent); }
.pill.premium { background: color-mix(in srgb, var(--s7) 18%, transparent); color: var(--s7); }
.pill.plain::before { display: none; }

.banner { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 16px; }
.banner svg { color: var(--warn); flex: none; margin-top: 2px; width: 20px; height: 20px; }
button svg { width: 16px; height: 16px; flex: none; }

/* tabella */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { max-width: 300px; margin: 0; }
label.sort { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
label.sort select { width: auto; margin: 0; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i, .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.wrap { white-space: normal; min-width: 220px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* grafici */
.alloc { display: flex; gap: 2px; height: 10px; width: 180px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.alloc > span { height: 100%; min-width: 3px; }
.alloc.lg { width: 100%; height: 14px; }
.hbar { display: grid; grid-template-columns: 112px 1fr 52px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cols { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.cols .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.cols .bar { width: 100%; max-width: 38px; background: var(--s1); border-radius: 4px 4px 0 0; min-height: 2px; }
.cols .val { font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cols-x { display: flex; gap: 8px; margin-top: 6px; }
.cols-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 180px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.donut-legend div:last-child { border: 0; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* hub */
.post { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.post:last-child { border-bottom: 0; }
.post .body { flex: 1; min-width: 0; }
.post .meta { font-size: 12.5px; color: var(--muted); }
.post .meta b { color: var(--text); font-weight: 600; }
.post p { white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
.post img { max-width: 240px; max-height: 240px; border-radius: 10px; display: block; margin: 8px 0; border: 1px solid var(--line); }
.quote { border-left: 3px solid var(--line-strong); padding: 6px 12px; margin: 8px 0; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* registro */
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.badge.view { background: var(--accent-soft); color: var(--accent); }
.badge.mod { background: var(--warn-soft); color: var(--warn); }
.badge.legal, .badge.denied { background: var(--bad-soft); color: var(--bad); }
.badge.auth { background: var(--good-soft); color: var(--good); }

/* infrastruttura */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; margin-top: 4px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); margin: 8px 0 0; color: var(--text-2); }
.err { padding: 10px 0; border-bottom: 1px solid var(--line); }
.err:last-child { border: 0; }

/* scheda utente */
.drawer-back { position: fixed; inset: 0; background: rgba(5, 7, 10, .45); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); border-left: 1px solid var(--line); z-index: 21; overflow-y: auto; padding: calc(24px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) 24px; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer .head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.drawer .close { margin-left: auto; }
.drawer section { margin-top: 22px; }
.drawer h2 { margin-bottom: 10px; }

.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 7px; max-width: 260px; box-shadow: var(--shadow); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; max-width: 90vw; z-index: 60; box-shadow: var(--shadow); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: none; color: var(--accent); font-weight: 500; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.seg button:hover:not(:disabled) { background: var(--accent-soft); filter: none; }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg button:disabled { background: none; border: 0; color: var(--muted); }
.hbar { grid-template-columns: minmax(112px, 150px) 1fr 52px; }
a { color: var(--accent); }

.span-all { grid-column: 1 / -1; }
.cols.dense { gap: 3px; }
.cols-x.dense { gap: 3px; }
.cols-x.dense span { overflow: visible; text-overflow: clip; }
.only-mobile { display: none; }
td.lead { font-weight: 500; }

/* iPad: barra laterale più stretta */
@media (min-width: 641px) and (max-width: 1180px) {
  .shell { grid-template-columns: 208px 1fr; }
  .side { padding: calc(20px + env(safe-area-inset-top)) 12px 18px calc(12px + env(safe-area-inset-left)); }
  .content { padding: calc(24px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) 22px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; }
  .kpi .value { font-size: 26px; }
}
.side .logo { white-space: nowrap; }

/* telefoni: intestazione fissa in alto */
@media (max-width: 640px) {
  .side { position: sticky; top: 0; z-index: 10; padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); }
  .shell > * { min-width: 0; }
  nav { min-width: 0; width: calc(100% + 32px); margin: 0 -16px; padding: 0 12px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  nav button { padding: 8px 12px; }
  .me .avatar { width: 30px; height: 30px; font-size: 12px; }
  .me #me-name { display: none; }
  .content { padding: 18px calc(16px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .page-head h1 { font-size: 21px; }
}

/* telefoni */
@media (max-width: 640px) {
  input, select { font-size: 16px; }            /* niente zoom automatico di Safari sui campi */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 23px; overflow-wrap: anywhere; }
  .card { padding: 16px; }
  .grid { gap: 12px; }
  .page-head { margin-bottom: 16px; }
  .page-head p { font-size: 13px; }
  #refresh { padding: 8px 10px; font-size: 0; gap: 0; }
  #refresh svg { width: 18px; height: 18px; }
  .search { max-width: none; }
  .toolbar { gap: 10px; }
  .seg { width: 100%; }
  .seg button { flex: 1; justify-content: center; padding: 7px 4px; }
  .hbar { grid-template-columns: minmax(84px, 38%) 1fr 40px; gap: 8px; font-size: 12.5px; }
  .hbar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cols { height: 130px; }
  .post img { max-width: 100%; }
  .drawer { padding: calc(18px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom)); }
  .auth-card { padding: 26px 20px; }
}

/* iPad verticale e telefoni: tabelle come elenco di schede */
@media (max-width: 860px) {
  .table-wrap { border: 0; background: none; box-shadow: none; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  td { border: 0; padding: 4px 0; white-space: normal; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  td.wrap { min-width: 0; }
  td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  td.lead { display: block; text-align: left; padding-bottom: 8px; }
  td:empty, td.only-desktop { display: none; }
  td .chips { justify-content: flex-end; }
  td .alloc { width: 55%; }
  tr.click:hover td { background: none; }
  .only-mobile { display: inline; }
}
@media (max-width: 640px) { .kv dd { overflow-wrap: anywhere; } }

/* dispositivi fidati */
.remember { margin-top: 16px; font-size: 13px; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device:last-child { border-bottom: 0; }
.device .body { flex: 1; min-width: 0; }
.device-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.device-icon.off { background: var(--surface-2); color: var(--muted); }
.device-icon svg { width: 20px; height: 20px; }
.trust-form button { margin-top: 4px; }

/* ---------- iPhone: intestazione compatta e barra delle sezioni in basso, come un'app iOS ---------- */
.tabbar { display: none; }
@media (max-width: 640px) {
  body { -webkit-tap-highlight-color: transparent; }
  .side { flex-wrap: nowrap; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; gap: 10px; }
  .side nav#nav { display: none; }
  .side .logo { font-size: 15px; gap: 8px; padding: 0; }
  .side .logo .mark { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
  .me { gap: 0; }
  .me .link, .me #me-name { display: none; }
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
    border-top: 1px solid var(--line); }
  .tabbar.hidden { display: none !important; }
  .tabbar button { flex: 1; min-width: 0; flex-direction: column; gap: 3px; padding: 6px 0 2px; background: none; color: var(--muted); font-size: 10.5px; font-weight: 500; border-radius: 0; }
  .tabbar button > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .ic { position: relative; display: grid; place-items: center; width: 44px; height: 28px; border-radius: 14px; transition: background .15s; }
  .tabbar .ic svg { width: 22px; height: 22px; }
  .tabbar button.active { color: var(--accent); font-weight: 600; }
  .tabbar button.active .ic { background: var(--accent-soft); }
  .tabbar .count { position: absolute; top: -3px; right: 2px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 99px; }

  .sheet-back { position: fixed; inset: 0; background: rgba(5, 7, 10, .45); z-index: 30; }
  /* pannello «Altro»: mai più alto dello schermo, scorre al suo interno, si chiude trascinandolo in giù o con la X */
  .sheet { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 31; background: var(--surface-2); border-radius: 22px; padding: 6px 12px 12px; box-shadow: 0 -10px 40px rgba(0, 0, 0, .35); animation: up .22s ease-out;
    max-height: calc(100dvh - 70px - env(safe-area-inset-top)); display: flex; flex-direction: column; touch-action: pan-y; transition: transform .18s ease-out; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px; flex: none; touch-action: none; }
  .sheet-head h3 { margin: 0; font-size: 15px; }
  .sheet-close { background: var(--accent-soft); color: var(--accent); width: 32px; height: 32px; padding: 0; border-radius: 99px; justify-content: center; }
  .sheet-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
  /* sezioni in due colonne: stanno tutte su uno schermo */
  .sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
  .sheet-grid button { background: var(--surface); color: var(--text); font-weight: 500; font-size: 14px; padding: 11px 10px; gap: 9px; border-radius: 14px; justify-content: flex-start; text-align: left; min-height: 52px; }
  .sheet-grid button.active { color: var(--accent); outline: 1.5px solid var(--accent); }
  .sheet-grid .count { margin-left: auto; }
  body.sheet-open { overflow: hidden; }
  @keyframes up { from { transform: translateY(30px); opacity: 0; } }
  .grabber { width: 38px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 4px auto 8px; flex: none; touch-action: none; }
  .sheet-list { background: var(--surface); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
  .sheet-list:last-child { margin-bottom: 0; }
  .sheet-list button { width: 100%; background: none; color: var(--text); font-weight: 500; font-size: 16px; padding: 13px 14px; gap: 12px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .sheet-list button:last-child { border-bottom: 0; }
  .sheet-list button.active { color: var(--accent); }
  .sheet-list button > svg { width: 18px; height: 18px; color: var(--muted); }
  .sheet-list .grow { flex: 1; text-align: left; }
  .sheet-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
  .sheet-ic svg { width: 17px; height: 17px; }
  .danger-text { color: var(--bad) !important; }
  .danger-text .sheet-ic { background: var(--bad-soft); color: var(--bad); }

  /* proporzioni */
  .page-head { align-items: center; }
  .page-head h1 { font-size: 26px; letter-spacing: -.025em; }
  .page-head p { display: none; }
  .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi .label { font-size: 12px; }
  .kpi .value { font-size: 26px; }
  .card { border-radius: 16px; }
  .card-head h2 { font-size: 16px; }
  .banner { font-size: 13px; padding: 12px 14px; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

.launch-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.launch-form label { flex: 1; min-width: 180px; margin: 0; }
.launch-form button { margin: 0; }
@media (max-width: 640px) {
  .card-head { flex-wrap: wrap; row-gap: 2px; }
  .card-head > .muted.small { flex-basis: 100%; }
  .cols, .cols-x { gap: 4px; }
  .cols-x span { font-size: 10px; overflow: visible; text-overflow: clip; }
  .cols .val { font-size: 10.5px; }
}

.pill.full { background: var(--accent-soft); color: var(--accent); }
.pill.lite { background: color-mix(in srgb, var(--s7) 18%, transparent); color: var(--s7); }
.per-app { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.pill.lite { background: color-mix(in srgb, var(--s7) 18%, transparent); color: var(--s7); }
body.viewer .owner-only { display: none !important; }

/* assistenza */
.post.click { cursor: pointer; }
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.bubble { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.bubble.ai { align-self: flex-end; background: color-mix(in srgb, var(--s7) 16%, var(--surface)); }
.bubble.agent { align-self: flex-end; background: var(--accent-soft); }
.bubble.system { align-self: center; max-width: 95%; background: none; color: var(--muted); font-size: 12.5px; text-align: center; padding: 2px 8px; }
.bubble .who { color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.bubble .when { color: var(--muted); font-size: 11px; margin-top: 4px; }
.reply-box { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
textarea.reply { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; resize: vertical; }
@media (max-width: 640px) { textarea.reply { font-size: 16px; } }

.dev-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dev-card .body { flex: 1; min-width: 220px; }
a.button-link { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; background: var(--accent); color: var(--on-accent); }
