:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #111214;
  --muted: #6b6f76;
  --line: #e6e6e2;
  --soft: #f0f0ec;
  --accent: #c74634; /* rosso Oracle, usato con parsimonia */
  --accent-soft: #fbeae7;
  --ok: #1f8a5b;
  --ok-soft: #e4f4ec;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --info: #2f5bd3;
  --info-soft: #e8eefc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --panel: #16181b;
    --ink: #ececea;
    --muted: #9a9ea6;
    --line: #26292e;
    --soft: #1d2024;
    --accent: #ef6a57;
    --accent-soft: #3a1f1b;
    --ok: #4cc38a;
    --ok-soft: #14291f;
    --warn: #e3a948;
    --warn-soft: #2e2414;
    --info: #7a9cff;
    --info-soft: #1a2240;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap; }
.brand i { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #f0a35e); display: inline-block; }
.brand em { font-style: normal; color: var(--muted); font-weight: 400; }
.top nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.top nav a:hover { color: var(--ink); background: var(--soft); }
.top nav a.on { color: var(--ink); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.top .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--accent-soft); color: var(--accent); }
.pill.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 760px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
select, input[type='text'], input[type='password'], textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; }
textarea { resize: vertical; }
label.f { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 32px 8px; }
.sep { height: 1px; background: var(--line); margin: 16px 0; }

/* ---- cliente ---- */
.client { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: start; }
.phone { display: grid; gap: 18px; }
.tabs { display: inline-flex; padding: 3px; background: var(--soft); border-radius: 999px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.orb-wrap { display: grid; place-items: center; padding: 18px 0 6px; }
.orb { width: 148px; height: 148px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd2b0, var(--accent) 55%, #6d1f16); box-shadow: 0 20px 60px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform 0.25s ease; }
.orb.idle { filter: grayscale(0.85) opacity(0.55); box-shadow: none; }
.orb.listening { animation: breathe 2.4s ease-in-out infinite; }
.orb.speaking { animation: talk 0.5s ease-in-out infinite alternate; }
@keyframes breathe { 50% { transform: scale(1.04); } }
@keyframes talk { from { transform: scale(1.02); } to { transform: scale(1.09); } }
.call-state { text-align: center; color: var(--muted); min-height: 21px; }
.call-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.call-actions .btn { min-width: 160px; padding: 11px 18px; border-radius: 999px; }
.transcript { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 14px; background: var(--soft); white-space: pre-wrap; }
.bubble.me { justify-self: end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
.bubble.bot { border-bottom-left-radius: 4px; }
.bubble.op { background: var(--info-soft); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble small { display: block; font-size: 11px; opacity: 0.7; margin-bottom: 2px; }
.chat-form { display: flex; gap: 8px; }
.typing { color: var(--muted); font-size: 12px; min-height: 18px; }
.feed { display: grid; gap: 10px; }
.feed-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; animation: fadein 0.35s ease; }
.feed-item .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); font-size: 14px; }
.feed-item b { font-weight: 600; }
.feed-item .mono { color: var(--muted); word-break: break-word; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.hint { display: grid; gap: 6px; font-size: 13px; }
.hint li { margin-left: -6px; }

/* ---- operatore ---- */
.ops { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
.conv-list { display: grid; gap: 6px; max-height: calc(100vh - 170px); overflow-y: auto; padding: 8px; }
.conv { display: grid; gap: 4px; padding: 12px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.conv:hover { background: var(--soft); }
.conv.on { background: var(--soft); border-color: var(--line); }
.conv.alert { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.6s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent); } }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { display: grid; gap: 16px; }
.handoff { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--panel) 70%); }
.handoff h2 { display: flex; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.timeline { display: grid; gap: 8px; font-size: 13px; }
.timeline div { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
.timeline time { color: var(--muted); font-family: var(--mono); font-size: 11px; padding-top: 2px; }

/* ---- fusion ---- */
.fusion-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; flex-wrap: wrap; margin-bottom: 20px; }
.ofusion { display: flex; align-items: center; gap: 10px; }
.ofusion span { font-weight: 600; letter-spacing: -0.01em; }
.ofusion i { font-style: normal; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--accent); color: #fff; letter-spacing: 0.04em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.fresh td { animation: flash 2.5s ease; }
@keyframes flash { from { background: var(--ok-soft); } }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; font-weight: 600; }
.stat span { color: var(--muted); font-size: 12px; }
pre.code { background: var(--soft); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12px; margin: 0; }

/* ---- architettura ---- */
.arch svg { width: 100%; height: auto; display: block; }
.arch .box { fill: var(--panel); stroke: var(--line); }
.arch .box.o { stroke: var(--accent); }
.arch .box.h { stroke: var(--info); }
.arch text { fill: var(--ink); font: 13px Inter, system-ui, sans-serif; }
.arch text.s { fill: var(--muted); font-size: 11px; }
.arch .ln { stroke: var(--muted); stroke-width: 1.5; fill: none; marker-end: url(#arr); }
.arch .tag { font-size: 10px; letter-spacing: 0.06em; }
.map td:first-child { font-weight: 500; white-space: nowrap; }

.login { max-width: 360px; margin: 12vh auto; }

@media (max-width: 900px) {
  .client, .ops, .two { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conv-list { max-height: 300px; }
  .top { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .top .spacer { display: none; }
  main { padding: 20px 16px 48px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { margin-top: 6px; }
}
