/* ============================================================
   Concierge Adadò, sistema visivo delle demo
   Direzione: editoriale operativo. Titoli e numeri in Instrument
   Serif, testo in Archivo, superfici distinte per tono e ombra,
   bordi solo sui controlli, colore solo dove indica un'azione o
   uno stato. Palette e caratteri ereditati da Live Feedback.
   ============================================================ */

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

/* ---------------- Token ---------------- */

:root {
  color-scheme: dark;
  --bg: #0b1c23;
  --bg-deep: #081419;
  --surface: #12262e;
  --surface-2: #173139;
  --raised: #1f3b44;
  --ink: #f2f3ec;
  --muted: #9fb4b8;
  --faint: #869ea3;   /* testo vero, non decorazione: ≥4,5:1 su --bg e sulle superfici */
  --line: #24404a;
  --line-strong: #345561;
  --brand-rule: #4d6f7b;
  --accent: #ff9b69;
  --accent-ink: #1a0d06;
  --good: #9ad5be;
  --warm: #f1c279;
  --bad: #ffaaa1;
  --info: #9ec9e2;
  --shadow-1: 0 1px 2px rgba(3, 17, 22, .45), 0 10px 28px -14px rgba(3, 17, 22, .8);
  --shadow-2: 0 2px 6px rgba(3, 17, 22, .5), 0 28px 70px -20px rgba(3, 17, 22, .95);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --sidebar-w: 240px;
  --gutter: 28px;
  --head-h: 112px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.22, 1.2, .36, 1);
  --dur-fast: .16s;
  --dur: .28s;
  --dur-slow: .46s;
  font-family: Archivo, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme=ivory] {
  color-scheme: light;
  --bg: #f1eee6;
  --bg-deep: #e9e5db;
  --surface: #fbf9f3;
  --surface-2: #f4f1e9;
  --raised: #e8e4d9;
  --ink: #172e34;
  --muted: #4f666b;
  --faint: #5c6f72;   /* testo vero, non decorazione: ≥4,5:1 su --bg e sulle superfici */
  --line: #ddd8cc;
  --line-strong: #bfc7c3;
  --brand-rule: #30515c;
  --accent: #b2471a;
  --accent-ink: #fff6ef;
  --good: #1b6850;
  --warm: #8a5f12;
  --bad: #a83329;
  --info: #1f5b7a;
  --shadow-1: 0 1px 2px rgba(23, 46, 52, .08), 0 10px 28px -14px rgba(23, 46, 52, .25);
  --shadow-2: 0 2px 6px rgba(23, 46, 52, .12), 0 28px 70px -20px rgba(23, 46, 52, .35);
}

/* ---------------- Base ---------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
}

body {
  overflow: hidden;
  /* Profondità: la luce arriva dall'alto a sinistra, il resto scende nel petrolio scuro */
  background: radial-gradient(1400px 700px at 8% -10%, color-mix(in srgb, var(--surface-2) 70%, var(--bg)), var(--bg) 60%, var(--bg-deep));
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; text-align: left; padding: 0; }
button:disabled { cursor: default; opacity: .5; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}

.serif { font-family: Instrument, Georgia, serif; font-weight: 400; letter-spacing: .002em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
}

/* ---------------- Movimento ---------------- */

@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes shimmer { from { background-position: 160% 0; } to { background-position: -60% 0; } }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
@keyframes menuIn { from { opacity: 0; transform: scale(.96) translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

.stagger { animation: rowIn .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 26ms); }
/* Bolle gia' viste, ridisegnate dal polling o da un'azione: niente rientro */
.bubble.settled, .stagger.settled { animation: none; }
/* Pallini dei non letti: lo scatto solo quando la riga entra animata, non a ogni ridisegno */
.chat-item:not(.stagger) .unread { animation: none; }
@keyframes threadIn { from { opacity: 0; } to { opacity: 1; } }
/* Attesa del filo: i segnaposto compaiono solo se il caricamento dura davvero */
.skel-late { animation: threadIn .2s var(--ease) both; }

/* ============================================================
   Impalcatura
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 3;
}

/* Il marchio è l'immagine approvata "adadò | CONCIERGE" (assets/brand-concierge.png),
   ritagliata al contenuto: nessuna composizione in CSS, quindi nessun disallineamento
   possibile fra parola e descrittore. Il solo filetto è disegnato qui, nel punto esatto
   in cui sta nell'immagine, per potergli dare il colore del tema. */
.brand {
  display: block;
  width: fit-content;
  padding: 2px 0 0 12px;
  line-height: 0;
}
.brand-lockup {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.brand-lockup img {
  display: block;
  height: 19px;
  width: auto;
}
.brand-lockup::after {
  content: '';
  position: absolute;
  left: 37.54%;
  top: 17.44%;
  width: 1px;
  height: 80.5%;
  transform: translateX(-50%);
  background: var(--brand-rule);
}

.nav { position: relative; display: flex; flex-direction: column; gap: 2px; }

/* La voce attiva ha un filetto di accento che scorre da una voce all'altra */
.nav-thumb {
  position: absolute;
  left: 0;
  width: 100%;
  height: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: transform var(--dur) var(--ease-spring), height var(--dur) var(--ease);
  pointer-events: none;
}
.nav-thumb::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transform: translateY(-50%);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease);
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--ink); font-weight: 600; }
.nav-item .ic { opacity: .85; }
.nav-item.active .ic { opacity: 1; color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--faint);
}
.nav-item.active .count { color: var(--ink); }
/* Due zone: Lavoro (numeri solo se c'e' qualcosa da fare) e Consultazione (niente numeri) */
.nav-group { padding: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.nav-group:first-of-type { padding-top: 2px; }
.nav-item.quiet .count, .nav-item .count[data-zero] { display: none; }

.sidebar-foot { margin-top: auto; display: grid; gap: 6px; }
.demo-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--faint);
}

/* ---------------- Colonna principale ---------------- */

.main { display: flex; flex-direction: column; min-width: 0; overflow: clip; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
  gap: 16px;
  padding: 12px var(--gutter) 10px;
}
/* Decisione di Fabrizio 24/09: nella pagina Chat Giovanni niente fascia alta, chat a tutta altezza */
body[data-view="chat"] .topbar { display: none; }
/* Fascia alta compatta: titolo e sottotitolo sulla stessa riga, niente vuoto sopra il lavoro */
.topbar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar h1 { font-size: 26px; line-height: 1.1; white-space: nowrap; }
.topbar .sub { font-size: 14px; color: var(--muted); margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Su schermo stretto il chip dell'assistenza non deve mozzarsi: va a capo coerente */
.topbar-actions .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  color: var(--muted);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  color: var(--good);
  animation: pulse 2.6s var(--ease) infinite;
}

.views { flex: 1; min-height: 0; position: relative; }
.view {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 4px var(--gutter) 32px;
  display: none;
}
.view.active { display: block; }
.view.enter > * { animation: viewIn var(--dur-slow) var(--ease) both; }
.view.chat-view { padding: 0; overflow: clip; }
.view.command-view { padding: 0; overflow: clip; }
/* Posizioni (solo Fabrizio): mappa a tutta altezza, il resto in posizioni/vista.css */
.view.positions-view { padding: 0; overflow: clip; }
.command-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }

/* ============================================================
   Controlli
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 90%, #fff); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 14px; }

.icon-btn {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn .ic { width: 16px; height: 16px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.field .ic { width: 16px; height: 16px; }
.field input { border: 0; background: none; outline: none; min-width: 0; width: 100%; font-size: 16px; color: var(--ink); }
.field input::placeholder { color: var(--faint); }
.field.grow { flex: 1; min-width: 220px; }

select {
  height: 40px;
  padding: 0 36px 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:hover { background-color: var(--surface-2); }

.segmented {
  position: relative;
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
}
.segmented.wrap { flex-wrap: wrap; margin-bottom: 16px; }
.segmented-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: var(--radius-pill);
  background: var(--raised);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease-spring), width var(--dur) var(--ease);
  pointer-events: none;
}
.seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}
.seg:hover, .seg.active { color: var(--ink); }
.seg.active { font-weight: 600; }
.seg .n {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.seg.active .n { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* Stato semantico: pallino più parola. Il colore è nel pallino, il testo resta leggibile */
.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
  color: var(--ink);
  white-space: nowrap;
}
.state i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.state.good i { background: var(--good); }
.state.warm i { background: var(--warm); }
.state.bad i { background: var(--bad); }
.state.info i { background: var(--info); }
.state.accent i { background: var(--accent); }
.state.quiet { color: var(--muted); }

/* Chip: etichetta compatta, usata dove serve una parola su fondo */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.chip.good { color: var(--good); } .chip.good i { background: var(--good); }
.chip.warm { color: var(--warm); } .chip.warm i { background: var(--warm); }
.chip.bad { color: var(--bad); } .chip.bad i { background: var(--bad); }
.chip.info { color: var(--info); } .chip.info i { background: var(--info); }
.chip.accent { color: var(--accent); } .chip.accent i { background: var(--accent); }

.dot-status { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot-status.good { background: var(--good); }
.dot-status.warm { background: var(--warm); }
.dot-status.bad { background: var(--bad); }
.dot-status.info { background: var(--info); }

/* Avatar: colore stabile per persona, ricavato dal nome */
.avatar {
  --hue: 200;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  color: hsl(var(--hue) 55% 88%);
  background: hsl(var(--hue) 32% 26%);
}
:root[data-theme=ivory] .avatar { color: hsl(var(--hue) 45% 26%); background: hsl(var(--hue) 40% 86%); }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ============================================================
   Numeri in evidenza, tabelle, pannelli
   ============================================================ */

/* I numeri chiave non stanno in scatole: stanno sulla pagina, come in un giornale */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 32px;
  padding: 10px 0 22px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.figure { display: grid; gap: 2px; padding: 4px 0; position: relative; }
.figure + .figure::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}
.figure .num { font-size: 34px; line-height: 1; margin-top: 8px; }
.figure .cap { font-size: 16px; color: var(--muted); margin-top: 4px; }
.figure.good .num { color: var(--good); }
.figure.warm .num { color: var(--warm); }
.figure.bad .num { color: var(--bad); }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th:first-child, tbody td:first-child { padding-left: 24px; }
thead th:last-child, tbody td:last-child { padding-right: 24px; }
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  vertical-align: middle;
}
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr[data-booking], tbody tr[data-structure] { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.cell-strong { font-size: 16px; font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 14px; color: var(--muted); margin-top: 3px; }
.cell-num { font-family: Instrument, Georgia, serif; font-size: 20px; line-height: 1; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); font-size: 16px; }
.empty .big { display: block; font-family: Instrument, Georgia, serif; font-size: 24px; color: var(--ink); margin-bottom: 6px; }

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--surface) 20%, var(--surface-2) 42%, var(--surface) 62%);
  background-size: 260% 100%;
  animation: shimmer 1.35s linear infinite;
}
.skel-row { height: 60px; margin: 8px 12px; }

/* ============================================================
   Chat
   ============================================================ */

.chat-layout { display: grid; grid-template-columns: clamp(360px, 25vw, 470px) 1fr; height: 100%; min-height: 0; }

.chat-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.chat-list-head {
  display: grid;
  gap: 10px;
  align-content: center;
  /* min-height e non height: col canale email i controlli sono due righe e la
     testata cresce, invece di sbordare sotto la topbar e mangiarsi i click */
  min-height: var(--head-h);
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.chat-list { flex: 1; overflow: auto; padding: 6px 0 16px; scrollbar-gutter: stable; }

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px var(--gutter);
  transition: background var(--dur-fast) var(--ease);
}
.chat-item::after {
  content: '';
  position: absolute;
  left: calc(var(--gutter) + 54px);
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
}
.chat-item:last-child::after { display: none; }
.chat-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transform: translateY(-50%);
  transition: height var(--dur) var(--ease-spring);
}
.chat-item:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.chat-item.active { background: var(--surface); }
.chat-item.active::before { height: 28px; }

.chat-item-body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.chat-item-row { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.chat-item-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Orario e non-letti stanno in una colonna a destra, sempre allineati fra le righe */
.chat-item-side { flex: none; align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; padding: 2px 0; }
.chat-item-time { font-size: 12px; color: var(--faint); }
.chat-item.waiting .chat-item-time { color: var(--warm); font-weight: 600; }
.chat-item-struct { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-preview { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); min-width: 0; }
.chat-item-preview > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  animation: popIn var(--dur) var(--ease-spring) both;
}

.thread-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.thread-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 14px;
  row-gap: 10px;
  min-height: var(--head-h);
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.thread-back { display: none; grid-column: 1; grid-row: 1; }
.thread-head > .avatar { grid-column: 2; grid-row: 1; }
.thread-head-info { grid-column: 3; grid-row: 1; min-width: 0; }
.thread-head-btns { grid-column: 4; grid-row: 1; display: flex; align-items: center; gap: 8px; }
.thread-head-btns > * { flex: none; }
/* Seconda riga: le pillole di stato, dal bordo sinistro come la barra dei canali sotto */
.thread-head-row { grid-column: 2 / -1; grid-row: 2; min-width: 0; }
.thread-head-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.thread-head-chips > * { flex: none; }
/* Selettore centrale: il canale attivo resta riconoscibile sopra i messaggi. */
.thread-channels { display: flex; justify-content: center; padding: 12px var(--gutter); border-bottom: 1px solid var(--line); }
.thread-channels .channel-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 440px; max-width: 100%; gap: 2px; padding: 4px; border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 13px; background: color-mix(in srgb, var(--ink) 6%, var(--bg)); overflow: visible; }
.thread-channels .channel-tab { justify-content: center; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: 9px; margin: 0; color: var(--muted); box-shadow: none; }
.thread-channels .channel-tab.active { background: color-mix(in srgb, var(--ink) 16%, var(--bg)); color: var(--ink); border-color: color-mix(in srgb, var(--ink) 7%, transparent); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 22%), 0 2px 6px rgb(0 0 0 / 8%); }
.thread-channels .channel-tab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.thread-channels .channel-tab.active .n { color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent); }
:root[data-theme=ivory] .thread-channels .channel-tab.active { background: #fff; border-color: rgb(0 0 0 / 3%); box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 2px 5px rgb(0 0 0 / 5%); }
.thread-head-name { font-family: Instrument, Georgia, serif; font-size: 24px; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head-detail { font-size: 16px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread-scroll { flex: 1; overflow: auto; padding: 24px var(--gutter) 8px; }
.thread-inner { display: flex; flex-direction: column; gap: 10px; max-width: 880px; }

.day-sep {
  align-self: center;
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
}

.bubble {
  max-width: min(70%, 600px);
  padding: 11px 15px 9px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.5;
  animation: bubbleIn .36s var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  overflow-wrap: anywhere;
}
.bubble-text { display: block; white-space: pre-wrap; }
.bubble.guest { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; box-shadow: var(--shadow-1); }
.bubble.ai { align-self: flex-end; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-bottom-right-radius: 6px; }
.bubble.operator { align-self: flex-end; background: color-mix(in srgb, var(--good) 16%, var(--surface)); border-bottom-right-radius: 6px; }
.bubble.note {
  align-self: stretch;
  max-width: none;
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--warm) 50%, transparent);
  color: var(--muted);
  font-size: 16px;
}
.bubble-author { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.bubble.ai .bubble-author { color: var(--accent); }
.bubble.operator .bubble-author { color: var(--good); }
.bubble.note .bubble-author { color: var(--warm); }
.bubble-meta { display: flex; gap: 8px; margin-top: 5px; font-size: 12px; color: var(--faint); }
.bubble.ai .bubble-meta, .bubble.operator .bubble-meta { justify-content: flex-end; }

.typing { align-self: flex-end; display: flex; gap: 4px; padding: 13px 15px; border-radius: var(--radius); background: var(--surface); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1.25s var(--ease) infinite; }
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }

.composer { padding: 12px var(--gutter) 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  resize: none;
  outline: none;
  font-size: 16px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.send-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform var(--dur-fast) var(--ease-spring), filter var(--dur-fast) var(--ease);
}
.send-btn .ic { width: 18px; height: 18px; }
.send-btn:hover { transform: translateY(-1px) scale(1.04); }
.send-btn:active { transform: scale(.94); }
.send-btn.direct { background: var(--good); color: #0b1c23; }
.send-btn.whisper { background: var(--accent); color: var(--accent-ink); }

.thread-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; color: var(--muted); padding: 40px; }
.thread-empty .ic { width: 40px; height: 40px; color: var(--line-strong); }
.thread-empty .big { font-family: Instrument, Georgia, serif; font-size: 24px; color: var(--ink); }

/* ============================================================
   Luca
   ============================================================ */

.luca-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 24px; align-items: start; }
.luca-col-head { display: flex; align-items: baseline; gap: 10px; padding: 4px 4px 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.luca-col-head .title { font-family: Instrument, Georgia, serif; font-size: 24px; line-height: 1; }
.luca-col-head .sub { font-size: 14px; color: var(--muted); }
.luca-col-head .n { margin-left: auto; font-family: Instrument, Georgia, serif; font-size: 24px; color: var(--faint); }
.luca-col.bad .luca-col-head .title { color: var(--bad); }
.luca-col.warm .luca-col-head .title { color: var(--warm); }
.luca-col.good .luca-col-head .title { color: var(--good); }
.luca-cards { display: grid; gap: 10px; }

.luca-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.luca-card:hover { transform: translateY(-2px); background: var(--surface-2); }
.luca-card-top { display: flex; align-items: center; gap: 10px; }
.luca-card-title { font-size: 16px; font-weight: 600; }
.luca-card-top .state { margin-left: auto; font-size: 14px; color: var(--muted); }
.luca-card-text { font-size: 16px; color: var(--muted); line-height: 1.5; }
.luca-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--faint); }
.luca-card-foot strong { color: var(--muted); font-weight: 500; }

.timeline { display: grid; }
.timeline-step { display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding-bottom: 12px; position: relative; }
.timeline-step:not(:last-child)::before { content: ''; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--line-strong); }
.timeline-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); margin-top: 2px; z-index: 1; }
.timeline-step.done .timeline-dot { background: var(--good); border-color: var(--good); }
.timeline-step.now .timeline-dot { background: var(--accent); border-color: var(--accent); color: var(--accent); animation: pulse 2s var(--ease) infinite; }
.timeline-label { font-size: 16px; }
.timeline-time { font-size: 14px; color: var(--faint); }

/* ============================================================
   Menu, pannello laterale, avvisi
   ============================================================ */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 280px;
  max-width: min(340px, 92vw);
  max-height: min(78vh, 700px);
  overflow-y: auto;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transform-origin: top right;
  animation: menuIn .22s var(--ease-spring) both;
}
.menu-group { padding: 10px 12px 4px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.menu-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: background var(--dur-fast) var(--ease);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .ic { width: 17px; height: 17px; margin-top: 2px; color: var(--muted); }
.menu-item .hint { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger .ic { color: var(--bad); }

.scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg-deep) 66%, transparent); opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transform: translateX(102%);
  transition: transform var(--dur-slow) var(--ease-spring);
  z-index: 41;
  display: flex;
  flex-direction: column;
}
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 24px 24px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 24px; margin-top: 6px; }
.sheet-body { flex: 1; overflow: auto; padding: 20px 24px 28px; display: grid; gap: 18px; align-content: start; }
.sheet-close { margin-left: auto; }
.sheet-note { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 16px; line-height: 1.5; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 16px; }
.kv dt { color: var(--muted); }

.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: var(--raised);
  box-shadow: var(--shadow-2);
  font-size: 16px;
  animation: toastIn .34s var(--ease-spring) both;
}
.toast.out { animation: toastOut .26s var(--ease) both; }

/* ============================================================
   Allegati: bolle multimediali, anteprima nel composer, visore
   ============================================================ */

.bubble.has-att { padding: 6px; }
.bubble.has-att .bubble-text:empty { display: none; }
.bubble.has-att .bubble-meta { padding: 0 9px 4px; }
.bubble.has-att .bubble-author { padding: 6px 9px 0; }

.att { display: block; border-radius: var(--radius-sm); overflow: hidden; }
.att-image { padding: 0; border: 0; background: var(--surface-2); max-width: 320px; cursor: zoom-in; }
.att-image img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; }
.att-video { max-width: 360px; background: #000; }
.att-video video { display: block; width: 100%; max-height: 300px; background: #000; }
.att-caption { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 14px; background: var(--surface-2); }
.att-caption .ic { width: 14px; height: 14px; color: var(--muted); }
.att-caption a { color: var(--ink); }
.att-audio { display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; width: 280px; max-width: 100%; }
.att-audio audio { display: none; }
.att-play {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.att-play:active { transform: scale(.92); }
.att-play .ic { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; }
.att-track { flex: 1; height: 4px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--ink) 18%, transparent); cursor: pointer; overflow: hidden; }
.att-track-fill { display: block; height: 100%; width: 0; background: var(--ink); border-radius: var(--radius-pill); transition: width .2s linear; }
.att-duration { font-size: 14px; color: var(--muted); flex: none; min-width: 34px; text-align: right; }
.att-doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 260px; max-width: 360px; background: color-mix(in srgb, var(--surface-2) 70%, transparent); color: inherit; text-decoration: none; }
.att-doc:hover { text-decoration: none; background: var(--surface-2); }
.att-doc-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.att-doc-icon .ic { width: 20px; height: 20px; }
.att-doc-body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.att-doc-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-doc-meta { font-size: 14px; color: var(--muted); }
.att-doc > .ic { width: 16px; height: 16px; color: var(--muted); flex: none; }

.att-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 6px 8px 6px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
  animation: popIn var(--dur) var(--ease-spring) both;
}
.att-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: var(--radius-sm); }
.att-chip > .ic { width: 18px; height: 18px; color: var(--muted); }
.att-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
/* icona inline, eccezione documentata alle altezze {32,40,44} */
.att-chip-x { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.att-chip-x:hover { background: var(--raised); color: var(--ink); }
.att-chip-x .ic { width: 13px; height: 13px; }

.composer-tools { display: flex; gap: 4px; align-items: center; }
.tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.tool-btn:hover { background: var(--surface-2); color: var(--ink); }
.tool-btn:active { transform: scale(.92); }
.tool-btn .ic { width: 19px; height: 19px; }
.tool-btn.recording { background: var(--bad); color: var(--bg-deep); animation: pulse 1.4s var(--ease) infinite; }
.rec-time { font-size: 14px; font-weight: 600; color: var(--bad); font-variant-numeric: tabular-nums; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: color-mix(in srgb, var(--bg-deep) 92%, transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.lightbox.open { opacity: 1; }
.lightbox-bar { display: flex; align-items: center; gap: 8px; padding: 14px 20px; color: var(--ink); }
.lightbox-name { flex: 1; min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A definite flex content box keeps tall photos inside the remaining viewport;
   an auto-sized inner grid can resolve max-height against the photo itself. */
.lightbox-body { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 0 20px 24px; }
.lightbox-body img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow-2); }
.lightbox-body iframe { width: min(960px, 100%); height: 100%; border: 0; border-radius: var(--radius-sm); background: #fff; }
.lightbox-file { display: grid; place-items: center; gap: 12px; color: var(--muted); }
.lightbox-file .ic { width: 48px; height: 48px; }

/* Spunte di recapito */
.ticks { display: inline-flex; align-items: center; margin-left: 2px; color: var(--faint); }
.ticks .ic { width: 15px; height: 15px; stroke-width: 2; }
.ticks.read { color: var(--info); }
.ticks.failed { color: var(--bad); }

/* Conferma prima di un invio che scavalca Giovanni */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.confirm.open { opacity: 1; }
.confirm-card {
  width: min(440px, 100%);
  padding: 22px 22px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 12px;
  transform: translateY(8px) scale(.98);
  transition: transform var(--dur) var(--ease-spring);
}
.confirm.open .confirm-card { transform: none; }
.confirm-title { font-size: 24px; line-height: 1.1; }
.confirm-body { font-size: 16px; color: var(--muted); line-height: 1.5; display: grid; gap: 8px; }
.confirm-body p { margin: 0; }
.confirm-quote { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); white-space: pre-wrap; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ============================================================
   Deleghe, reperibilità, doppia prenotazione, moduli nei dialoghi
   ============================================================ */

/* Deleghe con conferma di lettura */
.bubble.delegation { border-style: solid; border-color: var(--line-strong); }
.bubble.delegation.pending { border-color: color-mix(in srgb, var(--warm) 55%, transparent); }
.bubble.delegation.read { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.delegation-state { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.delegation-state .ticks { margin: 0; }
.delegation.read .delegation-state { color: var(--good); }
.delegation.pending .delegation-state { color: var(--warm); }
.delegation-state .btn { margin-left: auto; }

/* Reperibilità */
.oncall { display: grid; gap: 8px; }
.oncall-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); }
.oncall-item .avatar { width: 34px; height: 34px; font-size: 14px; }
.oncall-body { flex: 1; min-width: 0; }
.oncall-name { font-size: 16px; font-weight: 600; }
.oncall-role { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oncall-item .icon-btn { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.oncall-fallback { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--warm) 10%, var(--surface)); font-size: 16px; line-height: 1.45; }
.oncall-fallback .ic { flex: none; width: 18px; height: 18px; color: var(--warm); }

/* Doppia prenotazione sullo stesso numero */
.multi-booking { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--info) 10%, var(--surface)); }
.multi-booking .eyebrow { display: flex; align-items: center; gap: 6px; color: var(--info); }
.multi-booking .eyebrow .ic { width: 14px; height: 14px; }
.multi-booking-list { display: grid; gap: 6px; }
.multi-booking-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); font-size: 16px; text-align: left; }
.multi-booking-item.current { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 50%, transparent); }
.multi-booking-item .chip { margin-left: auto; }
.multi-booking-note { font-size: 14px; color: var(--muted); }

/* Fogli con un modulo dentro: segnalazione, follow-up, dopo la chiamata */
.sheet-form { display: grid; gap: 12px; padding: 6px 8px 4px; }
.sheet-form-title { font-size: 24px; line-height: 1.1; }
.report-context { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 16px; line-height: 1.4; }
.report-context .eyebrow { display: block; margin-bottom: 2px; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reason { height: 40px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); font-size: 16px; font-weight: 600; color: var(--muted); }
.reason.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sheet-note-input { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface-2); resize: none; font-size: 16px; outline: none; }
.templates { display: grid; gap: 8px; }
.template { display: grid; gap: 4px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; }
.template:active { background: var(--raised); }
.template-label { font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.template-text { font-size: 16px; line-height: 1.45; }


.form-card { width: min(520px, 100%); max-height: 88vh; overflow: auto; }
.confirm-head { display: flex; align-items: flex-start; gap: 12px; }
.confirm-head .icon-btn { margin-left: auto; }
.form-card .confirm-body { color: var(--ink); }
.form-card .reasons, .form-card .templates, .form-card .report-context { margin-top: 2px; }
.form-card .sheet-note-input { width: 100%; }

/* ============================================================
   Schermi stretti
   ============================================================ */

@media (max-width: 1100px) { .chat-layout { grid-template-columns: 300px 1fr; } }

/* Sotto i ~1020px la colonna del filo resterebbe troppo stretta per header, tab
   canale e pannello escalation: la chat passa a colonna singola (lista O filo,
   con il tasto indietro) ben prima che il contenuto si accavalli o si mozzi */
@media (max-width: 1020px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-list-pane { display: none; }
  .chat-layout.show-list .chat-list-pane { display: flex; }
  .chat-layout.show-list .thread-pane { display: none; }
  .thread-back { display: grid; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 64px 1fr; }
  /* I filtri della chat devono stare nella colonna: conteggi pill più compatti,
     altrimenti la testata forza la lista oltre la larghezza dello schermo */
  .chat-list-head .seg { padding: 0 10px; gap: 5px; font-size: 14px; height: 30px; }
  .chat-list-head .seg .n { padding: 2px 6px; font-size: 11.5px; }
  .sidebar { padding: 18px 10px 14px; }
  .brand { padding: 0; margin: 0 auto; }
  /* Sidebar chiusa: resta la sola parola, che occupa il 32,7% dell'immagine da sinistra */
  .brand-lockup img { width: 47px; height: 14px; object-fit: cover; object-position: left center; }
  .brand-lockup::after, .nav-item .label, .nav-item .count, .demo-note .label { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-thumb::before { display: none; }
  /* Barra stretta: il titolo della zona diventa un filetto */
  .nav-group { font-size: 0; padding: 0; margin: 8px 10px; border-top: 1px solid var(--line); }
  .nav-group:first-of-type { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------------- Collegamento ai dati veri ---------------- */

/* Accesso: stessa scheda delle conferme, al centro, sopra tutto */
.login {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}
.login[hidden] { display: none; }
.login-card {
  width: min(400px, 100%);
  display: grid; gap: 14px;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.login-brand { width: 200px; height: auto; margin-bottom: 6px; }
.login-sub { margin: 0; font-size: 16px; color: var(--muted); line-height: 1.5; }
.login-field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.login-field input {
  height: var(--ctl-h, 40px);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.login-error { margin: 0; min-height: 18px; font-size: 16px; color: var(--bad); }
.login-error:empty { display: none; }
.login-captcha[hidden] { display: none; }
.login-card .btn.primary { justify-content: center; height: 44px; }

/* Composer in sola lettura: lo dice, senza campo di testo */
.composer.readonly { padding-top: 10px; }
.composer-note {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}
.composer-note .ic { flex: none; color: var(--warm); }

/* L'italiano e' il testo della bolla: qui sotto si apre l'originale dell'ospite */
.bubble-original { margin-top: 7px; }
.bubble-original-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: inherit;
  opacity: .75;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.bubble-original-toggle:hover { opacity: 1; background: color-mix(in srgb, currentColor 16%, transparent); }
.bubble-original-text {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed color-mix(in srgb, currentColor 25%, transparent);
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  opacity: .75;
}

/* Elenchi nelle schede e nota sotto le tabelle */
.sheet-list { margin: 0; padding-left: 18px; font-size: 16px; line-height: 1.55; display: grid; gap: 4px; }
.table-note { padding: 12px var(--gutter); font-size: 14px; color: var(--muted); }

/* Piede della lista conversazioni: quante se ne vedono e come chiederne altre */
.list-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px 22px;
  font-size: 14px;
  color: var(--muted);
}

/* Il punto verde nella nota di stato si accende con il canale in tempo reale */
#modeNote .dot-status.good { box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
#modeNote .dot-status.good:not(.connected) { opacity: 0.55; box-shadow: none; }

/* ---------------- Impostazioni (amministratore) ---------------- */
.settings-grid { display: grid; gap: 18px; grid-template-columns: 1fr; align-content: start; }
.settings-card { padding: 18px var(--gutter) 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.settings-head h2 { margin: 0; font-size: 24px; line-height: 1.1; }
.settings-head p { margin: 4px 0 0; font-size: 16px; color: var(--muted); }
.settings-card .table-wrap { margin: 0 calc(-1 * var(--gutter)); }
.settings-card .table-wrap table { min-width: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form-field input, .form-field select, .form-field textarea {
  height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px;
}
.form-field textarea { height: auto; padding: 10px 12px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.form-field .hint { font-size: 14px; color: var(--faint); line-height: 1.4; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.role-legend { display: grid; gap: 6px; font-size: 16px; color: var(--muted); }
.role-legend strong { color: var(--ink); }
.check-list { display: grid; gap: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; font-size: 16px; line-height: 1.4; }
.check-item .dot-status { margin-top: 5px; }
.check-item .muted { display: block; }
.audit-detail { color: var(--muted); font-size: 14px; max-width: 520px; white-space: normal; }

/* Righe d'azione dell'amministratore: refresh manuali ed export */
.action-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.action-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.action-row .action-text { min-width: 0; }
.action-row .action-text strong { display: block; font-size: 16px; }
.action-row .action-text .muted { display: block; font-size: 14px; line-height: 1.35; }
.action-row .btn { flex: none; }
.action-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card-note { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.4; }

/* Filtro del registro e colonna IP */
.audit-filter { height: 32px; padding: 0 12px; flex: 1; min-width: 220px; max-width: 340px; }
.audit-filter .ic { width: 14px; height: 14px; }
.audit-filter input { font-size: 14px; }
.audit-ip { font-size: 12px; white-space: nowrap; }

@media (min-width: 1200px) { .settings-grid { grid-template-columns: 1fr 1fr; } .settings-card.wide { grid-column: 1 / -1; } }

/* ---------------- Azioni operatore nei dati veri ---------------- */

/* L'avviso dei casi eccezionali sopra il composer, come nella dashboard attuale */

/* Il × per togliere una nota interna, nella riga dei metadati della bolla */
.note-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-left: auto;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--faint);
  cursor: pointer;
}
.note-x:hover { background: var(--raised); color: var(--bad); }
.note-x .ic { width: 12px; height: 12px; }

/* Pannello "Gestisci escalation", fra i messaggi e il composer */
.esc-panel {
  display: grid; gap: 10px;
  margin: 0 var(--gutter) 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--warm) 40%, transparent);
  background: color-mix(in srgb, var(--warm) 8%, var(--surface));
}
/* Badge documenti che apre Vikey: la "goccia" della dashboard storica */
.docs-vikey-link { cursor: pointer; }
.docs-vikey-link .ic { width: 13px; height: 13px; }
.docs-vikey-link:hover { border-color: var(--line-strong); }
.docs-vikey-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.docs-chip { gap: 6px; }
.docs-chip .ic { width: 14px; height: 14px; flex: none; }
.docs-chip .ic:last-child { width: 12px; height: 12px; opacity: .7; }

.esc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Pannello retrattile: da chiuso e' una riga sola sopra il composer */
.esc-panel.esc-collapsed {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px;
}
.esc-panel.esc-collapsed > .ic { flex: none; width: 18px; height: 18px; color: var(--warm); }
.esc-collapsed-text { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.esc-panel.esc-collapsed .btn { margin-left: auto; }
.esc-head > .ic { flex: none; width: 20px; height: 20px; color: var(--warm); }
.esc-head-body { flex: 1; min-width: 0; }
.esc-title { font-size: 16px; font-weight: 600; }
.esc-sub { font-size: 14px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.esc-panel .sheet-note-input { width: 100%; }
.esc-actions { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
/* Figli del pannello: nessuno può imporre la sua larghezza minima alla griglia,
   altrimenti su schermo stretto i bottoni escono dal pannello invece di andare a capo */
.esc-panel > * { min-width: 0; }
.esc-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.esc-refund {
  display: grid; gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--warm) 45%, transparent);
  background: color-mix(in srgb, var(--warm) 10%, var(--surface));
}
.esc-refund-title { font-size: 16px; font-weight: 600; color: var(--warm); }
.esc-refund-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Storico dei follow-up e dei cambi di stato dentro le finestre di dialogo */
.form-card .kv { margin: 0; }

/* ---------------- Nuove sezioni operative ---------------- */

/* La nav si è allungata: la sidebar scorre da sola senza comprimere il piede.
   Come item della griglia shell le serve min-height:0, altrimenti cresce oltre
   il viewport e l'overflow non scatta mai (ultima voce mozzata, niente scroll). */
.sidebar { min-height: 0; overflow-y: auto; }
.nav { overflow: visible; }

/* Sotto-tab dentro una vista (Prenotazioni / Verifiche Ruben, Operativa / Erkole) */
.segmented.subtabs { margin-bottom: 16px; }

/* Tab dei canali nel filo della chat (WhatsApp / Email / Piattaforma):
   stesso componente degli altri segmented — cornice, sfondo, attacco in rilievo —
   centrato nella sua striscia sotto l'intestazione */
.channel-tabs {
  display: inline-flex; gap: 2px; padding: 3px; max-width: 100%;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.channel-tabs::-webkit-scrollbar { display: none; }
.channel-tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 500; height: 32px; padding: 0 13px; border-radius: var(--radius-pill);
  cursor: pointer; white-space: nowrap; transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.channel-tab:hover { color: var(--ink); }
.channel-tab.active { background: var(--raised); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.channel-tab .n {
  font-size: 12.5px; font-weight: 700; line-height: 1; padding: 3px 8px;
  border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.channel-tab.active .n { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.channel-tab .ic { width: 14px; height: 14px; }

/* Colonna email: il tasto Nuova Email sta sotto i filtri del registro */
.email-new { margin-top: 8px; }

/* Bolle email nel filo: oggetto in evidenza, corpo riassunto, tasto dettaglio */
.bubble.email { max-width: min(520px, 82%); }
.bubble.email .email-subject { display: block; font-weight: 700; }
.bubble.email .email-preview {
  display: block; white-space: pre-line; color: var(--muted);
  font-size: 14px; line-height: 1.5; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.bubble.email .btn { margin-top: 8px; }

/* Inbox e registro email nella colonna della lista */
#emailList { padding: 10px; gap: 6px; }
.email-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; color: var(--ink); transition: background var(--dur-fast) var(--ease);
}
.email-item:hover { background: var(--surface-2); }
.email-item.active { background: var(--surface-2); }
.email-item-body { min-width: 0; display: grid; gap: 2px; }
.email-item-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.email-item-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item-time { color: var(--faint); font-size: 12px; }
.email-item-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item-preview { color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item .unread { margin-left: auto; }
.email-log-direction { display: grid; gap: 2px; min-width: 0; }
.email-log-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Anteprima email nella scheda di dettaglio */
.email-frame { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.email-frame iframe { display: block; width: 100%; height: min(560px, 60vh); min-height: 320px; border: 0; background: #fff; }
.email-frame-title {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2);
}

/* Vista Escalation: righe raggruppate per prenotazione */
.esc-wait { font-weight: 700; }

/* Vista Documenti: card PDF operative */
.docs-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); align-content: start; }
.doc-card { display: grid; gap: 10px; padding: 18px; }
.doc-card-head { display: flex; align-items: flex-start; gap: 12px; }
.doc-card-icon {
  flex: none; width: 42px; height: 42px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--surface-2); color: var(--accent);
}
.doc-card-icon .ic { width: 20px; height: 20px; }
.doc-card-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.doc-card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.doc-card-text { font-size: 14px; line-height: 1.5; color: var(--muted); }
.doc-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--faint); font-size: 12px; }
.doc-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Analisi: barre orizzontali (canali, lingue) e ore di picco */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 52px; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .bar-track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); min-width: 2px; }
.bar-row .bar-n { text-align: right; color: var(--muted); }
.peak-chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.peak-col { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 4px; align-items: end; }
.peak-bar { border-radius: 0; background: var(--raised); min-height: 2px; }
.peak-col.hot .peak-bar { background: var(--accent); }
.peak-hour { text-align: center; font-size: 11px; color: var(--faint); }
.trend-grid { display: grid; gap: 10px; }
.trend-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.trend-delta { font-weight: 700; }

/* Erkole: chat analitica */
.erkole-chat { display: grid; grid-template-rows: 1fr auto; gap: 0; min-height: 380px; max-height: 560px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.erkole-thread { overflow: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.erkole-msg { max-width: 86%; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 16px; line-height: 1.55; }
.erkole-msg.user { justify-self: end; background: var(--raised); }
.erkole-msg.assistant { justify-self: start; background: var(--surface-2); }
.erkole-msg.assistant h4 { margin: 10px 0 4px; font-size: 14px; }
.erkole-msg.assistant ul { margin: 6px 0; padding-left: 18px; }
.erkole-msg.pending { justify-self: start; background: var(--surface-2); color: var(--muted); font-style: italic; }
.erkole-msg.error { justify-self: start; color: var(--bad); background: var(--surface-2); }
.erkole-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.erkole-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.erkole-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px; padding: 10px 12px; outline: none;
}
.erkole-composer textarea:focus { border-color: var(--accent); }

/* Schede recensioni: righe con voto in evidenza */
.review-rating { font-weight: 800; font-size: 16px; }
.review-text { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Su schermo stretto la tab dell'analisi e le barre restano leggibili */
@media (max-width: 860px) {
  .bar-row { grid-template-columns: 84px 1fr 44px; }
  .trend-row { grid-template-columns: 72px 1fr auto; }
  .erkole-msg { max-width: 94%; }
}

/* ---------------- Dettagli delle nuove sezioni ---------------- */

/* Vista Escalation: righe dello stesso incidente, attesa che diventa rossa */
tr.cont td { border-top: 1px dashed var(--line-strong); }
tr.cont td:first-child { padding-top: 4px; }
.esc-wait { font-weight: 700; }
.esc-wait.late { color: var(--bad); }
.cell-wrap { max-width: 320px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sheet-note.muted-note { color: var(--muted); }

/* Messaggi rilevanti nella scheda incidente: italiano in primo piano, originale sotto */
.esc-messages { display: grid; gap: 8px; }
.esc-message { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.esc-message-meta { font-size: 12px; color: var(--faint); margin-bottom: 2px; }
.esc-message-text { font-size: 14px; line-height: 1.5; }
.esc-message-original { font-size: 13px; color: var(--muted); margin-top: 4px; border-top: 1px dashed var(--line-strong); padding-top: 4px; }

/* Analisi: testo colorato per delta e didascalie delle ore di picco */
.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.peak-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }

/* La tabella dentro i pannelli delle recensioni respira come le altre */
.settings-card .table-wrap table { margin: 0; }
.card-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; display: flex; align-items: center; gap: 6px; }
.card-note .ic { width: 14px; height: 14px; }

/* ============================================================
   Azioni di edit: scheda struttura a tab, file, lezioni, QR
   ============================================================ */

/* Bottoni distruttivi: eliminazioni e takeover, rossi come le voci di menu */
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 86%, #000); }

/* Le tab della scheda struttura, sotto l'intestazione */
.sheet-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 24px 0; border-bottom: 1px solid var(--line); }
.sheet-tab {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px 10px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.sheet-tab:hover { color: var(--ink); }
.sheet-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Le liste di file (media, allegati, check-up) e le lezioni: righe con icona, testo e azioni */
.file-list, .lesson-list { display: grid; gap: 8px; }
.file-row, .lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.file-icon {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--accent);
}
.file-icon .ic { width: 16px; height: 16px; }
.file-body, .lesson-text { flex: 1; min-width: 180px; display: grid; gap: 2px; }
.file-body strong, .lesson-text strong { font-size: 14px; }
.file-body span, .lesson-text span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.lesson-chips { display: flex; gap: 6px; align-items: center; }
.file-row .row-actions, .lesson-item .row-actions { margin-left: auto; }
.file-row .state, .lesson-item .state { flex: none; }

/* Il QR di collegamento del WhatsApp di servizio */
.qr-box { display: grid; place-items: center; padding: 16px; border-radius: var(--radius); background: #fff; }
.qr-box img { width: min(280px, 70vw); height: auto; display: block; }
.qr-box .empty { background: transparent; }

/* ---------------- Assistente operativo ---------------- */
.assistant-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.assistant-sugg { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
/* I suggerimenti sono frasi intere: su schermo stretto il testo va a capo,
   il bottone non sborda dalla card */
.assistant-sugg .btn { min-width: 0; white-space: normal; text-align: left; }
.assistant-chat { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr auto; min-height: 380px; max-height: 560px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.assistant-thread { overflow: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.assistant-meta { font-size: 11px; color: var(--faint); margin-top: 4px; }
.assistant-actions { margin-top: 8px; }
.assistant-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.assistant-composer input {
  flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; padding: 0 16px; outline: none;
}
.assistant-composer input:focus { border-color: var(--accent); }

/* ---------------- Check-up globale e lista della spesa ---------------- */
.checkup-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.checkup-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.checkup-month {
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px;
}
/* Pericolo "leggero": testo rosso senza riempimento; la doppia classe ha
   specificita' maggiore della variante solida .btn.danger */
.btn.ghost.danger { background: transparent; border-color: transparent; color: var(--bad); }
.btn.ghost.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }

.shopping-list { display: grid; gap: 10px; }
.shopping-row {
  display: grid; gap: 10px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.shopping-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shopping-edit input {
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--ink); font: inherit; font-size: 14px; outline: none;
}
.shopping-edit input:focus { border-color: var(--accent); }
.shopping-edit input[data-shop-qty] { width: 90px; }
.shopping-edit input[data-shop-note] { flex: 1; min-width: 160px; }
.shopping-unit { font-size: 13px; color: var(--faint); }
.shopping-checks { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.shopping-checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------------- Voucher e Start-up ---------------- */
.voucher-code { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.progress-cell { min-width: 130px; }
.progress-track { height: 6px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-pill); background: var(--warm); }
.progress-fill.done { background: var(--good); }
.progress-cap { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------------- Luca: sotto-viste Task legacy e Ordini Erkole ---------------- */
.luca-subnav { margin-bottom: 16px; }
.luca-subnav .seg .n { margin-left: 6px; }
.luca-subhost { max-width: 860px; }
.luca-list { display: grid; gap: 12px; }
.luca-list .luca-card { cursor: default; }
.luca-list .luca-card:hover { transform: none; }
.luca-list .luca-card-text { font-size: 14px; }
.luca-list .luca-card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------------- Revisione documenti (secondo gruppo del sub-tab Ruben) ---------------- */
.docchecks { margin-top: 16px; padding: 16px var(--gutter); }
.docchecks-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.docchecks-head h3 { margin: 0; font-size: 20px; }
.docchecks-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.docchecks-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.doccheck-list { display: grid; gap: 8px; }
.doccheck-attempt {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.doccheck-attempt + .doccheck-attempt { border-top: 1px solid var(--line); }
.doccheck-imgs { display: flex; gap: 8px; flex: none; }
.doccheck-imgs img {
  width: 60px; height: 75px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
}
.doccheck-imgs img[data-dc-img$=":document"] { width: 100px; height: 65px; }
.doccheck-body { flex: 1; min-width: 180px; font-size: 13px; line-height: 1.5; }

/* ---------------- Stato del servizio email (footer della colonna email) ---------------- */
.email-service-status {
  display: flex; align-items: center; gap: 8px;
  min-height: 32px; padding: 0 12px; margin: 8px var(--gutter) 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font-size: 12px; cursor: pointer; text-align: left; flex: none;
}
.email-service-status:hover { background: var(--surface); }
.email-service-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Tentativi di contatto (sotto il registro email) ---------------- */
.contact-attempts {
  padding: 12px var(--gutter); border-top: 1px solid var(--line);
  max-height: 240px; overflow: auto; flex: none;
}
.contact-attempts-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.contact-attempts-list { display: grid; gap: 8px; }
.contact-attempt {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.contact-attempt .ic { width: 16px; height: 16px; flex: none; color: var(--accent); }
.contact-attempt-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.contact-attempt-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.contact-attempt-row .tnum { color: var(--muted); font-size: 12px; }
.contact-attempt-sub {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-attempt .state { flex: none; }


/* Native OTA queue: keep the send control inside narrow operator viewports. */
.composer textarea { min-width: 0; }
.platform-queue-panel { flex: none; padding: 12px var(--gutter); border-top: 1px solid var(--line); max-height: 220px; max-height: min(32vh, 220px); overflow-y: auto; font-size: 13px; line-height: 1.45; }
.platform-queue-panel p { margin: 8px 0 0; overflow-wrap: anywhere; }
.platform-queue-panel label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.platform-queue-panel select { max-width: 100%; }
.platform-queue-panel [role="alert"] { color: var(--warm); }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar-title { min-width: 0; flex: 1 1 100%; }
  .topbar h1 { font-size: 24px; }
  .topbar .sub { display: none; }
  .topbar-actions { margin-left: 0; flex-wrap: wrap; min-width: 0; }
  .topbar-actions .chip { height: auto; white-space: normal; }
  /* In an open conversation the guest header already identifies the view. */
  .main:has(#view-chat.active .chat-layout:not(.show-list)) > .topbar { display: none; }
  .thread-head { grid-template-columns: 32px 40px minmax(0, 1fr); column-gap: 10px; }
  .thread-head-name { font-size: 22px; }
  .thread-head-detail { font-size: 13px; }
  .thread-head-btns { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; gap: 6px; }
  .thread-head-row { grid-column: 1 / -1; grid-row: 3; }
  .thread-head-chips > * { flex: 0 1 auto; }
  .thread-head-chips .chip { max-width: 100%; height: auto; white-space: normal; }
  .thread-channels { padding: 10px; }
  .thread-channels .channel-tab { padding: 0 5px; gap: 4px; font-size: 12px; }
  .thread-channels .channel-tab .n { padding: 2px 4px; font-size: 11px; }
}
.lightbox-bar .lightbox-close { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); width: auto; min-height: 44px; padding: 0 12px; gap: 8px; }

/* A media tool must not expand the grid track beyond the mobile thread. */
.platform-queue-panel + .composer { min-width:0; grid-template-columns:minmax(0,1fr); }
.platform-queue-panel + .composer .composer-row { min-width:0; }
.lightbox { grid-template-columns: minmax(0, 1fr); }
.lightbox-bar, .lightbox-body { min-width: 0; }

/* Scheda struttura, tab Accessi: un varco Vikey per riga con il tasto Apri */
.door-list { display: grid; gap: 10px; }
.door-row { flex-wrap: nowrap; }
.door-row .action-text { flex: 1; }
.door-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.door-ic .ic { width: 20px; height: 20px; }
.door-row .btn { min-width: 76px; }
.door-result:empty { display: none; }
.door-result { display: block; margin-top: 4px; font-size: 14px; line-height: 1.35; }
.door-result.good { color: var(--good); }
.door-result.bad { color: var(--bad); }
.door-result.muted { color: var(--muted); }
.door-empty { padding: 40px 20px; }
.door-empty .ic { width: 22px; height: 22px; color: var(--muted); margin-bottom: 6px; }

/* ============================================================
   Manutenzioni: tabellone del flusso tecnici (25/09/2026)
   Colori delle urgenze come nella webapp manutentori:
   Urgentissima rosso, Urgente arancione, Bassa priorità azzurro.
   ============================================================ */

:root { --p-urgentissima: #ff6b5b; --p-urgente: #ffa53d; --p-bassa: #6cb8f0; --orange: #ffa53d; }
:root[data-theme=ivory] { --p-urgentissima: #a83329; --p-urgente: #c2410c; --p-bassa: #1d6fa5; --orange: #c2410c; }

.pdot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--p-bassa); }
.p-urgentissima .pdot, .pdot.p-urgentissima { background: var(--p-urgentissima); }
.p-urgente .pdot, .pdot.p-urgente { background: var(--p-urgente); }
.p-da_fare .pdot, .pdot.p-da_fare { background: var(--p-bassa); }

.maint-counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.maint-counter {
  display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1); border: 1.5px solid transparent;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.maint-counter:hover { transform: translateY(-2px); background: var(--surface-2); }
.maint-counter .num { font-size: 38px; line-height: 1; }
.maint-counter .cap { display: flex; align-items: center; gap: 7px; font-size: 15px; color: var(--muted); }
.maint-counter .cap .ic { width: 16px; height: 16px; }
.maint-counter.t-bad .num, .maint-counter.t-bad .cap .ic { color: var(--bad); }
.maint-counter.t-orange .num, .maint-counter.t-orange .cap .ic { color: var(--orange); }
.maint-counter.t-info .num, .maint-counter.t-info .cap .ic { color: var(--info); }
.maint-counter.t-good .num, .maint-counter.t-good .cap .ic { color: var(--good); }
.maint-counter.active { border-color: currentColor; }
.maint-counter.t-bad.active { border-color: var(--bad); }
.maint-counter.t-orange.active { border-color: var(--orange); }
.maint-counter.t-info.active { border-color: var(--info); }
.maint-counter.t-good.active { border-color: var(--good); }

.maint-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 16px; min-height: 30px; }
.maint-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.maint-legend span { display: inline-flex; align-items: center; gap: 6px; }
.maint-clear { cursor: pointer; color: var(--ink); }
.maint-clear .ic { width: 14px; height: 14px; }
.maint-read { margin-left: auto; font-size: 13px; }

.maint-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: start; }
.maint-board.single { grid-template-columns: minmax(0, 1fr); }
.maint-board.single .maint-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.maint-col-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; min-height: 44px; }
.maint-col-head .title { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.maint-col.t-bad .maint-col-head .title { color: var(--bad); }
.maint-col.t-orange .maint-col-head .title { color: var(--orange); }
.maint-col.t-good .maint-col-head .title { color: var(--good); }
.maint-col-head .n { font-size: 24px; color: var(--faint); line-height: 1; }
.maint-days { margin-left: auto; padding: 2px; }
.maint-days .seg { height: 28px; padding: 0 10px; font-size: 14px; }
.maint-days .seg.active { background: var(--raised); box-shadow: var(--shadow-1); }
.maint-cards { display: grid; gap: 10px; }
.maint-empty { padding: 18px 6px; color: var(--faint); font-size: 15px; }
.maint-more { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.maint-more:hover { color: var(--ink); border-style: solid; }
.maint-more svg { width: 18px; height: 18px; }

.mcard {
  display: grid; gap: 5px; padding: 13px 15px 13px 14px; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer; border-left: 4px solid var(--p-bassa);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.mcard.p-urgentissima { border-left-color: var(--p-urgentissima); }
.mcard.p-urgente { border-left-color: var(--p-urgente); }
.mcard:hover { transform: translateY(-2px); background: var(--surface-2); }
.mcard.alarm { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); box-shadow: var(--shadow-1), inset 0 0 0 1.5px color-mix(in srgb, var(--bad) 70%, transparent); }
.mcard.alarm:hover { background: color-mix(in srgb, var(--bad) 17%, var(--surface)); }
.mcard-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mcard-place { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-title { font-size: 15px; line-height: 1.4; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mcard-line { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.mcard-line .ic { width: 15px; height: 15px; margin-top: 2px; }
.mcard-line.who { color: var(--ink); }
.mcard-line.onsite { color: var(--info); }
.mcard-line.decl { color: var(--warm); }
.mcard-line.note { font-style: italic; }
.mcard-alarm { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--bad); margin-top: 2px; }
.mcard-alarm .ic { width: 15px; height: 15px; }

.maint-backlog { margin-top: 14px; border-top: 1px dashed var(--line-strong); padding-top: 12px; }
.maint-backlog-toggle { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 14px; color: var(--muted); padding: 6px 4px; border-radius: var(--radius-sm); }
.maint-backlog-toggle:hover { background: var(--surface); }
.maint-backlog-toggle > span:nth-child(2) { flex: 1; }
.maint-backlog-toggle strong { color: var(--ink); }
.maint-backlog-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; max-height: 420px; overflow: auto; }
.maint-backlog-list li { display: grid; grid-template-columns: 11px minmax(0, 9em) minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 13.5px; padding: 5px 6px; border-radius: 8px; cursor: pointer; }
.maint-backlog-list li:hover { background: var(--surface); }
.maint-backlog-list .place { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maint-backlog-list .what { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maint-backlog-list li.more { display: block; cursor: default; }

.maint-techs { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.maint-tech-row { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 16px; color: var(--muted); }
.maint-tech strong { color: var(--ink); }
.maint-rules { font-size: 13px; line-height: 1.5; max-width: 880px; margin-top: 6px; }

.maint-sheet-title { font-size: 18px; line-height: 1.45; }
.sheet-note.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); display: flex; gap: 8px; align-items: center; }
.maint-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.maint-history li { display: grid; grid-template-columns: 8.5em 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.45; }
.maint-history li:last-child { border-bottom: 0; }
.maint-history .t { color: var(--faint); font-size: 14px; }
.maint-chat-note { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 0; }
.maint-chat-note .ic { margin-top: 2px; }

.maint-tabs { display: none; }
@media (max-width: 1100px) {
  .maint-board { grid-template-columns: minmax(0, 1fr); }
  .maint-tabs { display: flex; width: 100%; margin-bottom: 4px; }
  .maint-tabs .seg { flex: 1; justify-content: center; }
  .maint-col-head { border-bottom: 0; margin-bottom: 4px; min-height: 0; padding: 0; }
  .maint-col-head .title, .maint-col-head .n { display: none; }
  .maint-tabs .seg { font-size: 14px; padding: 0 10px; }
  .maint-tabs .seg.active { background: var(--raised); box-shadow: var(--shadow-1); }
  .maint-board[data-mcol="to_take"] .maint-col:not([data-col="to_take"]),
  .maint-board[data-mcol="in_progress"] .maint-col:not([data-col="in_progress"]),
  .maint-board[data-mcol="resolved"] .maint-col:not([data-col="resolved"]) { display: none; }
  .maint-counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .maint-counters { gap: 8px; }
  .maint-counter { padding: 11px 12px; }
  .maint-counter .num { font-size: 30px; }
  .maint-counter .cap { font-size: 13.5px; }
  .maint-read { margin-left: 0; }
  .maint-legend { gap: 10px; font-size: 13px; }
  .maint-counter .cap .ic { display: none; }
  .maint-tabs .seg { font-size: 13px; padding: 0 4px; gap: 4px; }
  .maint-tabs .seg .n { padding: 2px 6px; font-size: 11.5px; }
  .maint-history li { grid-template-columns: 6.5em 1fr; font-size: 14px; }
}

/* ---------------- Richieste dalle piattaforme (in cima alla lista chat) ----------------
   Chat Booking/Airbnb senza prenotazione: nessun agente può rispondere. Il testo
   dell'ospite si legge per intero, niente tagli. */
.ota-requests { display: grid; gap: 10px; margin: 6px var(--gutter) 14px; padding: 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--warm) 8%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warm) 35%, transparent); }
.ota-requests-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--warm); }
.ota-requests-head svg { width: 16px; height: 16px; }
.ota-requests-head b { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill); display: grid; place-items: center;
  font-size: 12px; background: var(--warm); color: var(--accent-ink); }
.ota-request { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.ota-request-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ota-request-wait { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--warm); }
.ota-request-place { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.ota-request-why, .ota-request-hint { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ota-request-text { margin: 2px 0; font-size: 15px; line-height: 1.45; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.ota-request-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ota-request-actions .btn { white-space: normal; height: auto; min-height: 32px; }

/* Chat sulla piattaforma: link alla chat originale nella riga sopra il campo di scrittura,
   e rimando dal pannello escalation (vai direttamente alla piattaforma) */
.platform-queue-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.platform-queue-panel .platform-queue-head > p { flex: 1 1 260px; margin: 0; }
.platform-open-link { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); white-space: nowrap; transition: background var(--dur-fast) var(--ease); }
.platform-open-link:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.platform-open-link svg, .platform-open-link .ic { width: 14px; height: 14px; }
.esc-platform { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--info) 10%, var(--surface-2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 35%, transparent); }
.esc-platform > .ic, .esc-platform > svg { flex: none; width: 18px; height: 18px; color: var(--info); }
.esc-platform span { flex: 1 1 200px; min-width: 0; }
.esc-panel.esc-collapsed [data-go-platform] { margin-left: auto; }
.esc-panel.esc-collapsed [data-go-platform] + [data-esc-expand] { margin-left: 0; }

/* Loghi dei partner (Booking.com, Airbnb, Vikey) su targhetta chiara, dentro testi e pulsanti */
.ota-logo { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; flex: none; line-height: 0;
  background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgb(0 0 0 / .18); }
.ota-logo img { display: block; width: auto; height: 100%; }
.ota-logo-word { height: 20px; padding: 4px 7px; }
.ota-logo-mark { height: 22px; padding: 2px; border-radius: 6px; }
.ota-logo-mark.ota-logo-booking { padding: 0; background: transparent; box-shadow: none; }
.ota-logo-inline { height: 18px; padding: 3px 6px; border-radius: 5px; vertical-align: -4px; }
.ota-request-label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.ota-request-label b { font-weight: 600; }
.platform-open-link .ota-logo-word, .ota-request-actions .ota-logo-word { height: 18px; padding: 3px 6px; }
.btn .ota-logo-word { height: 18px; padding: 3px 6px; }
/* Anteprima in lista di un messaggio Booking/Airbnb: logo piccolo prima del testo */
.ota-logo-preview { height: 16px; padding: 2px 5px; margin-right: 6px; vertical-align: -3px; }
.chat-item-preview .ota-logo-preview { flex: none; }
[data-compose-mode="platform"] .ota-logo-inline { height: 16px; padding: 2px 5px; vertical-align: -3px; margin-left: 2px; }

/* Richieste senza prenotazione come chat nella lista (26/09/2026) */
.ota-list-head { display: flex; align-items: center; gap: 8px; padding: 10px var(--gutter) 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warm); }
.ota-list-head svg { width: 14px; height: 14px; }
.ota-list-head b { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); display: grid; place-items: center; font-size: 12px; background: var(--warm); color: var(--accent-ink); }
.chat-item.ota-item { background: color-mix(in srgb, var(--warm) 7%, transparent); }
.chat-item.ota-item:hover { background: color-mix(in srgb, var(--warm) 12%, transparent); }
.chat-item.ota-item.active { background: color-mix(in srgb, var(--warm) 16%, var(--surface)); }
.chat-item.ota-item .unread { background: var(--warm); }
.ota-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.ota-avatar .ota-logo { background: transparent; box-shadow: none; padding: 0; height: 22px; }
.ota-avatar.lg { width: 48px; height: 48px; }
.ota-avatar.lg .ota-logo { height: 26px; }
.ota-wait { color: var(--warm); font-weight: 600; }
.ota-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ota-pane .thread-scroll { flex: 1; }
.ota-pane-hint { padding: 8px var(--gutter); font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.ota-pane-hint.ota-suggest { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink, inherit); }
.ota-pane-hint.ota-suggest > span { flex: 1 1 200px; min-width: 0; }
.thread-head-btns .ota-logo-inline { height: 16px; padding: 2px 5px; }

/* Loghi dei partner trasparenti, come nel Command Center (26/09/2026): niente targhetta;
   nel tema scuro la variante chiara delle parti scure, nel tema chiaro l'originale */
.ota-logo, .ota-logo-word, .ota-logo-mark, .ota-logo-inline, .ota-logo-preview { background: none !important; box-shadow: none !important; padding: 0 !important; border-radius: 0 !important; }
.ota-logo img.on-light { display: none; }
:root[data-theme=ivory] .ota-logo img.on-dark { display: none; }
:root[data-theme=ivory] .ota-logo img.on-light { display: block; }
.ota-logo-inline { height: 15px; }
.ota-logo-preview { height: 13px; margin-right: 6px; }
.ota-logo-mark { height: 20px; }

/* Pallino Booking (26/09/2026, logo scelto da Fabrizio): il simbolo riempie tutto l'avatar
   e il cerchio ne arrotonda gli angoli; Airbnb resta il simbolo piccolo al centro */
.ota-avatar:has(.ota-logo-booking) { overflow: hidden; background: #003580; box-shadow: none; }
.ota-avatar .ota-logo-mark.ota-logo-booking { width: 100%; height: 100%; }
.ota-avatar .ota-logo-mark.ota-logo-booking img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.12); }

/* Testo a nastro (ui.mjs marquee): chi non entra scorre, non si tronca */
.mq-on { text-overflow: clip !important; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent); }
mq-in { display: inline-flex; white-space: nowrap; will-change: transform; animation: mq var(--mqd, 8s) linear infinite; }
mq-part { display: inline-block; flex: none; padding-right: 40px; }
@keyframes mq { 0%, 22% { transform: translateX(0); } 100% { transform: translateX(var(--mq, 0)); } }
@media (prefers-reduced-motion: reduce) { mq-in { animation-duration: calc(var(--mqd, 8s) * 2); } }
/* Dopo con richieste Booking/Airbnb da seguire: il numero si accende */
#segLaterN.attn { background: var(--warm); color: var(--accent-ink); }

/* ============================================================
   Selettore di regione Puglia | Palermo (30/09/2026)
   Stesso segmented control del resto; il numero e' quello delle
   escalation aperte della regione, acceso sull'altra regione se
   c'e' qualcosa da fare. Il cursore lo muove region.mjs.
   ============================================================ */
.region-switch { display: flex; width: 100%; }
.region-switch .segmented-thumb { top: 0; bottom: auto; left: 0; }
.region-switch.no-anim .segmented-thumb { transition: none; }
.region-switch .seg { flex: 1 1 0; min-width: 0; justify-content: center; gap: 7px; height: 34px; padding: 0 10px; font-size: 14px; }
.region-switch .region-short { display: none; }
.region-switch .n { font-size: 12px; padding: 3px 7px; }
.region-switch .seg:not(.active) .n.has { color: var(--warm); background: color-mix(in srgb, var(--warm) 16%, transparent); }
.region-host { margin: -6px 0 -4px; }

@media (max-width: 860px) {
  /* Barra laterale stretta: i due segmenti in colonna, sigla e numero */
  .sidebar .region-switch { flex-direction: column; gap: 2px; border-radius: var(--radius-sm); }
  .sidebar .region-switch .segmented-thumb { border-radius: 9px; }
  .sidebar .region-switch .seg { flex: none; flex-direction: column; height: auto; padding: 6px 0; gap: 3px; border-radius: 9px; }
  .sidebar .region-switch .region-name { display: none; }
  .sidebar .region-switch .region-short { display: inline; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
  .sidebar .region-switch .n { font-size: 11px; padding: 2px 6px; }
  .region-host { margin: 0; }
}

/* Filtro per città della sezione Strutture (30/09/2026): stessa pillola dei filtri,
   su più righe se le città sono tante; il segmento attivo ha il fondo in rilievo
   (senza cursore scorrevole, che non segue l'andata a capo) */
.city-filter { gap: 4px; }
.city-filter .seg.active { background: var(--raised); box-shadow: var(--shadow-1); }
/* Su una riga resta una pillola (alta 40); se va a capo gli angoli restano morbidi */
.segmented.city-filter { border-radius: var(--radius); }
/* Schermo stretto: una sola riga che scorre di lato, come i filtri di iOS */
@media (max-width: 860px) {
  .segmented.wrap.city-filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-radius: var(--radius-pill); }
  .city-filter::-webkit-scrollbar { display: none; }
  .city-filter .seg { flex: none; }
}

