/* ============================================================
   Command Center Adadò
   Stesso sistema visivo della dashboard Concierge (Live Feedback):
   Instrument Serif per nomi e numeri, Archivo per il testo,
   blu petrolio profondo, colore solo dove indica uno stato.
   Un'impaginazione per ogni schermo: Mac, iPad, iPhone, TV 16:9.
   ============================================================ */

@font-face { font-family: Archivo; src: url('../../dashboard-next/assets/archivo-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: Instrument; src: url('../../dashboard-next/assets/instrument-serif-latin.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #0b1c23;
  --bg-deep: #081419;
  --surface: #12262e;
  --surface-2: #162d36;
  --raised: #1f3b44;
  --ink: #f2f3ec;
  --muted: #9fb4b8;
  --faint: #869ea3;
  --line: #24404a;
  --line-strong: #345561;
  --accent: #ff9b69;
  --accent-ink: #1a0d06;
  --good: #9ad5be;
  --warm: #f1c279;
  --bad: #ffaaa1;
  --info: #9ec9e2;
  --off: #6f878c;
  --fam-ops: #9ec9e2;
  --fam-vik: #e5a0a6;
  --fam-bkg: #8fb3f0;
  --fam-abn: #ff9f8f;
  --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 18px 40px -24px rgb(0 0 0 / .7);
  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.22, 1.2, .36, 1);
  --serif: Instrument, 'Iowan Old Style', Georgia, serif;
  --sans: Archivo, -apple-system, 'Helvetica Neue', sans-serif;
  --pad: clamp(16px, 3vw, 36px);
  color-scheme: dark;
}

[data-theme="ivory"] {
  --bg: #f1eee6;
  --bg-deep: #e9e5db;
  --surface: #fbf9f3;
  --surface-2: #f6f3eb;
  --raised: #e8e4d9;
  --ink: #172e34;
  --muted: #4f666b;
  --faint: #5c6f72;
  --line: #ddd8cc;
  --line-strong: #bfc7c3;
  --accent: #b2471a;
  --accent-ink: #fff6ef;
  --good: #1b6850;
  --warm: #8a5f12;
  --bad: #a83329;
  --info: #1f5b7a;
  --off: #8b9a9c;
  --fam-ops: #1f5b7a;
  --fam-vik: #8e2c3a;
  --fam-bkg: #1d4f9c;
  --fam-abn: #c2412f;
  --shadow: 0 1px 2px rgb(23 46 52 / .05), 0 16px 36px -26px rgb(23 46 52 / .35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 520px at 50% -180px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg-deep);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.embed { background: var(--bg); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.app {
  max-width: 1680px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), var(--pad)) max(env(safe-area-inset-right), var(--pad)) max(env(safe-area-inset-bottom), 24px) max(env(safe-area-inset-left), var(--pad));
}

/* ---------------- intestazione ---------------- */

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.brand-word { font: 600 26px/1 var(--sans); letter-spacing: -.02em; color: var(--accent); }
.brand-rule { width: 1px; height: 22px; background: var(--line-strong); }
.brand-name { font: 600 13px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--ink); }
body.embed .brand { display: none; }
body.embed .top { grid-template-columns: 1fr auto; }

.totals { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tot {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 14px;
  box-shadow: var(--shadow);
}
.tot b { color: var(--ink); font-weight: 600; }
.tot, .updated { white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.lvl-ok { --lvl: var(--good); }
.lvl-warn { --lvl: var(--bad); }
.lvl-off { --lvl: var(--off); }
.lvl-unknown { --lvl: var(--warm); }
.tot .dot, .svc .dot { color: var(--lvl); }
.tot.lvl-ok .dot { animation: breathe 2.8s var(--ease) infinite; }

.controls { display: flex; align-items: center; gap: 10px; }
.updated { color: var(--faint); font-size: 13px; min-width: 44px; text-align: right; }
.updated.stale { color: var(--warm); }
.updated.stale::before { content: '● '; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--muted);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--surface); color: var(--ink); }

.seg {
  position: relative; display: inline-grid; grid-template-columns: repeat(3, 52px);
  padding: 4px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  --i: 2;
}
.seg button { position: relative; z-index: 1; height: 32px; border-radius: 999px; color: var(--muted); font-weight: 500; transition: color .2s var(--ease); }
.seg button[aria-checked="true"] { color: var(--accent-ink); }
.seg-thumb {
  position: absolute; top: 4px; left: 4px; width: 52px; height: 32px; border-radius: 999px;
  background: var(--accent);
  transform: translateX(calc(var(--i) * 52px));
  transition: transform .34s var(--ease-spring);
}

/* ---------------- avvisi ---------------- */

.alerts { display: flex; flex-wrap: wrap; gap: 10px; margin: -6px 0 22px; }
.alert {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  padding: 6px 14px 6px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--lvl) 13%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lvl) 35%, transparent);
  text-align: left;
}
.alert img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--raised); }
.alert b { font-weight: 600; }
.alert span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- organigramma ----------------
   Griglia rigida a 6 colonne uguali: riga 1 barre di famiglia, riga 2 card, riga 3
   riquadri. Ogni unita' (card + riquadri) e' una subgrid: tutte le card hanno la stessa
   altezza e tutti i riquadri partono dalla stessa riga. */

.org { --conn: var(--line-strong); --gap: 16px; }

.hero { display: flex; justify-content: center; }
.trunk { width: 2px; height: 28px; margin: 0 auto; background: var(--conn); }

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: auto auto auto;
  column-gap: var(--gap);
  row-gap: 14px;
}
.bar { grid-column: var(--dc); grid-row: var(--dr); }
.unit {
  grid-column: var(--dc); grid-row: var(--dr);
  display: grid; grid-template-rows: subgrid; row-gap: 12px; min-width: 0;
}

/* linee: dal tronco di Giovanni a ogni barra, compensando lo spazio tra le colonne */
.bar { position: relative; }
.bar::before { content: ''; position: absolute; top: -14px; left: calc(var(--gap) / -2); right: calc(var(--gap) / -2); border-top: 2px solid var(--conn); }
.bar::after { content: ''; position: absolute; top: -14px; left: calc(50% - 1px); width: 2px; height: 14px; background: var(--conn); }
.bar.fam-ops::before { left: 50%; }
.bar.fam-abn::before { right: 50%; }

/* ---------------- barre di famiglia ---------------- */

.bar {
  height: 64px; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--fam) 7%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fam) 26%, var(--line));
}
.bar:not(.has-director) { justify-content: center; }
.bar.has-director { cursor: pointer; }
.bar.has-director:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fam) 45%, var(--line)); }
.fam-label {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  font: 600 11.5px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--ink);
}
.fam-label i { width: 8px; height: 8px; border-radius: 3px; background: var(--fam); }
.bar.has-director .fam-label { padding-right: 12px; border-right: 1px solid var(--line-strong); }
.bar-who { display: grid; min-width: 0; line-height: 1.15; }
.bar-who b { font: 400 24px/1 var(--serif); }
.bar-who em { font-style: normal; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-line { margin-left: auto; font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar .pill { flex: none; }
.bar .launch { position: static; flex: none; }
.bar.lvl-warn { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 50%, transparent); }
.fam-ops { --fam: var(--fam-ops); }
.fam-vik { --fam: var(--fam-vik); }
.fam-bkg { --fam: var(--fam-bkg); }
.fam-abn { --fam: var(--fam-abn); }

/* ---------------- card (tutte uguali) ---------------- */

.card {
  --card-bg: var(--surface);
  position: relative; min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  row-gap: 12px;
  padding: 18px 16px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
  cursor: pointer; outline: none;
  transition: transform .28s var(--ease), box-shadow .28s var(--ease);
}
.card::before {
  content: ''; position: absolute; left: 22px; right: 22px; top: 0; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--lvl, var(--line)); opacity: .5;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong); }
.card:focus-visible, .bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.lvl-warn { box-shadow: var(--shadow), inset 0 0 0 1px color-mix(in srgb, var(--bad) 45%, transparent); }
.card.lvl-warn::before { opacity: 1; }
.card.lvl-off { filter: saturate(.3); }
.card.lvl-off .num { color: var(--muted); }

.card-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding-right: 30px; }
.ava { position: relative; display: block; width: 56px; height: 56px; flex: none; border-radius: 50%; }
.ava img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 18%; background: radial-gradient(circle at 50% 35%, var(--raised), var(--surface)); box-shadow: 0 0 0 2px var(--lvl, var(--line)); }
.ava::after { content: ''; position: absolute; right: -1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--lvl, var(--off)); box-shadow: 0 0 0 3px var(--card-bg); }
.lvl-ok .ava::after { animation: breathe 2.8s var(--ease) infinite; }
.lvl-warn .ava::after { animation: alarm 1.2s var(--ease) infinite; }
.ava-sm { width: 40px; height: 40px; }
.ava-sm::after { width: 10px; height: 10px; }
.bar { --card-bg: color-mix(in srgb, var(--fam) 7%, var(--surface)); }

.who { min-width: 0; }
.who h3 { margin: 0; font: 400 30px/1 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role { margin: 5px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--lvl); background: color-mix(in srgb, var(--lvl) 14%, transparent);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.metric { display: grid; gap: 4px; }
.num { font: 400 52px/.9 var(--serif); letter-spacing: -.02em; }
.lbl { color: var(--muted); font-size: 13px; line-height: 1.25; min-height: 1.25em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.details { display: grid; gap: 5px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.details div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.details dt { color: var(--faint); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.details dd { margin: 0; font-weight: 600; font-size: 14px; }

/* riga di stato: due righe fisse, mostra il problema oppure l'ultima operazione */
.line {
  align-self: end; margin: 0;
  font-size: 12.5px; line-height: 1.35; color: var(--faint);
  height: calc(2 * 1.35em);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card.lvl-warn .line, .card.lvl-unknown .line { color: var(--lvl); font-weight: 500; }
.extra:empty { display: none; }

.launch {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  color: var(--faint); box-shadow: inset 0 0 0 1px var(--line);
  transition: color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
.launch svg { width: 16px; height: 16px; }
.launch:hover { color: var(--accent-ink); background: var(--accent); box-shadow: none; }

/* ---------------- riquadri (sottoagenti, corsie, flussi): tutti uguali ---------------- */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 104px; gap: 8px; align-content: start; }
.tile {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 9px; row-gap: 2px; align-content: center;
  padding: 10px 11px; border-radius: 14px; min-width: 0;
  background: color-mix(in srgb, var(--raised) 42%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: left;
}
.tile-face { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: var(--raised); display: grid; place-items: center; }
.tile-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; }
.lane-badge { font: 400 20px/1 var(--serif); color: var(--fam-vik); }
.tile-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b { grid-column: 1 / -1; font: 400 28px/1 var(--serif); margin-top: 6px; }
.tile-lbl { grid-column: 1 / -1; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-face + .tile-name { align-self: center; grid-row: span 2; }

/* flussi di Giovanni: stessi riquadri, in riga dentro la sua card */
.card-hero .extra { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.tile-svc { grid-template-columns: minmax(0, 1fr); height: 84px; cursor: pointer; }
.tile-svc .tile-name { display: flex; align-items: center; gap: 7px; grid-row: auto; }
.tile-svc .dot { color: var(--lvl); }
.tile-svc b { margin-top: 2px; }
.tile-svc:hover { background: var(--raised); }

/* ---------------- Giovanni ---------------- */

.card-hero {
  width: min(960px, 100%);
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto auto;
  column-gap: 24px;
  padding: 22px 24px 18px;
}
.card-hero .card-head { grid-column: 1; grid-row: 1; padding-right: 0; }
.card-hero .ava { width: 92px; height: 92px; }
.card-hero .ava::after { width: 17px; height: 17px; right: 2px; bottom: 4px; }
.card-hero .who h3 { font-size: 46px; }
.card-hero .role { font-size: 14.5px; }
.card-hero > .pill { grid-column: 1; grid-row: 2; margin-left: 104px; margin-top: -12px; }
.card-hero .metric { grid-column: 2; grid-row: 1 / span 2; justify-items: end; text-align: right; align-self: center; margin-right: 34px; }
.card-hero .num { font-size: 76px; }
.card-hero .lbl { font-size: 14px; }
.card-hero .details { grid-column: 1 / -1; grid-row: 3; display: flex; gap: 28px; }
.card-hero .details div { justify-content: flex-start; }
.card-hero .extra { grid-column: 1 / -1; grid-row: 4; }
.card-hero .line { display: none; }

/* ---------------- scheda di dettaglio ---------------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(3 10 13 / .5); opacity: 0; transition: opacity .26s var(--ease); backdrop-filter: blur(2px); }
.sheet {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  overflow-y: auto; overscroll-behavior: contain;
  padding: max(env(safe-area-inset-top), 24px) 26px max(env(safe-area-inset-bottom), 28px);
  background: var(--bg); box-shadow: -30px 0 60px -30px rgb(0 0 0 / .6), inset 1px 0 0 var(--line);
  transform: translateX(104%); transition: transform .34s var(--ease);
}
body.sheet-open .sheet { transform: none; }
body.sheet-open .sheet-backdrop { opacity: 1; }

.sheet-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; }
.sheet-ava { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; object-position: 50% 18%; background: var(--raised); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--lvl); }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.sheet-head h2 { margin: 0 0 8px; font: 400 42px/1 var(--serif); }
.sheet-close { align-self: start; }
.sheet-blurb { color: var(--muted); margin: 18px 0 0; }
.sheet-reason { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--lvl) 12%, transparent); }

.wtable { width: 100%; border-collapse: collapse; margin: 22px 0 6px; font-size: 14px; }
.wtable th { font: 600 11.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); text-align: right; padding: 0 0 10px; width: 64px; }
.wtable th.on { color: var(--accent); }
.wtable td { padding: 9px 0; border-top: 1px solid var(--line); color: var(--muted); }
.wtable td.tnum { text-align: right; color: var(--ink); }
.wtable td.on { font-weight: 600; }
.wtable tr.main td:first-child { color: var(--ink); font-weight: 600; }

.work { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.work h3 { margin: 0 0 14px; font: 400 28px/1.1 var(--serif); }
.ai-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-pick button { padding: 7px 12px; border-radius: 999px; font-size: 13.5px; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); transition: all .16s var(--ease); }
.ai-pick button[aria-checked="true"] { color: var(--accent-ink); background: var(--accent); box-shadow: none; font-weight: 600; }
.launch-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 13px;
  font-weight: 600; font-size: 14.5px; text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn:hover { filter: brightness(1.06); }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--faint); }
.cmds { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.cmd-head { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.cmd-head b { color: var(--ink); font-weight: 600; font-size: 14px; }
.cmd-head a { margin-left: auto; font-size: 13px; color: var(--accent); text-decoration: none; }
.cmd-hint { margin: 3px 0 0 26px; font-size: 12.5px; color: var(--faint); }
.cmd { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 4px 4px 14px; border-radius: 12px; background: var(--bg-deep); box-shadow: inset 0 0 0 1px var(--line); }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 8px 0; font: 12.5px/1.4 ui-monospace, 'SF Mono', Menlo, monospace; color: var(--ink); scrollbar-width: none; }
.cmd code::-webkit-scrollbar { display: none; }

.toast {
  position: fixed; left: 50%; bottom: max(env(safe-area-inset-bottom), 24px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px;
  transition: all .26s var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.foot { margin: 26px 0 0; text-align: center; font-size: 12.5px; color: var(--faint); }

/* ---------------- accesso (stessa scheda della dashboard) ---------------- */

.login-wrap, .login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; padding: 30px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.login-brand { width: 200px; height: auto; }
.login-sub { margin: 0; color: var(--muted); line-height: 1.5; }
.login-field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.login-field input { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg-deep); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; }
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-error { margin: 0; color: var(--bad); }
.login-error:empty { display: none; }
.login-card .btn.primary { justify-content: center; border: 0; cursor: pointer; }



/* ---------------- iPad e finestre medie: 2 colonne ---------------- */

@media (max-width: 1180px) {
  .top { grid-template-columns: 1fr auto; row-gap: 14px; }
  .totals { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; }
  .bar, .unit { grid-column: var(--tc); grid-row: var(--tr); }
  .bar::before, .bar::after, .trunk { display: none; }
  .bar { margin-top: 12px; }
  .hero { margin-bottom: 8px; }
}

/* ---------------- iPhone: una colonna ---------------- */

@media (max-width: 700px) {
  body { font-size: 14.5px; }
  .top { grid-template-columns: 1fr auto; }
  .brand-word { font-size: 22px; }
  .brand-name { font-size: 11px; letter-spacing: .18em; }
  .updated, #tvBtn { display: none; }
  .seg { grid-template-columns: repeat(3, 46px); }
  .seg button { height: 30px; font-size: 14px; }
  .seg-thumb { width: 46px; height: 30px; transform: translateX(calc(var(--i) * 46px)); }

  .grid { display: flex; flex-direction: column; gap: 12px; }
  .unit { display: grid; grid-template-rows: auto auto; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 92px; }
  .tile { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: 8px 4px; }
  .tile-face { grid-row: auto; }
  .tile-face + .tile-name { grid-row: auto; }
  .tile b { font-size: 22px; margin-top: 2px; }
  .tile-lbl { display: none; }
  .tiles:empty { display: none; }
  .bar { height: 58px; }
  .bar-line, .bar .pill { display: none; }
  .bar .launch { margin-left: auto; }
  .card:hover { transform: none; }

  .card-hero { grid-template-columns: minmax(0, 1fr); padding: 18px 16px 14px; }
  .card-hero .ava { width: 72px; height: 72px; }
  .card-hero .who h3 { font-size: 38px; }
  .card-hero > .pill { grid-row: 2; margin: 0; }
  .card-hero .metric { grid-column: 1; grid-row: 3; justify-items: start; text-align: left; margin: 0; }
  .card-hero .num { font-size: 60px; }
  .card-hero .details { grid-row: 4; flex-wrap: wrap; gap: 6px 18px; }
  .card-hero .extra { grid-row: 5; grid-template-columns: 1fr; }
  .tile-svc { height: auto; }
  .alert span { max-width: 60vw; }
  .sheet { width: 100vw; top: auto; max-height: 92dvh; border-radius: 24px 24px 0 0; transform: translateY(104%); padding-top: 22px; }
  .sheet-ava { width: 68px; height: 68px; }
  .sheet-head h2 { font-size: 34px; }
}

/* ---------------- schermo TV 16:9 (AirPlay) ----------------
   Palco fisso 1920x1080 scalato allo schermo: sul televisore non scorre nulla. */

body.tv { overflow: hidden; background: var(--bg-deep); }
/* zoom e non transform: il browser ridisegna testo e volti alla risoluzione vera dello
   schermo invece di ingrandire un'immagine gia' disegnata (testo sfocato sulla TV) */
body.tv { display: grid; place-items: center; height: 100dvh; }
body.tv .app {
  width: 1920px; height: 1080px; max-width: none; margin: 0;
  padding: 40px 56px 26px;
  zoom: var(--tv-scale, 1);
  display: flex; flex-direction: column;
}
body.tv.cursor-hidden, body.tv.cursor-hidden * { cursor: none !important; }
body.tv .top { margin-bottom: 14px; }
body.tv .brand-word { font-size: 32px; }
body.tv .brand-name { font-size: 15px; }
body.tv #themeBtn, body.tv .launch { display: none; }
body.tv .updated { font-size: 22px; color: var(--muted); }
body.tv .tot { font-size: 17px; padding: 9px 16px; }
body.tv .alerts { margin: 0 0 12px; justify-content: center; }
body.tv .alert { font-size: 17px; }
body.tv .card, body.tv .bar { cursor: default; }
body.tv .card:hover { transform: none; }
body.tv .card-head { padding-right: 0; }
body.tv .card-hero { padding: 16px 24px 14px; row-gap: 10px; }
body.tv .card-hero .ava { width: 80px; height: 80px; }
body.tv .card-hero > .pill { margin-left: 92px; }
body.tv .card-hero .num { font-size: 68px; }
body.tv .card-hero .metric { margin-right: 0; }
body.tv .card-hero .extra { padding-top: 10px; }
body.tv .tile-svc { height: 74px; }
body.tv .trunk { height: 22px; }
body.tv .card { padding: 14px 16px 12px; row-gap: 10px; }
body.tv .num { font-size: 48px; }
body.tv .tiles { grid-auto-rows: 88px; }
body.tv .foot { margin-top: auto; font-size: 15px; }
body.tv #tvBtn { opacity: 0; transition: opacity .3s; }
body.tv:not(.cursor-hidden) #tvBtn { opacity: 1; }

/* riquadro nella dashboard */
body.embed #themeBtn { display: none; }
body.embed .app { padding-top: 14px; }

/* ---------------- animazioni ---------------- */

@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 3px var(--card-bg, var(--surface)), 0 0 0 3px color-mix(in srgb, var(--lvl) 0%, transparent); } 50% { box-shadow: 0 0 0 3px var(--card-bg, var(--surface)), 0 0 0 7px color-mix(in srgb, var(--lvl) 24%, transparent); } }
.tot.lvl-ok .dot { animation: breathe-dot 2.8s var(--ease) infinite; }
@keyframes breathe-dot { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lvl) 0%, transparent); } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--lvl) 25%, transparent); } }
@keyframes alarm { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.sheet { overflow-x: hidden; }
.cmds li { min-width: 0; }

/* rifiniture: tasto in basso a destra, barre senza riga di sessione, riquadri piu' alti */
.card-head { padding-right: 0; }
.card > .launch { top: auto; bottom: 12px; right: 12px; }
.card > .line { padding-right: 40px; }
.card-hero > .launch { bottom: auto; top: 14px; }
.bar-line { display: none; }
.bar .pill { margin-left: auto; }
.bar-who em { overflow: visible; }
.tiles { grid-auto-rows: 112px; }
.tile { padding: 10px 11px 12px; }
.alerts { justify-content: center; }
body.tv .tiles { grid-auto-rows: 96px; }
body.tv .card-hero .details { display: none; }
body.tv .tile-svc { height: 86px; }
body.tv .tiles { grid-auto-rows: 104px; }
body.tv .foot { margin-top: auto; padding-top: 8px; }
body.tv .tile { padding: 8px 11px; }
body.tv .tile-face { width: 28px; height: 28px; }
body.tv .tile b { font-size: 25px; margin-top: 4px; }

/* colonne strette (dashboard, finestre medie): ruoli su due righe, riquadri verticali */
.card:not(.card-hero), .tiles { container-type: inline-size; }
.role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 290px) {
  .tile { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: 8px 6px; row-gap: 1px; }
  .tile-face, .tile-face + .tile-name { grid-row: auto; }
  .tile b { margin-top: 2px; font-size: 24px; }
  .tile-lbl { max-width: 100%; }
  .num { font-size: 46px; }
  .ava { width: 50px; height: 50px; }
  .who h3 { font-size: 27px; }
}

/* TV: testi leggibili da qualche metro (niente sotto i 15 px sul palco 1080p) */
body.tv .role, body.tv .lbl, body.tv .details dt, body.tv .details dd, body.tv .line { font-size: 16px; }
body.tv .line { line-height: 1.3; }
body.tv .who h3 { font-size: 32px; }
body.tv .pill { font-size: 14px; padding: 5px 11px; }
body.tv .fam-label { font-size: 14px; }
body.tv .bar-who b { font-size: 28px; }
body.tv .bar-who em { font-size: 14px; }
body.tv .tile-name { font-size: 15px; }
body.tv .tile-lbl { font-size: 13px; }
body.tv .tile b { font-size: 28px; }
body.tv .tile-svc .tile-name { font-size: 16px; }
body.tv .card-hero .role, body.tv .card-hero .lbl { font-size: 17px; }
body.tv .foot { font-size: 16px; }
body.tv .tot { font-size: 19px; }
body.tv .alert { font-size: 19px; }
body.tv .foot { display: none; }
body.tv .card-hero .who h3 { font-size: 44px; }
body.tv .tiles { grid-auto-rows: 114px; }
body.tv .tile-face { width: 30px; height: 30px; }
body.tv .grid { row-gap: 12px; }
body.tv .unit { row-gap: 10px; }
body.tv .app { padding: 28px 56px 24px; }
body.tv .top { margin-bottom: 10px; }
body.tv .alerts { margin-bottom: 10px; }

/* ============================================================
   Tabellone TV (16:9): palco 1920x1080 ridisegnato alla risoluzione
   dello schermo (zoom), scene a rotazione, nastro delle notizie.
   ============================================================ */

body.tv .app { display: none; }
.tv-root { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--bg-deep); overflow: hidden; }
.tvw {
  position: relative;
  width: 1920px; height: 1080px; zoom: var(--tv-scale, 1);
  display: grid; grid-template-rows: 96px 1fr 64px;
  background:
    radial-gradient(900px 500px at 12% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    radial-gradient(900px 600px at 100% 110%, color-mix(in srgb, var(--fam-bkg) 9%, transparent), transparent 70%),
    var(--bg-deep);
  overflow: hidden;
}

/* intestazione */
.tvw-top { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 36px; padding: 0 56px; border-bottom: 1px solid var(--line); }
.tvw-top .brand-word { font-size: 34px; }
.tvw-top .brand-name { font-size: 15px; }
.tvw-tabs { display: flex; gap: 10px; justify-content: center; }
.tvw-tab { position: relative; display: grid; gap: 8px; min-width: 190px; padding: 10px 18px 12px; border-radius: 14px; color: var(--faint); font: 600 17px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; text-align: left; transition: color .4s var(--ease), background .4s var(--ease); }
.tvw-tab.on { color: var(--ink); background: var(--surface); }
.tvw-tab i { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.tvw-tab b { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.tvw-status { display: flex; gap: 10px; }
.tvw-status .tot { font-size: 18px; padding: 9px 15px; }
.tvw-status .tot.hot { animation: hot 1.6s var(--ease) infinite; }
.tvw-clock { display: grid; justify-items: end; line-height: 1; }
.tvw-clock b { font: 400 50px/1 var(--serif); font-variant-numeric: tabular-nums; }
.tvw-clock span { margin-top: 4px; font-size: 15px; color: var(--faint); text-transform: capitalize; }

/* palco e scene */
.tvw-stage { position: relative; overflow: hidden; }
.scene { position: absolute; inset: 0; padding: 26px 56px 18px; opacity: 0; visibility: hidden; transform: translateX(60px); transition: opacity .8s var(--ease), transform .9s var(--ease), visibility 0s .9s; }
.scene.on { opacity: 1; visibility: visible; transform: none; transition: opacity .8s var(--ease) .15s, transform .9s var(--ease) .15s, visibility 0s; }
.scene.leave { transform: translateX(-60px); }
.scene > div { height: 100%; }
.scene-empty { display: grid; place-items: center; height: 100%; font: 400 44px/1.2 var(--serif); color: var(--faint); }

/* Squadra: l'organigramma entra nella scena */
.scene-team .org { height: 100%; display: flex; flex-direction: column; }
.scene-team .hero { flex: none; }

/* Manutenzioni */
.scene-maint { display: grid; grid-template-rows: auto 1fr auto; gap: 22px; }
.mcounters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.mcount { display: grid; gap: 6px; padding: 18px 24px; border-radius: 22px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.mcount b { font: 400 92px/.9 var(--serif); }
.mcount span { font-size: 19px; color: var(--muted); }
.mc-toTake b { color: var(--warm); }
.mc-resolvedToday b { color: var(--good); }
.mc-alarms.hot { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--bad) 60%, transparent); animation: hot 1.6s var(--ease) infinite; }
.mc-alarms.hot b { color: var(--bad); }
.mcols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; min-height: 0; }
.mcol { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; min-height: 0; }
.mcol h3 { display: flex; align-items: center; gap: 12px; margin: 0; font: 600 16px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.mcol h3 b { font: 400 30px/1 var(--serif); letter-spacing: 0; color: var(--ink); }
.mcol-list { display: grid; grid-auto-rows: min-content; gap: 10px; min-height: 0; overflow: hidden; }
.job { position: relative; display: grid; gap: 6px; padding: 13px 18px 13px 22px; border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.job::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--prio); }
.job.p3 { --prio: var(--bad); } .job.p2 { --prio: var(--warm); } .job.p1 { --prio: var(--info); }
.job header { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--faint); }
.job .prio { color: var(--prio); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.job .where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job h4 { margin: 0; font: 500 21px/1.2 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job footer { display: flex; gap: 14px; font-size: 15px; color: var(--muted); }
.job .tech { color: var(--ink); font-weight: 600; }
.job.alarm { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--bad) 50%, transparent); }
.job .why { margin: 0; font-size: 15px; font-weight: 600; color: var(--bad); }
.mcol-resolved .job { opacity: .8; }
.mcol .more, .mcol .empty { margin: 0; font-size: 16px; color: var(--faint); }
.mtechs { display: flex; gap: 14px; flex-wrap: wrap; }
.mtech { display: inline-flex; align-items: baseline; gap: 12px; padding: 10px 18px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 16px; }
.mtech b { font: 400 24px/1 var(--serif); }
.mtech em { font-style: normal; color: var(--muted); }

/* Recensioni */
.scene-reviews { display: grid; grid-template-columns: 470px 1fr 620px; gap: 34px; }
.scene-reviews h3, .scene-reviews h4 { margin: 0 0 14px; font: 600 16px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.rleft { display: grid; grid-template-rows: auto auto 1fr; gap: 22px; min-height: 0; }
.rtoday { display: grid; gap: 4px; padding: 24px 28px; border-radius: 26px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.rtoday span { font-size: 18px; color: var(--muted); }
.rtoday b { font: 400 150px/.9 var(--serif); color: var(--tone, var(--ink)); }
.rtoday small { font-size: 18px; color: var(--faint); }
.good { --tone: var(--good); } .warm { --tone: var(--warm); } .bad { --tone: var(--bad); }
.rperiods { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rperiod { display: grid; gap: 2px; padding: 16px 20px; border-radius: 20px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.rperiod span { font-size: 16px; color: var(--muted); }
.rperiod b { font: 400 58px/1 var(--serif); color: var(--tone, var(--ink)); }
.rperiod small { font-size: 15px; color: var(--faint); }
.delta { font-style: normal; font-weight: 600; margin-left: 6px; }
.delta.up, .rtrend .up { color: var(--good); } .delta.down, .rtrend .down { color: var(--bad); }
.rcompl { min-height: 0; }
.rbar { display: grid; grid-template-columns: 150px 1fr 40px; align-items: center; gap: 14px; margin-bottom: 10px; font-size: 17px; color: var(--muted); }
.rbar i { height: 10px; border-radius: 10px; background: var(--raised); position: relative; overflow: hidden; }
.rbar i::after { content: ''; position: absolute; inset: 0; width: calc(var(--p) * 100%); border-radius: inherit; background: var(--bad); }
.rbar b { text-align: right; color: var(--ink); }
.rmid { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; padding: 26px 30px; border-radius: 26px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.rspark { color: var(--tone, var(--info)); min-height: 0; }
.spark { width: 100%; height: 100%; }
.spark-line { stroke-dasharray: 4000; stroke-dashoffset: 4000; animation: draw 2.4s var(--ease) forwards; }
.scene:not(.on) .spark-line { animation: none; }
.spark-dot { animation: breathe-svg 2.4s var(--ease) infinite; transform-box: fill-box; transform-origin: center; }
.rtrend { margin: 12px 0 0; font-size: 20px; color: var(--muted); }
.rtrend b { font: 400 34px/1 var(--serif); color: var(--ink); }
.rright { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.rstack { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: hidden; }
.rcard {
  display: grid; gap: 12px; padding: 20px 24px; border-radius: 24px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .6s var(--ease), box-shadow .6s var(--ease), opacity .6s var(--ease);
  opacity: .6;
}
.rcard.front { opacity: 1; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--tone, var(--line)) 55%, transparent); animation: rise .7s var(--ease); }
.rcard.gone { display: none; }
.rcard header { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.rscore { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; font: 400 38px/1 var(--serif); color: var(--accent-ink); background: var(--tone, var(--muted)); }
.rcard.front .rscore { width: 78px; height: 78px; font-size: 46px; }
.rcard header b { display: block; font: 400 28px/1.1 var(--serif); }
.rcard header div span { font-size: 15px; color: var(--faint); }
.rcard p { margin: 0; font-size: 19px; line-height: 1.4; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.rcard.front p { font-size: 23px; color: var(--ink); -webkit-line-clamp: 5; }
@keyframes rise { from { transform: translateY(18px); } to { transform: none; } }
.rdots { display: flex; gap: 8px; justify-content: center; padding-top: 12px; }
.rdots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); transition: all .4s var(--ease); }
.rdots i.on { width: 28px; border-radius: 9px; background: var(--accent); }
.scene-reviews .empty { font-size: 18px; color: var(--faint); }

/* nastro delle notizie */
.tvw-ticker { display: grid; grid-template-columns: auto 1fr; align-items: center; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); overflow: hidden; }
.ticker-tag { display: inline-flex; align-items: center; gap: 10px; height: 100%; padding: 0 22px 0 56px; font: 700 15px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); background: var(--bg-deep); box-shadow: 18px 0 24px -6px var(--bg-deep); position: relative; z-index: 1; }
.ticker-tag i { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: blink 1.4s var(--ease) infinite; }
.ticker-win { overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.ticker-track { display: inline-flex; animation: ticker var(--dur, 60s) linear infinite; }
.ticker-run { display: inline-flex; align-items: center; gap: 22px; padding-right: 22px; }
.ti { font-size: 21px; color: var(--muted); }
.ti b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.ti.bad, .ti.bad b { color: var(--bad); }
.sep { font-style: normal; font-size: 12px; color: var(--accent); opacity: .7; }

.tvw-exit { position: absolute; right: 18px; bottom: 76px; padding: 8px 14px; border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 14px; opacity: 0; transition: opacity .3s; }
body.tv:not(.cursor-hidden) .tvw-exit { opacity: 1; }

.bump { animation: bump .9s var(--ease); }
@keyframes bump { 0% { color: inherit; } 30% { color: var(--accent); transform: scale(1.06); } 100% { transform: none; } }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes hot { 0%, 100% { box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--bad) 60%, transparent); } 50% { box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--bad) 20%, transparent), 0 0 34px -6px color-mix(in srgb, var(--bad) 60%, transparent); } }
@keyframes breathe-svg { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------------- TV leggibile: palco 1600x900 (tutto +20% sullo schermo) e meno contenuto ---------------- */
.tvw { width: 1600px; height: 900px; grid-template-rows: 84px 1fr 58px; }
.tvw-top { gap: 24px; padding: 0 36px; }
.tvw-top .brand-word { font-size: 30px; }
.tvw-top .brand-name { display: none; }
.tvw-tab { min-width: 150px; padding: 9px 14px 11px; font-size: 17px; }
.tvw-status .tot { font-size: 18px; padding: 8px 14px; }
.tvw-clock b { font-size: 46px; }
.tvw-clock span { font-size: 15px; }
.scene { padding: 18px 36px 12px; }
.ticker-tag { padding-left: 36px; font-size: 15px; }
.ti { font-size: 22px; }

/* Squadra in TV: nome, stato e numero; i dettagli restano nella web app */
body.tv .scene-team .details,
body.tv .scene-team .tile-lbl,
body.tv .scene-team .card-hero .details { display: none; }
body.tv .scene-team .card { row-gap: 8px; padding: 12px 14px 10px; }
body.tv .scene-team .num { font-size: 50px; }
body.tv .scene-team .lbl { font-size: 17px; }
body.tv .scene-team .role { font-size: 16px; }
body.tv .scene-team .line { font-size: 16px; }
body.tv .scene-team .who h3 { font-size: 32px; }
body.tv .scene-team .tiles { grid-auto-rows: 92px; }
body.tv .scene-team .tile-name { font-size: 16px; }
body.tv .scene-team .tile b { font-size: 28px; }
body.tv .scene-team .bar { height: 58px; }
body.tv .scene-team .bar-who b { font-size: 28px; }
body.tv .scene-team .fam-label { font-size: 15px; }
body.tv .scene-team .card-hero { width: 980px; padding: 14px 22px 12px; }
body.tv .scene-team .tile-svc { height: 80px; }
body.tv .scene-team .tile-svc .tile-name { font-size: 17px; }
body.tv .scene-team .tile-svc .tile-lbl { display: none; }
body.tv .scene-team .trunk { height: 16px; }

/* Manutenzioni in TV */
.scene-maint { gap: 16px; }
.mcounters { gap: 12px; }
.mcount { padding: 12px 20px; }
.mcount b { font-size: 76px; }
.mcount span { font-size: 19px; }
.mcols { gap: 16px; }
.mcol h3 { font-size: 17px; }
.job { padding: 12px 16px 12px 20px; }
.job header { font-size: 15px; }
.job h4 { font-size: 23px; }
.job footer, .job .why { font-size: 17px; }
.mtech { font-size: 17px; padding: 8px 16px; }

/* Recensioni in TV */
.scene-reviews { grid-template-columns: 380px 1fr 500px; gap: 22px; }
.rtoday { padding: 18px 24px; }
.rtoday b { font-size: 128px; }
.rtoday span, .rtoday small { font-size: 19px; }
.rperiod b { font-size: 50px; }
.rperiod span, .rperiod small { font-size: 16px; }
.rbar { grid-template-columns: 130px 1fr 34px; font-size: 18px; }
.rmid { padding: 20px 24px; }
.rtrend { font-size: 20px; }
.rcard { padding: 16px 20px; }
.rcard header b { font-size: 27px; }
.rcard header div span { font-size: 16px; }
.rcard p { font-size: 19px; }
.rcard.front p { font-size: 23px; -webkit-line-clamp: 4; }
.scene-reviews h3, .scene-reviews h4 { font-size: 17px; }
.tvw-top .brand-rule { display: none; }
.tvw-exit { display: none; }
.tvw-controls { position: absolute; right: 20px; bottom: 72px; z-index: 5; display: flex; gap: 10px; opacity: 0; transition: opacity .3s var(--ease); pointer-events: none; }
body.tv:not(.cursor-hidden) .tvw-controls { opacity: 1; pointer-events: auto; }
.tvw-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 600; box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong); }
.tvw-btn:hover { background: var(--accent); color: var(--accent-ink); }
.mcol { grid-template-rows: auto auto auto; align-content: start; }
.rperiod small { white-space: nowrap; font-size: 15px; }

/* transizioni piu' rapide tra le pagine */
.scene { transition: opacity .45s var(--ease), transform .5s var(--ease), visibility 0s .5s; transform: translateX(40px); }
.scene.on { transition: opacity .45s var(--ease) .08s, transform .5s var(--ease) .08s, visibility 0s; }
.scene.leave { transform: translateX(-40px); }

/* ---------------- Escalation in diretta ---------------- */
.scene-esc { display: grid; grid-template-rows: auto 1fr; gap: 16px; }
.ecounters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.ecount { display: grid; gap: 6px; padding: 12px 20px; border-radius: 22px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.ecount b { font: 400 70px/.9 var(--serif); }
.ecount span { font-size: 18px; color: var(--muted); line-height: 1.2; }
.ec-closed b { color: var(--good); }
.ecount.hot { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); animation: hot 1.6s var(--ease) infinite; }
.ecount.hot b { color: var(--bad); }
.ebody { display: grid; grid-template-columns: 1fr 1fr 1.1fr; gap: 16px; min-height: 0; }
.ebody section { display: grid; grid-template-rows: auto 1fr; min-height: 0; padding: 16px 18px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.ebody h3 { margin: 0 0 12px; font: 600 17px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.ebody section > div { display: grid; gap: 10px; align-content: start; }
.eitem { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.eitem b { display: block; font: 400 26px/1.1 var(--serif); }
.eitem span { font-size: 16px; color: var(--muted); }
.eitem em { font: 400 32px/1 var(--serif); font-style: normal; color: var(--warm); }
.eitem.late { background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--bad) 50%, transparent); }
.eitem.late em { color: var(--bad); }
.eitem.urgent b::after { content: ' · urgente'; font: 700 14px/1 var(--sans); color: var(--bad); text-transform: uppercase; letter-spacing: .08em; }
.eclear { display: grid; place-items: center; gap: 8px; height: 100%; min-height: 240px; color: var(--good); }
.eclear b { font: 400 90px/1 var(--serif); }
.eclear span { font-size: 22px; }
.eop { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.eop-ava { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: color-mix(in srgb, var(--info) 22%, var(--surface-2)); font: 400 26px/1 var(--serif); color: var(--info); }
.eop-main { display: grid; gap: 5px; min-width: 0; }
.eop-main b { font-size: 20px; font-weight: 600; }
.eop-main i { height: 8px; border-radius: 8px; background: var(--raised); position: relative; overflow: hidden; }
.eop-main i::after { content: ''; position: absolute; inset: 0; width: calc(var(--p) * 100%); border-radius: inherit; background: var(--good); transition: width .8s var(--ease); }
.eop-main span { font-size: 15px; color: var(--faint); }
.eop strong { font: 400 46px/1 var(--serif); }
.erow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 17px; color: var(--muted); }
.erow em { font-style: normal; color: var(--faint); font-size: 16px; }
.erow b { color: var(--ink); }
.erow div span { color: var(--muted); }
.erow strong { color: var(--good); font-weight: 600; font-size: 16px; white-space: nowrap; }
.erow div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Recensioni e FRS ---------------- */
.scene-frs { display: grid; grid-template-rows: auto 1fr auto; gap: 14px; }
.fkpis { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.fkpi { display: grid; gap: 4px; padding: 12px 20px; border-radius: 22px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.fkpi span { font-size: 17px; color: var(--muted); }
.fkpi b { font: 400 72px/.95 var(--serif); color: var(--tone, var(--ink)); }
.fkpi small { font-size: 16px; color: var(--faint); }
.fk-removed b { color: var(--good); }
.fk-lift { background: color-mix(in srgb, var(--good) 12%, var(--surface)); box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--good) 40%, transparent); }
.fk-lift b { color: var(--good); }
.fbody { display: grid; grid-template-columns: 1fr 440px; gap: 16px; min-height: 0; }
.fbody section { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; padding: 16px 20px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.fbody h3 { margin: 0 0 10px; font: 600 17px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.fchart-svg { min-height: 0; }
.band { width: 100%; height: 100%; }
.band-fill { fill: color-mix(in srgb, var(--good) 26%, transparent); }
.band-avg { fill: none; stroke: var(--good); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 4000; stroke-dashoffset: 4000; animation: draw 1.8s var(--ease) forwards; }
.band-without { fill: none; stroke: var(--bad); stroke-width: 3; stroke-dasharray: 8 7; opacity: .85; }
.band-dot { fill: var(--good); animation: breathe-svg 2.4s var(--ease) infinite; }
.scene:not(.on) .band-avg { animation: none; }
.flegend { display: flex; gap: 26px; margin: 10px 0 0; font-size: 16px; color: var(--muted); }
.flegend span::before { content: ''; display: inline-block; width: 22px; height: 4px; margin-right: 8px; vertical-align: middle; border-radius: 3px; }
.lg-avg::before { background: var(--good); }
.lg-without::before { background: repeating-linear-gradient(90deg, var(--bad) 0 6px, transparent 6px 10px); }
.lg-band::before { height: 12px !important; background: color-mix(in srgb, var(--good) 30%, transparent); }
.fremoved > div { display: grid; gap: 10px; align-content: start; }
.frow { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.fscore { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font: 400 30px/1 var(--serif); color: var(--accent-ink); background: var(--tone, var(--muted)); position: relative; }
.fscore::after { content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 3px; background: var(--accent-ink); opacity: .7; transform: rotate(-12deg); }
.frow b { display: block; font: 400 24px/1.1 var(--serif); }
.frow span { font-size: 15px; color: var(--faint); }
.ffunnel { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.fstep { display: flex; align-items: baseline; gap: 10px; }
.fstep b { font: 400 40px/1 var(--serif); }
.fstep span { font-size: 17px; color: var(--muted); }
.fstep:last-of-type b { color: var(--good); }
.farrow { font-style: normal; font-size: 26px; color: var(--accent); }
.ffunnel::before { content: 'Percorso FRS · 30 giorni'; font: 600 15px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-right: 10px; }
.band path, .band circle { stroke-width: inherit; }
.band-fill { stroke: none; }
.band-dot { stroke: none; }
.frow .fscore { font: 400 30px/1 var(--serif); color: var(--accent-ink); }
.frow div span { font-size: 15px; color: var(--faint); }
.fscore::after { height: 2px; opacity: .45; }
.erow { grid-template-columns: auto 1fr auto; align-items: center; padding: 10px 0; }
.erow div { display: grid; gap: 2px; white-space: normal; }
.erow div b { font-size: 19px; }
.erow div span { font-size: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eop { padding: 4px 0; }

/* ---------------- Economics ---------------- */
.scene-eco { display: grid; grid-template-rows: auto 1fr auto; gap: 14px; }
.xkpis { display: grid; grid-template-columns: 1.3fr 1.2fr 1fr 1fr 1fr; gap: 12px; }
.xkpi { display: grid; gap: 4px; padding: 12px 20px; border-radius: 22px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); min-width: 0; }
.xkpi span { font-size: 17px; color: var(--muted); }
.xkpi b { font: 400 62px/1 var(--serif); white-space: nowrap; }
.xkpi small { font-size: 16px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xk-gross { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); box-shadow: var(--shadow), inset 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.xk-gross b { color: var(--accent); }
.xk-net b { color: var(--good); }
.xbody { display: grid; grid-template-columns: 1fr 520px; gap: 16px; min-height: 0; }
.xbody section { display: grid; grid-template-rows: auto 1fr; min-height: 0; padding: 16px 20px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.xbody h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; font: 600 17px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.xlegend { display: flex; align-items: center; gap: 8px; font-size: 14px; letter-spacing: .04em; text-transform: none; color: var(--faint); }
.xlegend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-left: 12px; }
.lg-net { background: var(--good); }
.lg-com { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.ebars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 10px; align-items: end; min-height: 0; height: 100%; }
.ebar { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; height: 100%; justify-items: center; }
.ebar i { position: relative; width: 100%; align-self: end; height: calc(var(--g) * 100%); border-radius: 8px 8px 3px 3px; background: color-mix(in srgb, var(--accent) 55%, transparent); overflow: hidden; animation: grow .9s var(--ease) both; transform-origin: bottom; }
.ebar i b { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--n) * 100%); background: var(--good); }
.ebar-val { font-size: 14px; color: var(--muted); }
.ebar-day { font-size: 13px; color: var(--faint); white-space: nowrap; }
.ebar.today i { outline: 2px dashed color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.ebar.today .ebar-day { color: var(--accent); font-weight: 700; }
.scene:not(.on) .ebar i { animation: none; }
.xtop { align-content: start; }
.xrow { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.xrow em { font: 400 28px/1 var(--serif); font-style: normal; color: var(--faint); }
.xrow b { display: block; font: 400 25px/1.1 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xrow span { font-size: 15px; color: var(--faint); }
.xrow strong { font: 400 32px/1 var(--serif); color: var(--accent); }
.xplat { display: flex; gap: 12px; }
.xp { position: relative; flex: max(var(--w), .16) 1 0; display: grid; gap: 4px; padding: 12px 18px 16px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; min-width: 0; }
.xp b { font: 400 26px/1 var(--serif); }
.xp span { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp i { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--fam-bkg); }
.xp:nth-child(2) i { background: var(--fam-abn); }
.xp:nth-child(3) i { background: var(--good); }
@keyframes grow { from { transform: scaleY(0); } to { transform: none; } }
/* cinque pagine: intestazione piu' compatta, colonne vincolate al palco */
.tvw-top { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 18px; }
.tvw-tabs { gap: 4px; }
.tvw-tab { min-width: 0; padding: 9px 12px 11px; font-size: 15px; letter-spacing: .05em; }
.tvw-status { gap: 8px; }
.tvw-status .tot { font-size: 16px; padding: 7px 12px; }
.tvw-status .tot.lvl-ok { display: none; }
.tvw-clock b { font-size: 42px; }
.xkpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.xkpi b { font-size: 54px; }
.xbody { grid-template-columns: minmax(0, 1fr) 470px; }
.xtop { display: block !important; }
.xrow strong { white-space: nowrap; font-size: 30px; }
.fkpis, .ecounters, .mcounters { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.xp { flex: max(var(--w), .27) 1 0; }

/* Squadra: il tratto tra Giovanni e le famiglie non si schiaccia mai (sovrapposizione) */
.scene-team .trunk, .scene-team .grid, .scene-team .hero { flex: none; }

/* carte che girano di 180 gradi */
.flip { perspective: 1400px; min-width: 0; min-height: 0; }
.flip-in { position: relative; display: grid; height: 100%; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.45, .05, .25, 1); }
.flip.flipped .flip-in { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; min-width: 0; min-height: 0; display: grid; }
.face.back { transform: rotateY(180deg); }
.face > * { height: 100%; }
.fbody { grid-template-columns: minmax(0, 1fr) 460px; }
.fside { display: grid; grid-template-rows: auto 1fr; min-height: 0; padding: 16px 20px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.fside > div { display: grid; gap: 12px; align-content: start; }
.face.back .fside { background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.frow.new .fscore::after { display: none; }

/* scala dei punteggi */
.fchart-svg { position: relative; display: grid; grid-template-columns: 52px 1fr; min-height: 0; }
.axis { position: relative; }
.axis span { position: absolute; right: 10px; transform: translateY(-50%); font: 400 20px/1 var(--serif); color: var(--muted); font-variant-numeric: tabular-nums; }
.plot { position: relative; min-height: 0; }
.grid-line { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 6; }
.band-avg, .band-without { vector-effect: non-scaling-stroke; }
.band-now { position: absolute; right: -7px; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 25%, transparent); animation: breathe-svg 2.4s var(--ease) infinite; }
body.tv .scene-team .trunk { height: 24px; }
body.in-app .tvw-controls { display: none; }
/* dentro la dashboard: pagine statiche, niente barra del tempo sulle schede */
.tv-root.manual .tvw-tab i { visibility: hidden; }
.tv-root.manual .tvw-tab { cursor: pointer; }
.tv-root.manual .tvw-tab:not(.on):hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }

/* avvisi */
.alert-btn.on { color: var(--accent); }
.alert-btn.on svg { fill: color-mix(in srgb, var(--accent) 25%, transparent); }
.steps { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.8; }
.alerts-h { margin: 26px 0 10px; font: 400 26px/1.1 var(--serif); }
.alerts-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.alerts-log li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.alerts-log em { font-style: normal; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); grid-column: 1; }
.alerts-log b { grid-column: 1; font-weight: 600; }
.alerts-log span { grid-column: 1; font-size: 13.5px; color: var(--muted); }
.alerts-log small { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: var(--faint); font-variant-numeric: tabular-nums; }
.alerts-log .empty { display: block; color: var(--faint); }
body.tv .alert-btn { display: none; }
.sheet-head:not(:has(.sheet-ava)) { grid-template-columns: 1fr auto; }

/* ---------------- avviso "Nuova prenotazione" (tabellone TV) ---------------- */
.bk-toast {
  position: absolute; left: 50%; bottom: 84px; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  min-width: 820px; max-width: 1180px; padding: 22px 30px 22px 22px;
  border-radius: 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pl) 20%, var(--surface-2)), var(--surface));
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .75), inset 0 0 0 2px color-mix(in srgb, var(--pl) 60%, transparent);
  transform: translate(-50%, 140%) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .7s cubic-bezier(.2, 1.3, .4, 1), opacity .5s var(--ease);
  --pl: var(--accent);
}
.bk-toast.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
.bk-toast.pl-bkg { --pl: var(--fam-bkg); }
.bk-toast.pl-abn { --pl: var(--fam-abn); }
.bk-toast.pl-dir { --pl: var(--good); }
.bk-glow { position: absolute; inset: -2px; border-radius: inherit; pointer-events: none; box-shadow: 0 0 0 0 color-mix(in srgb, var(--pl) 60%, transparent); }
.bk-toast.show .bk-glow { animation: bk-ring 1.6s var(--ease) .3s 2; }
.bk-icon { display: grid; place-items: center; width: 92px; height: 92px; border-radius: 26px; background: var(--pl); color: var(--accent-ink); }
.bk-icon svg { width: 52px; height: 52px; stroke-width: 1.8; }
.bk-toast.show .bk-icon { animation: bk-bell 1s var(--ease) .4s 2; }
.bk-main { display: grid; gap: 6px; min-width: 0; }
.bk-eyebrow { font: 700 17px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--pl); }
.bk-name { font: 400 54px/1.02 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 21px; color: var(--muted); }
.bk-pl { font-style: normal; font-weight: 700; color: var(--ink); padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--pl) 30%, transparent); }
.bk-amount { font: 400 66px/1 var(--serif); color: var(--pl); white-space: nowrap; }
@keyframes bk-ring { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pl) 55%, transparent); } to { box-shadow: 0 0 0 26px transparent; } }
@keyframes bk-bell { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@media (prefers-reduced-motion: reduce) { .bk-toast { transition: opacity .3s; } }
