/* ADVISOR AI Hub — interfaccia. Layout: barra laterale blu notte fissa + area di lavoro a schede;
   sotto i 900px la barra diventa un cassetto e le griglie passano a una colonna. */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #eceff5;
  --ink: #131a2c;
  --muted: #5b6477;
  --line: #dce1ea;
  --accent: #96711f;        /* ottone ADVISOR, versione leggibile su chiaro */
  --accent-ink: #ffffff;
  --accent-soft: #f4ecd9;
  --side-bg: #0c1529;
  --side-ink: #c9d0de;
  --side-muted: #7d889f;
  --side-active: #1b2742;
  --side-gold: #d6b25e;
  --pos: #1d7348;  --pos-soft: #e1f2e8;
  --warn: #9a6200; --warn-soft: #fbefd6;
  --crit: #b3261e; --crit-soft: #fbe3e1;
  --info: #2c579f; --info-soft: #e2eaf8;
  --shadow: 0 1px 2px rgba(19, 26, 44, .06), 0 6px 18px rgba(19, 26, 44, .05);
  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  --side-w: 252px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1020; --surface: #111a2d; --surface-2: #17223a; --ink: #e7eaf2; --muted: #98a2b7; --line: #243050;
    --accent: #d6b25e; --accent-ink: #1a1405; --accent-soft: #2a2414;
    --side-bg: #070d1a; --side-active: #16213a;
    --pos: #53c48d; --pos-soft: #12301f; --warn: #e3a63c; --warn-soft: #33270f;
    --crit: #f07a72; --crit-soft: #3a1714; --info: #85a9ee; --info-soft: #152442;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1020; --surface: #111a2d; --surface-2: #17223a; --ink: #e7eaf2; --muted: #98a2b7; --line: #243050;
  --accent: #d6b25e; --accent-ink: #1a1405; --accent-soft: #2a2414;
  --side-bg: #070d1a; --side-active: #16213a;
  --pos: #53c48d; --pos-soft: #12301f; --warn: #e3a63c; --warn-soft: #33270f;
  --crit: #f07a72; --crit-soft: #3a1714; --info: #85a9ee; --info-soft: #152442;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.n, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* ------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side-bg); color: var(--side-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 12px calc(18px + env(safe-area-inset-bottom, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 12px; height: 12px; border-radius: 50%; background: var(--side-gold); box-shadow: 0 0 0 4px rgba(214, 178, 94, .18); }
.brand b { font-family: var(--f-display); font-size: 20px; letter-spacing: .06em; color: #fff; font-weight: 600; }
.brand span { font-size: 10px; letter-spacing: .22em; color: var(--side-muted); text-transform: uppercase; }
.nav-group { margin-top: 14px; }
.nav-group > div { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--side-muted); padding: 0 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-ink);
  text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.on { background: var(--side-active); color: #fff; box-shadow: inset 2px 0 0 var(--side-gold); }
.nav a .badge { margin-left: auto; background: var(--side-gold); color: #1a1405; font-size: 11px; border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; color: var(--side-muted); display: grid; gap: 8px; }
.side-foot button { background: transparent; border: 1px solid #2a3756; color: var(--side-ink); border-radius: 7px; padding: 6px 10px; cursor: pointer; text-align: left; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .burger { display: none; }
.top select { max-width: 230px; width: auto; }
.mode-pill { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top .spacer { flex: 1; }
.content { padding: 22px 24px 48px; display: grid; gap: 18px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.page-head h1 { font-family: var(--f-display); font-weight: 600; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------ componenti */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--crit); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: wait; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label.f { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; }
label.chk input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; box-shadow: var(--shadow); }
.panel > h2, .panel-head h2 { font-size: 15px; font-weight: 600; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.alert { border-color: color-mix(in srgb, var(--crit) 45%, var(--line)); }
.kpi.alert .v { color: var(--crit); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.pos { background: var(--pos-soft); color: var(--pos); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.gold { background: var(--accent-soft); color: var(--accent); }
.up { color: var(--pos); } .down { color: var(--crit); }

.tbl-wrap { overflow-x: auto; margin: 0 -2px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
tr.sub td { background: var(--surface-2); font-weight: 600; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
.neg { color: var(--crit); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }

.pipeline { display: flex; gap: 8px; flex-wrap: wrap; }
.pipe { display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.pipe b { font-family: var(--f-mono); } .pipe span.mono { font-size: 12px; color: var(--muted); }

.alert-row { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .bar { align-self: stretch; border-radius: 2px; background: var(--muted); }
.alert-row.critico .bar { background: var(--crit); } .alert-row.attenzione .bar { background: var(--warn); }
.alert-row.da_verificare .bar { background: var(--info); } .alert-row.positivo .bar { background: var(--pos); }
.alert-row .cat { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.chart-box { position: relative; height: 260px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }

/* ------------------------------------------------ AI */
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: min(78vh, 820px); min-height: 480px; }
.chat-log { overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 78ch; padding: 12px 14px; border-radius: 12px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent-soft); }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.msg .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.msg ul, .msg ol { padding-left: 20px; margin: 6px 0; }
.msg p { margin: 6px 0; }
.chat-input { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-input textarea { min-height: 46px; height: 46px; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.suggest button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 5px 11px; cursor: pointer; font-size: 12.5px; }
.agent-list { display: grid; gap: 6px; }
.agent { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 11px; cursor: pointer; }
.agent.on { border-color: var(--accent); background: var(--accent-soft); }
.agent b { display: block; font-size: 13px; } .agent span { font-size: 12px; color: var(--muted); }
.lock { font-size: 11px; color: var(--warn); }

/* ------------------------------------------------ modale, toast, login */
.modal-bg { position: fixed; inset: 0; background: rgba(6, 10, 20, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal header h3 { font-family: var(--f-display); font-size: 20px; font-weight: 600; }
.modal .body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 9px; max-width: 360px; box-shadow: var(--shadow); font-size: 13px; }
.toast.err { background: var(--crit); color: #fff; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font: 12px/1.5 var(--f-mono); max-height: 55vh; white-space: pre; }

.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login .hero { background: var(--side-bg); color: var(--side-ink); padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; gap: 22px; justify-content: center; }
.login .hero h1 { font-family: var(--f-display); color: #fff; font-size: clamp(30px, 4.4vw, 52px); line-height: 1.08; font-weight: 600; }
.login .hero p { max-width: 52ch; color: var(--side-ink); font-size: 15px; }
.login .hero ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13.5px; }
.login .hero li::before { content: "—  "; color: var(--side-gold); }
.login .form { padding: clamp(24px, 5vw, 64px); display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 520px; width: 100%; margin: 0 auto; }
.login .form h2 { font-family: var(--f-display); font-size: 26px; font-weight: 600; }

.score { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; }
.ring { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 84px; height: 84px; border-radius: 50%; background: var(--surface); display: grid; place-items: center;
  font: 600 26px var(--f-mono); }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; font-size: 13px; }
.kv div:nth-child(even) { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.banner { background: var(--accent-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--r); padding: 10px 14px; font-size: 13px; }


/* ------------------------------------------------ navigazione per aree, barra superiore */
.nav-area { margin-top: 4px; }
.nav-area-h { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: 0; cursor: pointer;
  color: var(--side-ink); padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 600; letter-spacing: .02em; text-align: left; }
.nav-area-h:hover { background: var(--side-active); color: #fff; }
.nav-area-h i { font-style: normal; color: var(--side-muted); }
.nav-area.open .nav-area-h { color: var(--side-gold); }
.nav-area .nav { padding: 2px 0 8px 8px; border-left: 1px solid #22304d; margin-left: 12px; }
.nav-sec { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); padding: 10px 10px 4px; }
.search-wrap { flex: 0 1 280px; min-width: 150px; }
.search-wrap input { border-radius: 99px; padding-left: 14px; }
.bell .badge, .btn .badge { background: var(--crit); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 6px; font-weight: 600; }

/* ------------------------------------------------ elenchi, filtri, kanban */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters > input { max-width: 300px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-f { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 3px 11px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.chip-f.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; transition: outline-color .15s; outline: 2px dashed transparent; }
.kcol.over { outline-color: var(--accent); }
.kcol-h { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 2px 4px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; display: grid; gap: 3px; font-size: 13px; }
.kcard:hover { border-color: var(--accent); }
.kcard[draggable="true"] { cursor: grab; }
.kempty { color: var(--muted); text-align: center; padding: 14px 0; font-size: 12px; }

/* ------------------------------------------------ scheda record */
.ro { padding: 7px 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-2); min-height: 36px; color: var(--ink); white-space: pre-wrap; }
.lines { display: grid; gap: 8px; }
.ltable td { padding: 4px; border-bottom: 0; }
.ltable th { padding: 4px 6px; }
.ltable input, .ltable select { padding: 5px 7px; min-width: 70px; }
.ltable .ro { padding: 5px 7px; min-height: 30px; }
details.access { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
details.access summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.rec-tools { display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ------------------------------------------------ panoramiche di area */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; cursor: pointer;
  display: grid; gap: 4px; align-content: start; color: var(--ink); }
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tile-n { font: 600 22px var(--f-mono); color: var(--accent); }
.tile-n small { font: 12px var(--f-body); color: var(--muted); }
.tile.tog { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 10px; }
.tile.tog input { width: auto; margin-top: 3px; grid-row: span 2; }
.rmx { display: grid; grid-template-columns: 22px minmax(0, 260px); grid-template-rows: auto auto; gap: 4px; margin: 6px 0; }
.rmx-y { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; color: var(--muted); text-align: center; }
.rmx-g { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; aspect-ratio: 1; }
.rmx-c { border-radius: 4px; display: grid; place-items: center; font: 600 13px var(--f-mono); background: var(--surface-2); }
.rmx-c.pos { background: var(--pos-soft); color: var(--pos); } .rmx-c.info { background: var(--info-soft); color: var(--info); }
.rmx-c.warn { background: var(--warn-soft); color: var(--warn); } .rmx-c.crit { background: var(--crit-soft); color: var(--crit); }
.rmx-x { grid-column: 2; font-size: 11px; color: var(--muted); text-align: center; }
.gantt { display: grid; gap: 6px; margin: 10px 0; }
.g-row { display: grid; grid-template-columns: minmax(110px, 190px) minmax(0, 1fr); gap: 10px; align-items: center; cursor: pointer; }
.g-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-track { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; }
.g-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 5px; background: var(--info); color: #fff; font: 600 11px var(--f-mono); display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; }
.g-bar.in_corso, .g-bar.avviato { background: var(--accent); color: var(--accent-ink); }
.g-bar.completato, .g-bar.chiuso { background: var(--pos); }
.g-bar.sospeso, .g-bar.bloccato { background: var(--crit); }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding-left: 22px; position: relative; }
.org-tree { padding-left: 0; }
.org-tree ul { border-left: 1px solid var(--line); margin-left: 12px; }
.org-tree li { padding: 6px 0 0 12px; position: relative; }
.org-tree ul > li::before { content: ""; position: absolute; left: -22px; top: 22px; width: 30px; border-top: 1px solid var(--line); }
.org-node { display: inline-grid; gap: 2px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; background: var(--surface); min-width: 220px; }
.org-node > b { font-size: 13.5px; }
.org-people { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.org-people span { font-size: 11.5px; background: var(--surface-2); border-radius: 99px; padding: 1px 8px; }
.utree, .utree ul { list-style: none; margin: 0; padding-left: 18px; }
.utree { padding-left: 0; }
.utree ul { border-left: 1px dashed var(--line); }
.unit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; }
.unit:hover { background: var(--surface-2); }
.unit-act { margin-left: auto; display: flex; gap: 4px; opacity: .55; }
.unit:hover .unit-act, .unit:focus-within .unit-act { opacity: 1; }
.timeline { display: grid; gap: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.tl { position: relative; padding: 8px 0 8px 18px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.tl::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.tl-d { font: 12px var(--f-mono); color: var(--muted); min-width: 90px; }
.levels { display: grid; gap: 10px; margin-top: 10px; }
.levels > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: start; }
.lv { font: 600 12px var(--f-mono); background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 3px 8px; text-align: center; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; margin: 6px 0 12px; }

/* ------------------------------------------------ area personale e agenda */
.clock-big { font: 600 22px var(--f-display); margin: 8px 0 4px; color: var(--muted); }
.clock-big.in { color: var(--pos); }
.note { border-left: 3px solid var(--line); padding: 6px 12px; margin: 8px 0; }
.note.pin { border-color: var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.note p { margin: 4px 0 0; }
.cal-wrap { overflow-x: auto; padding: 12px; }
.cal { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); min-width: 860px; }
.cal-h { font-size: 12px; font-weight: 600; text-align: center; padding: 6px 4px; border-bottom: 1px solid var(--line); text-transform: capitalize; }
.cal-h.today { color: var(--accent); }
.cal-hours > div { height: 44px; font: 11px var(--f-mono); color: var(--muted); padding-right: 6px; text-align: right; transform: translateY(-7px); }
.cal-day { position: relative; border-left: 1px solid var(--line); display: grid; grid-auto-rows: 44px; }
.cal-day > i { border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.cal-ev { position: absolute; left: 3px; right: 3px; border: 0; border-left: 3px solid var(--info); background: var(--info-soft); color: var(--ink);
  border-radius: 6px; padding: 3px 6px; text-align: left; font-size: 11.5px; overflow: hidden; cursor: pointer; display: grid; align-content: start; line-height: 1.3; }
.cal-ev span { color: var(--muted); font-size: 11px; }
.cal-ev.conf { border-left-color: var(--accent); background: var(--accent-soft); }
.cal-ev.k-cda, .cal-ev.k-board, .cal-ev.k-consiglio { border-left-color: var(--crit); }
.cal-ev.k-promemoria, .cal-ev.k-scadenza { border-left-color: var(--warn); background: var(--warn-soft); }
.hits { display: grid; gap: 6px; margin-top: 10px; }
.hit { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.hit:hover { border-color: var(--accent); }

/* ------------------------------------------------ editor documenti */
.ed-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ed-head select { width: auto; }
.ed-title { flex: 1; min-width: 220px; font: 600 22px var(--f-display); border-color: transparent; background: transparent; }
.ed-title:hover, .ed-title:focus { border-color: var(--line); background: var(--surface); }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.ed-bar { position: sticky; top: 58px; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.ed-bar select { width: auto; padding: 4px 8px; }
.ed-bar button { border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 9px; cursor: pointer; min-width: 32px; }
.ed-bar button:hover { background: var(--surface-2); border-color: var(--line); }
.page { background: #fff; color: #1a1a1a; max-width: 820px; min-height: 70vh; margin: 0 auto; padding: 56px 64px; border-radius: 4px;
  box-shadow: var(--shadow); border: 1px solid var(--line); font: 15px/1.65 Georgia, "Times New Roman", serif; outline: none; }
.page h1, .page h2, .page h3 { font-family: var(--f-display); margin: 1em 0 .4em; }
.page table { border: 1px solid #ccc; margin: 10px 0; } .page td, .page th { border: 1px solid #ccc; color: #1a1a1a; text-transform: none; letter-spacing: 0; font-size: 13px; }
.page blockquote { border-left: 3px solid #c9b27a; margin: 10px 0; padding: 2px 14px; color: #444; }
.ed-ai { position: sticky; top: 58px; display: grid; gap: 10px; }
.ed-ai-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 190px; }
.menu-list button { background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }

/* ------------------------------------------------ amministrazione e playground */
.agent-card { display: grid; gap: 6px; align-content: start; }
.agent-card h2 { font-family: var(--f-display); font-size: 19px; }
.pg-list { max-height: 78vh; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; align-content: start; }
.pg-list > * { min-width: 0; }
.pg-list .nav-sec { color: var(--muted); }
.pg-op { display: flex; gap: 8px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 5px 6px; border-radius: 6px; cursor: pointer; overflow: hidden; }
.pg-op:hover, .pg-op.on { background: var(--surface-2); }
.pg-op .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-req { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 8px; }
.m { font: 600 10.5px var(--f-mono); padding: 2px 6px; border-radius: 4px; min-width: 50px; text-align: center; flex: none; }
.m-GET { background: var(--info-soft); color: var(--info); } .m-POST { background: var(--pos-soft); color: var(--pos); }
.m-PUT { background: var(--warn-soft); color: var(--warn); } .m-DELETE { background: var(--crit-soft); color: var(--crit); }

/* ------------------------------------------------ lingua */
.lang-switch { display: flex; gap: 4px; }
.lang-switch .lang { flex: 1; padding: 4px 8px; font-size: 12px; border-radius: 6px; cursor: pointer; background: transparent; border: 1px solid var(--line); color: inherit; }
.side-foot .lang-switch .lang { border-color: #2a3756; color: var(--side-ink); }
.lang-switch .lang.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.login .form .lang-switch { justify-content: flex-end; }
.login .form .lang-switch .lang { flex: 0 0 auto; }

/* ------------------------------------------------ plugin e connettori */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.conn-card { display: grid; gap: 6px; align-content: start; }
.conn-card h2 { font-family: var(--f-display); font-size: 19px; }
.conn-card .actions { margin-top: 6px; }
.conn-code { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.conn-code .code { font-size: clamp(28px, 5vw, 40px); font-weight: 600; letter-spacing: .16em; color: var(--accent); }

/* ------------------------------------------------ portale clienti e fornitori */
.app.portal .side { background: linear-gradient(180deg, var(--side-bg), #101d36); }
.app.portal .tile-n { font-size: 26px; }

@media (max-width: 1100px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-wide { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px); z-index: 40; transform: translateX(-100%); transition: transform .2s; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .app.drawer .side { transform: none; box-shadow: 0 0 0 100vmax rgba(6, 10, 20, .5); }
  .top .burger { display: inline-flex; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .ed-grid { grid-template-columns: 1fr; } .ed-ai, .ed-bar { position: static; }
  .page { padding: 28px 20px; }
  .pg-req { grid-template-columns: 90px minmax(0, 1fr); } .pg-req > :last-child { grid-column: 1 / -1; }
  .search-wrap { order: 9; flex-basis: 100%; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 70px; } .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------------ assistente sempre presente */
.spark { color: var(--accent); font-size: 15px; line-height: 1; }
.cmdbar { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 6px 8px 6px 14px; border-radius: 99px; cursor: text;
  background: var(--surface); border: 1.5px solid var(--accent); color: var(--muted); box-shadow: 0 0 0 4px var(--accent-soft); text-align: left; }
.cmdbar:hover { color: var(--ink); }
.cmdbar .cmd-l { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdbar kbd, .as-hint kbd { font: 11px var(--f-mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; color: var(--muted); }
.search-wrap { flex: 0 1 380px; }
.ai-fab { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 55; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 99px; border: 0; cursor: pointer; background: var(--side-bg); color: #fff; font-weight: 600; box-shadow: 0 10px 30px rgba(8, 14, 30, .35); }
.ai-fab .spark { color: var(--side-gold); font-size: 18px; }
.ai-fab:hover { transform: translateY(-1px); }
.assist { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(460px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(8, 14, 30, .22); animation: as-in .18s ease-out; }
.assist[hidden] { display: none; }
@keyframes as-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
body.assist-open .main { margin-right: 460px; }
.as-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px; border-bottom: 1px solid var(--line); }
.as-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.as-title .spark { font-size: 22px; }
.as-title b { font-family: var(--f-display); font-size: 18px; white-space: nowrap; }
.as-page { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.as-hbtn { display: flex; gap: 2px; }
.as-bar { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.as-modes { display: flex; background: var(--surface-2); border-radius: 99px; padding: 3px; gap: 2px; }
.as-modes button { border: 0; background: none; padding: 4px 10px; border-radius: 99px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.as-modes button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.as-bar select { flex: 1; min-width: 140px; font-size: 12.5px; padding: 5px 8px; }
.as-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.as-welcome { display: grid; gap: 12px; }
.as-hello { font-family: var(--f-display); font-size: 24px; font-weight: 600; }
.as-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.as-sugg button { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px; cursor: pointer; font-size: 13px; }
.as-sugg button:hover { border-color: var(--accent); }
.as-follow button { font-size: 12px; padding: 5px 9px; }
.as-tips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.as-tips div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 12px; display: grid; }
.as-tips b { font-size: 12.5px; }
.as-tips span { color: var(--muted); }
.as-msg { padding: 10px 12px; border-radius: 12px; line-height: 1.55; max-width: 100%; overflow-wrap: anywhere; }
.as-msg.user { align-self: flex-end; background: var(--accent-soft); max-width: 88%; }
.as-msg.ai { background: var(--surface-2); border: 1px solid var(--line); }
.as-msg.err { border-color: var(--crit); }
.as-msg p { margin: 5px 0; }
.as-msg ul, .as-msg ol { padding-left: 18px; margin: 5px 0; }
.as-ctx { font-size: 11px; color: var(--muted); margin-top: 4px; }
.as-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.as-tools { margin-left: auto; display: flex; gap: 4px; }
.as-tools button { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 11.5px; padding: 2px 4px; }
.as-hits { display: grid; gap: 6px; margin-top: 8px; }
.as-hit { display: grid; text-align: left; gap: 1px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 12.5px; }
.as-hit:hover { border-color: var(--accent); }
.as-hit span:last-child { color: var(--muted); font-size: 12px; }
.as-k { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.as-typing i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 3px; animation: as-dot 1s infinite; }
.as-typing i:nth-child(2) { animation-delay: .15s; } .as-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes as-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.as-pop { margin: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.as-item { display: flex; gap: 10px; width: 100%; text-align: left; padding: 8px 12px; border: 0; background: none; cursor: pointer; align-items: flex-start; }
.as-item.on, .as-item:hover { background: var(--accent-soft); }
.as-ic { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--accent); flex: none; }
.as-foot { padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: grid; gap: 6px; }
.as-sel label { display: flex; gap: 6px; align-items: center; font-size: 12.5px; background: var(--info-soft); border-radius: 8px; padding: 5px 8px; }
.as-input { display: flex; gap: 6px; align-items: flex-end; border: 1.5px solid var(--accent); border-radius: 14px; padding: 6px; background: var(--surface); }
.as-input textarea { flex: 1; border: 0; outline: 0; resize: none; min-height: 36px; max-height: 160px; padding: 7px 6px; background: none; box-shadow: none; }
.as-mic { border: 0; background: var(--surface-2); border-radius: 10px; width: 38px; height: 36px; cursor: pointer; font-size: 16px; }
.as-mic.rec { background: var(--crit); color: #fff; animation: as-dot 1s infinite; }
.as-hint { text-align: center; }
@media (max-width: 1200px) { body.assist-open .main { margin-right: 0; } }
@media (max-width: 900px) {
  .cmdbar kbd { display: none; }
  .assist { width: 100vw; border-left: 0; }
  .ai-fab .ai-fab-l { display: none; }
  .ai-fab { padding: 14px 16px; }
  .as-hint { display: none; }
}
@media (max-width: 600px) { .as-tips { grid-template-columns: 1fr; } }
.modal-hbtn { display: flex; gap: 4px; align-items: center; }
/* ------------------------------------------------------------------ conversazione a voce e grafici nell'assistente */
.search-wrap { display: flex; gap: 6px; align-items: center; }
.cmd-talk, .ai-talk { border: 0; cursor: pointer; display: grid; place-items: center; flex: none; }
.cmd-talk { width: 38px; height: 38px; border-radius: 50%; background: var(--side-bg); color: #fff; font-size: 16px; box-shadow: 0 0 0 4px var(--accent-soft); }
.ai-talk { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(max(20px, env(safe-area-inset-bottom)) + 58px); z-index: 55;
  width: 46px; height: 46px; border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 19px; border: 1.5px solid var(--accent); box-shadow: 0 8px 24px rgba(8, 14, 30, .22); }
.cmd-talk:hover, .ai-talk:hover { transform: translateY(-1px); }
.ai-talk.on, .cmd-talk.on { background: var(--crit); color: #fff; }
body.assist-open .ai-talk { display: none; }
.as-talkbtn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 42px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--side-bg); color: #fff; font-weight: 600; font-size: 14.5px; }
.as-talkbtn:hover { filter: brightness(1.15); }
.as-talkbtn.on { background: var(--crit); }
.as-wave { display: inline-flex; gap: 2px; align-items: center; height: 14px; }
.as-wave i { width: 3px; height: 100%; background: currentColor; border-radius: 2px; animation: as-wave .9s ease-in-out infinite; }
.as-wave i:nth-child(2) { animation-delay: .15s; } .as-wave i:nth-child(3) { animation-delay: .3s; }
@keyframes as-wave { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.as-talk { display: flex; align-items: center; gap: 10px; margin: 0 14px 8px; padding: 10px 12px; border-radius: 14px; background: var(--side-bg); color: #fff; }
.as-talk[hidden] { display: none; }
.as-talk .btn { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); }
.as-talk .btn.danger { background: var(--crit); border-color: var(--crit); }
.as-talk-x { flex: 1; min-width: 0; display: grid; }
.as-talk-x span { font-size: 12px; color: var(--side-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-orb { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(214, 178, 94, .18); }
.as-orb i { width: 16px; height: 16px; border-radius: 50%; background: var(--side-gold); }
.as-talk[data-phase="listen"] .as-orb { animation: as-pulse 1.3s ease-out infinite; }
.as-talk[data-phase="think"] .as-orb i { animation: as-dot 1s infinite; }
.as-talk[data-phase="speak"] .as-orb i { animation: as-wave .7s ease-in-out infinite; border-radius: 4px; width: 6px; }
@keyframes as-pulse { 0% { box-shadow: 0 0 0 0 rgba(214, 178, 94, .55); } 100% { box-shadow: 0 0 0 14px rgba(214, 178, 94, 0); } }
.as-vtag { font-size: 12px; }
.as-vset { display: grid; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.as-vset[hidden] { display: none; }
.as-vrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.as-vrow > b { min-width: 132px; }
.as-vrow select { flex: 1; min-width: 160px; font-size: 12.5px; padding: 4px 8px; }
.as-vrow input[type="range"] { flex: 1; max-width: 180px; accent-color: var(--accent); }
.as-seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 2px; gap: 2px; }
.as-seg button { border: 0; background: none; padding: 3px 10px; border-radius: 99px; cursor: pointer; font-size: 12px; color: var(--muted); }
.as-seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.as-hbtn .btn.on { background: var(--accent-soft); }
.as-tools button.on { font-weight: 700; }
.as-chart { margin: 10px 0 2px; padding: 8px 10px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.as-chart figcaption { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 4px; }
.as-legend { display: inline-flex; gap: 10px; color: var(--muted); font-size: 11.5px; }
.as-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.as-chart svg { width: 100%; height: auto; display: block; }
.as-chart text { font: 9.5px var(--f-body); fill: var(--muted); }
@media (max-width: 900px) { .ai-talk { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 62px); } .as-vrow > b { min-width: 0; width: 100%; } }
@media (max-width: 600px) { .cmd-talk { width: 34px; height: 34px; } }
@media (min-width: 1201px) { body.assist-open .modal-bg { padding-right: 476px; } }
/* ------------------------------------------------------------------ chat tra colleghi */
.chat-top { position: relative; }
.cchat { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100dvh - 128px); min-height: 460px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: -34px; }
.ch-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--surface); }
.ch-lh { display: flex; justify-content: space-between; align-items: flex-end; padding: 14px 14px 8px; }
.ch-lh h1 { font-family: var(--f-display); font-size: 26px; font-weight: 600; line-height: 1.1; }
.ch-list > input { margin: 0 12px 8px; width: auto; border-radius: 99px; }
.ch-rooms { flex: 1; overflow-y: auto; padding: 0 6px 8px; }
.ch-room { display: flex; gap: 10px; width: 100%; padding: 9px 8px; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; align-items: center; color: inherit; }
.ch-room:hover { background: var(--surface-2); }
.ch-room.on { background: var(--accent-soft); }
.ch-rm { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ch-rt, .ch-rp { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.ch-rt b, .ch-rp > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sep { padding: 10px 8px 4px; text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; }
.ch-notif { margin: 6px 12px 12px; }
.ch-avw { position: relative; flex: none; }
.ch-av { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex: none; }
.ch-av.grp { border-radius: 12px; }
.ch-av.sm { width: 28px; height: 28px; font-size: 11px; }
.ch-av.ghost { visibility: hidden; }
.ch-av-co { background: var(--side-bg); color: var(--side-gold); font-size: 18px; border-radius: 12px; }
.ch-on { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #2fb36d; border: 2px solid var(--surface); }
.ch-on.static { position: static; display: inline-block; margin-left: auto; }
.ch-online { color: var(--pos); font-weight: 600; }
.ch-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.ch-main.drop::after { content: "Rilascia per inviare"; position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 85%, transparent); font-weight: 600; color: var(--accent); }
.ch-empty { margin: auto; text-align: center; display: grid; gap: 6px; padding: 30px; }
.ch-empty-i { font-size: 40px; }
.ch-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ch-ht { flex: 1; min-width: 0; display: grid; }
.ch-ht b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-hb { display: flex; gap: 6px; }
.ch-back { display: none; font-size: 22px; padding: 0 8px; }
.ch-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.ch-day { text-align: center; margin: 12px 0 6px; }
.ch-day span { font-size: 11.5px; background: var(--surface-2); color: var(--muted); padding: 3px 10px; border-radius: 99px; }
.ch-sys { text-align: center; margin: 6px 0; }
.ch-more { text-align: center; }
.ch-row { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.ch-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.ch-b { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 7px 10px 5px; min-width: 64px; overflow-wrap: anywhere; }
.ch-row.mine .ch-b { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); border-radius: 14px 14px 4px 14px; }
.ch-who { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.ch-text { line-height: 1.45; font-size: 14px; }
.ch-text a { color: var(--info); }
.ch-meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; display: flex; gap: 4px; justify-content: flex-end; }
.ch-tick.read { color: var(--info); font-weight: 700; }
.ch-quote { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--surface-2) 70%, transparent); padding: 4px 8px; border-radius: 6px; margin-bottom: 4px; display: grid; font-size: 12.5px; }
.ch-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-acts { position: absolute; top: -14px; right: 6px; display: none; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 1px 4px; box-shadow: var(--shadow); }
.ch-row.mine .ch-acts { right: auto; left: 6px; }
.ch-b:hover .ch-acts, .ch-b:focus-within .ch-acts { display: flex; }
.ch-acts button { border: 0; background: none; cursor: pointer; padding: 2px 5px; font-size: 13px; color: var(--muted); }
.ch-acts button:hover { color: var(--accent); }
.ch-img { display: block; border: 0; padding: 0; background: var(--surface-2); border-radius: 10px; overflow: hidden; cursor: zoom-in; margin: 2px 0 4px; min-width: 120px; min-height: 80px; }
.ch-img img { display: block; max-width: min(320px, 100%); max-height: 320px; object-fit: cover; }
.ch-video video { display: block; max-width: min(360px, 100%); max-height: 320px; border-radius: 10px; background: #000; margin: 2px 0 4px; }
.ch-play { display: flex; gap: 8px; align-items: center; border: 0; border-radius: 10px; background: var(--side-bg); color: #fff; padding: 22px 18px; cursor: pointer; margin: 2px 0 4px; }
.ch-play span:first-child { font-size: 20px; color: var(--side-gold); }
.ch-audio { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
.ch-audio audio { height: 36px; max-width: 260px; }
.ch-nofile { opacity: .55; }
.ch-nofile::after { content: "anteprima: file di esempio"; font-size: 11px; color: var(--muted); padding: 6px; }
.ch-file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px 8px 8px; cursor: pointer; text-align: left; margin: 2px 0 4px; color: inherit; }
.ch-ext { width: 38px; height: 44px; border-radius: 6px; background: var(--crit-soft); color: var(--crit); display: grid; place-items: center; font: 600 10.5px var(--f-mono); flex: none; }
.ch-typing { min-height: 18px; padding: 0 16px; }
.ch-replybar { display: flex; gap: 8px; align-items: center; margin: 0 12px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 8px; }
.ch-replybar[hidden] { display: none; }
.ch-replybar div { flex: 1; min-width: 0; display: grid; font-size: 12.5px; }
.ch-replybar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-comp { display: flex; gap: 6px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); flex-wrap: wrap; }
.ch-comp textarea { flex: 1; min-width: 120px; resize: none; min-height: 40px; max-height: 140px; border-radius: 12px; padding: 9px 12px; }
.ch-ib { border: 0; background: var(--surface-2); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; font-size: 17px; flex: none; }
.ch-ib:hover { background: var(--accent-soft); }
.ch-ib.rec { background: var(--crit); color: #fff; }
.ch-comp.recording > :not(.ch-recbar) { display: none; }
.ch-recbar { display: flex; gap: 10px; align-items: center; width: 100%; }
.ch-recbar .small { flex: 1; }
.ch-recdot { width: 12px; height: 12px; border-radius: 50%; background: var(--crit); animation: as-dot 1s infinite; }
.ch-toast { display: flex; gap: 10px; align-items: center; text-align: left; border: 0; cursor: pointer; }
.ch-toast .ch-av { width: 30px; height: 30px; font-size: 11px; }
.ch-tabs { margin-bottom: 2px; }
.ch-picks { display: grid; gap: 2px; max-height: 340px; overflow-y: auto; margin-top: 8px; }
.ch-pick { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.ch-pick:hover { background: var(--surface-2); }
.ch-pick > span { flex: 1; }
.ch-pick[hidden] { display: none; }
[data-rm].on { color: var(--crit); }
#ch-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.assist-open .cchat { grid-template-columns: 250px minmax(0, 1fr); }
body[data-view="chat"] .ai-fab, body[data-view="chat"] .ai-talk { display: none; }   /* in chat l'assistente resta in alto */
@media (max-width: 600px) { .ch-bl { display: none; } .ch-hb .btn { padding: 6px 9px; } }
@media (max-width: 900px) {
  .cchat { grid-template-columns: 1fr; height: calc(100dvh - 150px); border-radius: 12px; }
  .cchat .ch-main { display: none; }
  .cchat.has-room .ch-list { display: none; }
  .cchat.has-room .ch-main { display: flex; }
  .ch-back { display: inline-block; }
  .ch-row { max-width: 92%; }
  .ch-acts { display: flex; position: static; box-shadow: none; border: 0; background: none; padding: 0; justify-content: flex-end; }
  .chat-top .chat-l { display: none; }
}
.ch-rp .badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 600; flex: none; }

/* ---------- proprietario della piattaforma */
.sa-banner { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px;
  background: #fff4d6; color: #5c4200; border-bottom: 1px solid #e8c766; font-size: 13px; }
.sa-banner b { font-weight: 700; } .sa-banner .sp { flex: 1; }
.sa-banner button { background: #5c4200; color: #fff; border: 0; border-radius: 8px; padding: 5px 12px; cursor: pointer; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sa-banner { background: #3a2e0a; color: #f5dc8f; border-color: #6b5517; }
  :root:not([data-theme="light"]) .sa-banner button { background: #f5dc8f; color: #3a2e0a; } }
:root[data-theme="dark"] .sa-banner { background: #3a2e0a; color: #f5dc8f; border-color: #6b5517; }
:root[data-theme="dark"] .sa-banner button { background: #f5dc8f; color: #3a2e0a; }
.sa-env { font-family: var(--f-mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- azioni dell'AI da confermare */
.ai-act { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warn); display: grid; gap: 8px; }
.ai-act[data-st="confirmed"] { border-left-color: var(--pos); }
.ai-act[data-st="rejected"] { border-left-color: var(--line); opacity: .8; }
.ai-act-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-act-ic { font-size: 16px; }
.ai-act-txt { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; font-size: 13.5px; line-height: 1.5; }
.ai-act-txt.md { white-space: normal; }
.ai-kv { font-size: 13px; }
.ai-act .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-acts { display: grid; gap: 14px; margin-top: 14px; max-width: 860px; }
.ai-act-row .ai-act { margin-top: 4px; }
.doc-ai-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--line); border-left: 3px solid var(--warn); }
.doc-ai-banner .sp { flex: 1; }
.ai-kv { grid-template-columns: auto minmax(0, 1fr); }
.ai-kv div:nth-child(even) { text-align: left; font-family: inherit; }
.ai-kv div:nth-child(odd) { color: var(--muted); }

/* ---------------------------------------------------------------- agenti AI operativi */
.ag-grid { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.ag-card.off { opacity: .7; }
.ag-routines { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ag-cmd { display: grid; gap: 8px; margin-top: 6px; }
.ag-cmd textarea { min-height: 70px; width: 100%; resize: vertical; }
.ag-cmd .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ag-cmd .spacer { flex: 1; }
.ag-cmd [data-mic].on { color: var(--crit); border-color: var(--crit); }
.ag-files { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-files .lnk { background: none; border: 0; cursor: pointer; color: inherit; padding: 0 0 0 4px; }
.ag-working { padding: 10px 0; }
.ag-run { margin-top: 12px; }
.ag-prompt { font-style: italic; color: var(--muted); margin-top: 4px; }
.ag-steps { display: grid; gap: 2px; margin-top: 8px; }
.ag-step, .ag-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.ag-step:first-child { border-top: 0; }
.ag-item-b b { display: block; margin-top: 2px; }
.ag-body { white-space: pre-wrap; margin-top: 8px; max-height: 220px; overflow: auto; }
.ag-bulk { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ag-areas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.ag-areas a { text-decoration: none; }
.ag-quick { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) {
  .ag-step, .ag-item { grid-template-columns: auto minmax(0, 1fr); }
  .ag-step .actions, .ag-item .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------------------------------------------------------------- chatbot e assistenza AI (1.9) */
.bx-wrap { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.bx-list { padding: 6px; max-height: calc(100vh - 260px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.bx-item { text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; padding: 9px 10px; cursor: pointer; color: var(--ink); display: grid; gap: 3px; }
.bx-item:hover { background: var(--surface-2); }
.bx-item.on { border-color: var(--accent); background: var(--accent-soft); }
.bx-l1 { display: flex; justify-content: space-between; gap: 8px; }
.bx-l2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bx-l3 { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.bx-panel { display: flex; flex-direction: column; }
.bx-msgs { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 420px); min-height: 200px; overflow-y: auto; padding: 8px 2px; }
.bx-m { max-width: 80%; padding: 9px 12px; border-radius: 12px; line-height: 1.5; border: 1px solid var(--line); background: var(--surface-2); }
.bx-m p { margin: 0 0 4px; }
.bx-m.user { align-self: flex-start; background: var(--surface); }
.bx-m.bot { align-self: flex-end; background: var(--info-soft); border-color: transparent; }
.bx-m.agent { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bx-m.note { align-self: center; background: var(--warn-soft); border-style: dashed; max-width: 92%; }
.bx-who { color: var(--muted); margin-bottom: 3px; }
.bx-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); }
.bx-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.bx-comp { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.bx-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.bx-tools select { width: auto; }
.bx-back { display: none; }
.bw-prev { position: relative; min-height: 420px; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px); border-radius: var(--r); padding: 16px; }
.bw-win { width: min(320px, 100%); margin-left: auto; background: #fff; color: #131a2c; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); overflow: hidden; }
.bw-win.dark { background: #111a2d; color: #e7eaf2; }
.bw-h { background: var(--bw); color: #fff; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.bw-av { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; overflow: hidden; }
.bw-av img { width: 100%; height: 100%; object-fit: cover; }
.bw-b { padding: 12px; min-height: 180px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.bw-m { background: rgba(127, 127, 127, .12); padding: 8px 11px; border-radius: 12px; font-size: 13.5px; }
.bw-s { border: 1px solid var(--bwa); color: inherit; padding: 4px 10px; border-radius: 99px; font-size: 12.5px; }
.bw-i { border-top: 1px solid rgba(127, 127, 127, .25); padding: 11px 14px; color: #8a93a6; font-size: 13px; }
.bw-l { position: absolute; right: 16px; bottom: 16px; background: var(--bw); color: #fff; border-radius: 99px; padding: 10px 16px; font-weight: 600; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }
.bw-l.left { right: auto; left: 16px; }
@media (max-width: 900px) {
  .bx-wrap { grid-template-columns: 1fr; }
  .bx-wrap.has-conv .bx-list { display: none; }
  .bx-wrap:not(.has-conv) .bx-conv { display: none; }
  .bx-back { display: inline-flex; margin-right: 6px; }
  .bx-list, .bx-msgs { max-height: none; }
  .bx-m { max-width: 92%; }
  .bx-tools .btn, .bx-tools select { flex: 1 1 auto; }
}
