/* Pollon · interfaccia di gestione. Tema chiaro/scuro con variabili. */
:root {
  --serie-1: #2a78d6; --serie-2: #eb6834; --serie-3: #6250d6; /* grafici: palette validata (CVD ok) */
  --bg: #f5f4f1; --surface: #ffffff; --surface-2: #faf9f7; --surface-3: #f0eee9;
  --text: #1d1c1a; --muted: #6d6a64; --faint: #9a968f; --border: #e6e3dd; --border-strong: #d6d2ca;
  --accent: #8a2d3c; --accent-hover: #74232f; --accent-soft: #f6e9eb; --accent-text: #ffffff;
  --ok: #2f7d4f; --ok-soft: #e6f3eb; --warn: #a36207; --warn-soft: #fbf0dc; --err: #b42318; --err-soft: #fbe9e7;
  --info: #2c5f9e; --info-soft: #e7eef8;
  --bubble-guest: #f0eee9; --bubble-agent: #f6e9eb;
  --shadow: 0 1px 2px rgba(20, 18, 15, .05), 0 4px 16px rgba(20, 18, 15, .04);
  --shadow-lg: 0 12px 48px rgba(20, 18, 15, .18);
  --radius: 12px; --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #9085e9;
    --bg: #111012; --surface: #19181b; --surface-2: #1e1d21; --surface-3: #252428;
    --text: #ecebe8; --muted: #a29fa8; --faint: #77737d; --border: #2b2a2f; --border-strong: #3a3940;
    --accent: #d9707f; --accent-hover: #e48795; --accent-soft: #3a2228; --accent-text: #1a0d10;
    --ok: #5cc28a; --ok-soft: #1b3226; --warn: #e3a64a; --warn-soft: #3a2d17; --err: #f07a6e; --err-soft: #3d1f1c;
    --info: #79a8e6; --info-soft: #1c2a3d;
    --bubble-guest: #252428; --bubble-agent: #34212a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #9085e9;
  --bg: #111012; --surface: #19181b; --surface-2: #1e1d21; --surface-3: #252428;
  --text: #ecebe8; --muted: #a29fa8; --faint: #77737d; --border: #2b2a2f; --border-strong: #3a3940;
  --accent: #d9707f; --accent-hover: #e48795; --accent-soft: #3a2228; --accent-text: #1a0d10;
  --ok: #5cc28a; --ok-soft: #1b3226; --warn: #e3a64a; --warn-soft: #3a2d17; --err: #f07a6e; --err-soft: #3d1f1c;
  --info: #79a8e6; --info-soft: #1c2a3d;
  --bubble-guest: #252428; --bubble-agent: #34212a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; }
.brand b { font-size: 15px; display: block; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .sep { height: 1px; background: var(--border); margin: 10px 6px; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.theme { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-3); border-radius: var(--radius-sm); padding: 3px; }
.theme button { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.theme button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.main { min-width: 0; padding: 28px 36px 60px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.back:hover { color: var(--text); text-decoration: none; }
.mobile-top { display: none; }

/* ---------- componenti ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 42px 20px; }
.empty svg.i { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn svg.i { width: 16px; height: 16px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge svg.i { width: 13px; height: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-weight: 500; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: -2px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=email], input:not([type]), select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 14px var(--font); outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
textarea.code { font-family: var(--mono); font-size: 13px; line-height: 1.6; min-height: 520px; tab-size: 2; background: var(--surface-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fields { display: grid; gap: 16px; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 6px; font: 500 13px var(--font); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button svg.i { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }

.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row b { font-weight: 500; display: block; }
.toggle-row small { color: var(--muted); font-size: 12.5px; }

.range { display: flex; align-items: center; gap: 12px; }
.range input[type=range] { flex: 1; accent-color: var(--accent); }
.range output { font-family: var(--mono); font-size: 12.5px; min-width: 44px; text-align: right; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs svg.i { width: 15px; height: 15px; }

/* ---------- KPI ---------- */
.kpi { padding: 16px 18px; }
.kpi .lab { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12.5px; }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .col i { width: 100%; max-width: 34px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 3px; opacity: .85; }
.chart .col small { color: var(--faint); font-size: 11px; }

/* ---------- liste ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--border); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }
.item .ico.accent { background: var(--accent-soft); color: var(--accent); }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { display: flex; align-items: center; gap: 8px; flex: none; }

.pcard { padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 12px; transition: border-color .12s, transform .12s; }
.pcard:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.pcard .top { display: flex; gap: 12px; align-items: center; }
.pcard .av { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.pcard p { margin: 0; color: var(--muted); font-size: 13px; }
.pcard .foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.pcard.new { border-style: dashed; align-items: center; justify-content: center; color: var(--muted); min-height: 170px; box-shadow: none; background: transparent; }

/* ---------- trascrizione / chat ---------- */
.transcript { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.msg { display: flex; gap: 10px; max-width: 86%; }
.msg.agente { align-self: flex-start; }
.msg.ospite { align-self: flex-end; flex-direction: row-reverse; }
.msg .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; background: var(--accent-soft); color: var(--accent); }
.msg.ospite .av { background: var(--surface-3); color: var(--muted); }
.msg .bub { padding: 10px 14px; border-radius: 14px; background: var(--bubble-agent); white-space: pre-wrap; word-wrap: break-word; }
.msg.ospite .bub { background: var(--bubble-guest); }
.msg.agente .bub { border-top-left-radius: 4px; }
.msg.ospite .bub { border-top-right-radius: 4px; }
.msg .info { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 5px; font-size: 12px; color: var(--faint); }
.msg.ospite .info { justify-content: flex-end; }
.msg.flag .bub { box-shadow: 0 0 0 2px var(--warn); }
.msg.hl .bub { box-shadow: 0 0 0 2px var(--accent); }
.flagbox { margin-top: 8px; }
.flagbox textarea { min-height: 60px; font-size: 13px; }
.tool { display: flex; flex-direction: column; gap: 4px; align-self: flex-start; margin-left: 40px; max-width: 80%; }
.tool details { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 11px; font-size: 12.5px; }
.tool summary { cursor: pointer; display: flex; gap: 8px; align-items: center; color: var(--muted); list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool pre { margin: 8px 0 2px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: var(--text); max-height: 260px; overflow: auto; }
.checks { display: flex; flex-direction: column; }
.check { display: flex; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; cursor: default; }
.check:last-child { border-bottom: 0; }
.check[data-turno] { cursor: pointer; }
.check[data-turno]:hover { background: var(--surface-2); }
.check .dot { margin-top: 6px; }
.check small { display: block; color: var(--muted); }

.chatbox { display: flex; flex-direction: column; height: 620px; }
.chatbox .transcript { flex: 1; overflow-y: auto; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer input { flex: 1; }
.typing { color: var(--faint); font-style: italic; font-size: 13px; padding: 0 20px 8px; }

.split { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 20px; }
.split-r { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.qr-box { background: #fff; border-radius: 12px; padding: 12px; display: grid; place-items: center; min-height: 240px; color: #333; }
.pcard.new { min-height: 150px; }

/* ---------- diff ---------- */
.diff { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; max-height: 420px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.diff div { padding: 0 12px; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: var(--ok-soft); color: var(--ok); }
.diff .del { background: var(--err-soft); color: var(--err); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--err) 40%, transparent); }
.diff .gap { color: var(--faint); background: var(--surface-3); font-style: italic; }

/* ---------- modale / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 13, 12, .45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s; }
.modal.wide { width: min(980px, 100%); }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .16s; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--err); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 60px; }

.callout { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--text); font-size: 13.5px; align-items: flex-start; }
.callout svg.i { color: var(--info); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); } .callout.warn svg.i { color: var(--warn); }
.callout.ok { background: var(--ok-soft); } .callout.ok svg.i { color: var(--ok); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.copy { display: flex; gap: 6px; align-items: center; }
.copy code { flex: 1; padding: 7px 10px; background: var(--surface-3); border-radius: 6px; overflow-x: auto; white-space: nowrap; }
.lines-editor .line { display: flex; gap: 6px; margin-bottom: 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td input { height: 32px; font-size: 13px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split, .split-r { grid-template-columns: minmax(0, 1fr); } .sticky { position: static; } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .main { padding: 20px 16px 50px; }
  .g2, .g3, .fields.two, .fields.three { grid-template-columns: minmax(0, 1fr); }
  .msg { max-width: 96%; }
  .chatbox { height: 70vh; }
}

/* ---------- rifiniture ---------- */
.field .seg { align-self: flex-start; }
.tabs a { padding: 10px 11px; }
textarea[data-lines], textarea[data-occ-lines], .field textarea[data-k^="comportamento"] { field-sizing: content; min-height: 84px; max-height: 420px; }
h3 .i, h1 .i { vertical-align: -3px; }
.main { overflow-x: hidden; }
@media (max-width: 820px) {
  .head .actions { width: 100%; }
  .head .actions select { width: 100% !important; }
  .item { padding: 12px 14px; gap: 10px; }
  .item .meta .badge:not(:last-child) { display: none; }
  .tabs a { padding: 10px 9px; font-size: 13px; }
  .transcript { padding: 14px; }
}
.item .body > .badge { align-self: flex-start; }

/* grafici */
.grafico { position: relative; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .asse { stroke: var(--border); stroke-width: 1; }
.grafico .etichetta { fill: var(--muted); font-size: 11px; }
.grafico .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -110%); display: none; z-index: 2; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* profilo vivo (markdown) */
.md-profilo h2 { font-size: 20px; margin: 18px 0 8px; } .md-profilo h3 { font-size: 16px; margin: 20px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); } .md-profilo h4 { font-size: 14px; margin: 14px 0 4px; }
.md-profilo p, .md-profilo li { line-height: 1.6; } .md-profilo ul, .md-profilo ol { padding-left: 20px; margin: 6px 0; }
.md-profilo blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 6px; }
.md-profilo code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.tab-md { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; } .tab-md th, .tab-md td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; } .tab-md th { background: var(--surface-2); }

/* ---------- pannello chat con Pollon (a destra) ---------- */
.pn { display: none; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); position: sticky; top: 0; height: 100vh; min-width: 0; }
.pn.aperto { display: flex; }
.app.con-pannello { grid-template-columns: 236px minmax(0, 1fr) 400px; }
.pn-h { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); }
.pn-h b { display: block; } .pn-h small { color: var(--muted); font-size: 12px; }
.pn-h .spacer { flex: 1; }
.pn-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.pn-lista { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.pn-m { display: flex; flex-direction: column; max-width: 90%; }
.pn-m.tu { align-self: flex-end; align-items: flex-end; }
.pn-m.lui { align-self: flex-start; }
.pn-b { padding: 9px 13px; border-radius: 14px; background: var(--bubble-agent); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.pn-m.tu .pn-b { background: var(--bubble-guest); border-top-right-radius: 4px; }
.pn-m.lui .pn-b { border-top-left-radius: 4px; }
.pn-t { font-size: 11px; color: var(--faint); margin-top: 3px; }
.pn-tag { font-size: 11px; color: var(--accent); margin-top: 4px; }
.pn-f { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.pn-f textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; }
.pn-vuoto { margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; color: var(--muted); padding: 10px; }
.pn-vuoto svg.i { width: 28px; height: 28px; color: var(--accent); }
.pn-vuoto b { color: var(--text); }
.pn-esempi { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; width: 100%; }
.pn-scrive { display: flex; gap: 4px; padding: 13px 14px; }
.pn-scrive span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pn-pulse 1.2s infinite; }
.pn-scrive span:nth-child(2) { animation-delay: .2s; } .pn-scrive span:nth-child(3) { animation-delay: .4s; }
@keyframes pn-pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.pn-apri { position: fixed; right: 20px; bottom: 20px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 35; }
.pn-apri svg.i { width: 22px; height: 22px; }
.pn-apri.nascosto { display: none; }
/* schermi più stretti: il pannello si apre sopra la pagina */
@media (max-width: 1499px) {
  .app.con-pannello { grid-template-columns: 236px minmax(0, 1fr); }
  .pn.aperto { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); z-index: 45; box-shadow: var(--shadow-lg); }
}
@media (max-width: 820px) { .app.con-pannello { grid-template-columns: minmax(0, 1fr); } }
.pn-evidenzia { outline: 2px solid var(--accent) !important; outline-offset: 2px; transition: outline .2s; }

/* ---------- interfaccia compatta: tutto in una schermata, le liste lunghe scorrono dentro il loro riquadro ---------- */
body { font-size: 13px; }
h1 { font-size: 19px; } h2 { font-size: 14.5px; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.side { padding: 12px 10px; }
.brand { padding: 2px 8px 12px; }
.nav a { padding: 7px 10px; }
.nav .sep { margin: 6px 6px; }
.main { padding: 16px 22px 18px; max-width: none; height: 100vh; overflow-y: auto; scrollbar-width: none; }
.main::-webkit-scrollbar { display: none; }
.head { margin-bottom: 12px; gap: 12px; }
.head p { margin-top: 2px; font-size: 12.5px; }
.card-pad { padding: 12px 14px; }
.card-head { padding: 9px 14px; }
.card-head h2 { display: flex; align-items: center; gap: 7px; }
.card-head h2 svg.i { width: 16px; height: 16px; color: var(--accent); }
.grid, .stack { gap: 12px; }
.item { padding: 7px 14px; gap: 10px; }
.item .ico { width: 28px; height: 28px; border-radius: 8px; }
.item .ico svg.i { width: 15px; height: 15px; }
.kpi { padding: 10px 14px; }
.kpi .val { font-size: 21px; margin-top: 2px; }
.tabs a { padding: 7px 11px; }
.btn { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.sm { height: 28px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=email], input:not([type]), select { height: 34px; }
.empty { padding: 22px 14px; }
.empty.sm { padding: 14px; font-size: 12.5px; }
/* liste lunghe nelle pagine: scorrono dentro la scheda invece di allungare la pagina */
.main .card > .list { max-height: calc(100vh - 230px); overflow-y: auto; }

/* ---------- panoramica a schermata unica ---------- */
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dash { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 92px); min-height: 560px; }
.dash .dr { flex: 1; min-height: 0; }
.dk { color: var(--text); text-decoration: none !important; transition: border-color .12s; min-width: 0; }
.dk:hover { border-color: var(--accent); }
.dk .val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.dc-b { flex: 1; min-height: 0; overflow-y: auto; }
.dc-b .list { max-height: none; }
.dc .item { padding: 6px 14px; }
.dm { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px 14px; }
.dm a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; min-width: 0; }
.dm a:hover { border-color: var(--accent); }
.dm b { font-size: 17px; }
.dm span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart.sm { height: 70px; padding: 0 14px 10px; }
.chart.sm small { font-size: 10.5px; }
/* menu a gruppi */
.nav .nav-sez { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); opacity: .75; padding: 2px 10px 4px; }
/* Oggi: striscia "Da fare" */
.dafare { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
.dafare > b { display: flex; align-items: center; gap: 6px; }
.dafare-voce { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); text-decoration: none !important; font-size: 13px; }
.dafare-voce b { color: var(--accent); }
.dafare-voce:hover { outline: 1px solid var(--accent); }
/* Email: elenco + lettura affiancati */
.po-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); border-top: 1px solid var(--border); }
.po-grid > .list { max-height: calc(100vh - 250px); overflow-y: auto; border-right: 1px solid var(--border); }
.po-grid .item.on { background: var(--accent-soft); }
.po-lettura { padding: 16px 20px; max-height: calc(100vh - 250px); overflow-y: auto; min-width: 0; }
@media (max-width: 1000px) { .po-grid { grid-template-columns: 1fr; } .po-grid > .list { border-right: 0; max-height: 50vh; } .po-lettura { max-height: none; border-top: 1px solid var(--border); } }
@media (max-width: 1400px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .dm { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(260px, auto); } .dash { height: auto; } }
@media (max-width: 1100px) { .dash { height: auto; } .dash .dr { min-height: 320px; } }
@media (max-width: 820px) { .main { height: auto; overflow: visible; } .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .main .card > .list { max-height: none; } }

/* ---------- Skill ---------- */
.sk-cat { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; }
.sk-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sk-top { display: flex; align-items: center; gap: 10px; }
.sk-tit { flex: 1; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.sk-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.sk-prof { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 8px; }
.sk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.sk-row svg.i { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; color: var(--muted); }
.sk-stato { margin-left: 6px; }

/* ---------- Firma documenti ---------- */
.fd-home { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
.fd-lista { min-height: 200px; }
.fd-firma-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); min-height: 120px; display: grid; place-items: center; padding: 12px;
  background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.fd-firma-box img { max-width: 100%; max-height: 140px; }
:root[data-theme="dark"] .fd-firma-box img, :root:not([data-theme="light"]) .fd-firma-box img { filter: none; }
.fd-vuota { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); font-size: 13px; }
.fd-vuota svg.i { width: 26px; height: 26px; }
.fd-azioni { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.fd-ed canvas, .fd-scacchi canvas { max-width: 100%; max-height: 260px; display: block; margin: 0 auto; }
.fd-scacchi { border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; background: repeating-conic-gradient(#e9e7e2 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.fd-pad canvas { width: 100%; height: auto; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; }
.btn.disabled { opacity: .5; pointer-events: none; }
.fd-titolo { word-break: break-word; }
.fd-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 14px; height: calc(100vh - 170px); min-height: 420px; }
.fd-vista { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.fd-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.fd-bar .sp { flex: 1; }
.fd-mini { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; cursor: pointer; }
.fd-pagine { flex: 1; overflow: auto; padding: 14px; background: var(--surface-3); position: relative; }
.fd-pg { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.fd-pg canvas { width: 100%; height: 100%; display: block; }
.fd-num { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #666; background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 8px; }
.fd-sig { position: absolute; outline: 2px dashed var(--accent); outline-offset: 2px; cursor: move; touch-action: none; background: rgba(138,45,60,.05); }
.fd-sig.su { outline-style: solid; }
.fd-sig img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.fd-res { position: absolute; right: -7px; bottom: -7px; width: 13px; height: 13px; background: var(--accent); border: 2px solid #fff; border-radius: 50%; cursor: nwse-resize; }
.fd-del { position: absolute; right: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #333; color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }
.fd-txt { position: absolute; color: #000; font-family: Helvetica, Arial, sans-serif; white-space: pre; cursor: move; outline: 1px dashed var(--accent); touch-action: none; line-height: 1; }
.fd-lato { display: flex; flex-direction: column; gap: 12px; overflow: auto; min-height: 0; }
.fd-lato .card-pad { display: flex; flex-direction: column; gap: 8px; }
.fd-dove { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.fd-pieno { width: 100%; justify-content: center; }
.fd-storia { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; max-height: 160px; overflow: auto; }
.fd-storia svg.i { width: 13px; height: 13px; vertical-align: -2px; }
.fd-seg { width: 100%; }
.fd-seg button { flex: 1; }
.fd-docx { background: #fff; color: #111; max-width: 780px; margin: 0 auto; padding: 40px 48px; font: 13px/1.5 Calibri, Arial, sans-serif; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.fd-docx p { margin: 0 0 6px; }
.fd-docx p.tab { padding-left: 10px; border-left: 2px solid #eee; }
.fd-docx p.tit { font-weight: 700; font-size: 15px; margin-top: 12px; }
.fd-docx p.c { text-align: center; } .fd-docx p.r { text-align: right; }
.fd-docx .fd-firma { height: 50px; vertical-align: middle; outline: 2px dashed #8a2d3c; outline-offset: 3px; }
.fd-docx .fd-img { color: #999; font-size: 11px; }
@media (max-width: 1000px) { .fd-home, .fd-wrap { grid-template-columns: 1fr; height: auto; } .fd-pagine { max-height: 70vh; } }
[hidden] { display: none !important; }
.fd-home > * { min-width: 0; }
.fd-lista .item .body { min-width: 0; }
.fd-lista .item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-lista .item .meta { flex-shrink: 0; }
.fd-punti { display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow: auto; }
.fd-punto { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; line-height: 1.35; }
.fd-punto input { margin-top: 2px; }
.fd-punto small { display: block; color: var(--muted); font-size: 11px; }
.fd-ed2 { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; margin-bottom: 10px; }
.fd-ed2 > div > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fd-prima canvas { border-radius: var(--radius-sm); display: block; max-height: 260px; }
.fd-dopo .fd-scacchi { margin-bottom: 4px; min-height: 120px; display: grid; place-items: center; }
@media (max-width: 700px) { .fd-ed2 { grid-template-columns: 1fr; } }
.fd-cestino { margin-left: 2px; opacity: .6; } .fd-cestino:hover { opacity: 1; color: var(--err, #c33); }
/* grafici affiancati + popup grande */
.graf-coppia { align-items: stretch; }
.graf-testa { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.graf-grande { min-height: 340px; padding-bottom: 6px; }
.modal.wide:has(.graf-grande) { width: min(1280px, 96vw); }
.graf-coppia .grafico .etichetta { font-size: 21px; }
.graf-coppia .grafico svg circle { r: 5; }

/* ---------- Presentazioni ---------- */
.pz-home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pz-home > * { min-width: 0; }
.pz-stili { display: flex; flex-direction: column; }
.pz-stile { display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); cursor: pointer; }
.pz-stile:hover { background: var(--surface-2); }
.pz-mini { display: flex; gap: 3px; flex-shrink: 0; }
.pz-mini img { width: 64px; aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; background: var(--surface-3); border: 1px solid var(--border); }
.pz-attesa { width: 198px; aspect-ratio: 48/9; display: grid; place-items: center; background: var(--surface-3); border-radius: 4px; }
.pz-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pz-tit { display: flex; gap: 6px; align-items: center; }
.pz-pred { color: #d4a017; }
.pz-pal { display: flex; gap: 3px; }
.pz-pal span { width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.pz-thumb { width: 72px; flex-shrink: 0; display: grid; place-items: center; }
.pz-thumb img { width: 72px; aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); background: var(--surface-3); }
.pz-nomini { visibility: hidden; }
.pz-avanz { margin-bottom: 12px; font-size: 13px; }
.pz-avanz div { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.pz-avanz i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.pz-det { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.pz-det > * { min-width: 0; }
.pz-ul { margin: 0; padding-left: 18px; line-height: 1.55; font-size: 13px; }
.pz-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 14px; }
.pz-griglia figure { margin: 0; }
.pz-griglia img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-3); }
.pz-griglia figcaption { font-size: 12px; margin-top: 4px; line-height: 1.35; }
.pz-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 14px; height: calc(100vh - 170px); min-height: 420px; }
@media (max-width: 1000px) { .pz-home, .pz-det, .pz-wrap { grid-template-columns: 1fr; height: auto; } }
.pz-mini { align-items: flex-start; } .pz-mini img { height: auto; }
/* visualizzatore di file dal pannello */
.overlay.vf .modal { width: min(1100px, 96vw); height: calc(100vh - 40px); }
.overlay.vf .modal-body { flex: 1; min-height: 0; padding: 0; display: flex; }
.vf-pagine { flex: 1; height: auto; border-radius: 0; }
.vf-img { flex: 1; display: grid; place-items: center; padding: 14px; overflow: auto; background: var(--surface-3); } .vf-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

/* galleria foto del comportamento */
.gal-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gal-gruppo + .gal-gruppo { margin-top: 18px; }
.gal-gruppo h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted, inherit); font-weight: 600; }
.gal-foto { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2, transparent); display: flex; flex-direction: column; }
.gal-foto img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--surface-3); cursor: zoom-in; }
.gal-foto .gal-campi { padding: 8px; display: grid; gap: 6px; }
.gal-foto .gal-campi input, .gal-foto .gal-campi select { width: 100%; font-size: 12px; }
.gal-foto .gal-azioni { display: flex; gap: 4px; justify-content: flex-end; }
.gal-zoom img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 6px; }
