/* Cremona Srl · Gestionale AI — tema chiaro */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0d2238;
  --ink-2: #3c4f66;
  --muted: #6b7c93;
  --faint: #97a6ba;
  --line: #e6ebf1;
  --line-2: #eef2f6;
  --soft: #f6f9fc;
  --hover: #f5f8fb;

  --accent: #0095d6;
  --accent-ink: #0079b3;
  --accent-soft: #e9f6fc;
  --accent-line: #bfe3f4;
  --navy: #003566;
  --green: #7bba4d;

  --ok: #3f7d1e;
  --ok-soft: #eef7e8;
  --warn: #a8670a;
  --warn-soft: #fdf5e6;
  --bad: #c0392b;
  --bad-soft: #fdf0ee;
  --info: #0079b3;
  --info-soft: #e9f6fc;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 34, 56, 0.04);
  --shadow-md: 0 1px 2px rgba(13, 34, 56, 0.04), 0 6px 18px -6px rgba(13, 34, 56, 0.08);
  --shadow-lg: 0 24px 60px -12px rgba(13, 34, 56, 0.22), 0 2px 6px rgba(13, 34, 56, 0.06);
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --side-w: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; }
a:not([class]) { color: var(--accent-ink); text-decoration: none; }
a:not([class]):hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.ic { flex: none; display: inline-block; vertical-align: -3px; }

/* ---------------------------------------------------------------- guscio */
.shell { min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.side-brand { display: grid; gap: 6px; padding: 24px 22px 18px; text-decoration: none; }
.side-brand img { width: 140px; height: auto; display: block; }
.side-brand span { font-size: 12px; color: var(--muted); letter-spacing: 0.01em; padding-left: 2px; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; }
.side-sec { margin-top: 14px; }
.side-label { font-size: 11.5px; font-weight: 500; color: var(--faint); padding: 0 10px 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0; border-radius: 7px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.side-nav a .ic { color: var(--faint); transition: color 0.12s; }
.side-nav a:hover { background: var(--hover); color: var(--ink); }
.side-nav a:hover .ic { color: var(--muted); }
.side-nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.side-nav a.on .ic { color: var(--accent); }
.side-foot { border-top: 1px solid var(--line); padding: 14px 16px 16px; }
.side-user { display: flex; gap: 10px; align-items: center; }
.side-user b { display: block; font-size: 13px; font-weight: 500; line-height: 1.3; }
.side-user span:not(.avatar) { font-size: 12px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--accent-soft), #eaf5e1); color: var(--accent-ink); font-size: 12px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent-line); }
.side-note { margin: 12px 0 0; font-size: 11.5px; color: var(--faint); }
.side-scrim { display: none; }

.content { margin-left: var(--side-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1304px; margin: 0 auto; padding: 0 32px; height: 60px; display: flex; align-items: center; gap: 12px; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; min-width: 0; }
.crumb b { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.crumb .crumb-sep { color: var(--faint); }
.spacer { flex: 1; }
.search { position: relative; display: flex; align-items: center; width: 300px; max-width: 34vw; color: var(--faint); }
.search .ic { position: absolute; left: 11px; pointer-events: none; }
.search input { width: 100%; height: 34px; padding: 0 12px 0 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; box-shadow: var(--shadow); }
.search input::placeholder { color: var(--faint); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.hamburger { display: none; }
.btn.btn-copilot { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.btn.btn-copilot:hover { background: #dff1fa; }
.btn.btn-copilot .ic { color: var(--accent); }

main { max-width: 1304px; margin: 0 auto; padding: 32px 32px 72px; }

/* ---------------------------------------------------------------- tipografia e blocchi base */
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 600; color: var(--ink); }
h2 { font-size: 14.5px; line-height: 1.4; margin: 0 0 14px; font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 28px; max-width: 760px; font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num, .money { font-variant-numeric: tabular-nums; }
.money { white-space: nowrap; }
.right { text-align: right; }
.empty { color: var(--muted); text-align: center; padding: 36px 8px; font-size: 13px; }
.card.empty { padding: 48px 16px; }
.sep { height: 1px; background: var(--line); margin: 18px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .lead { margin: 0; }

/* bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 13.5px; font-weight: 500; line-height: 1; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(13, 34, 56, 0.05);
  cursor: pointer; text-decoration: none; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--hover); border-color: #dbe2ea; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 149, 214, 0.22); }
.btn .ic { color: var(--muted); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 2px rgba(0, 90, 140, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn.primary .ic { color: #fff; }
.btn.primary:hover { background: #0088c4; border-color: #0088c4; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger:hover { background: #a93226; }
.btn:disabled { opacity: 0.5; cursor: default; }
label.btn { cursor: pointer; }

/* campi */
select, input[type='text'], input[type='password'], input[type='number'], input[type='date'], input[type='email'], input[type='search'], textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; width: 100%; font-size: 13.5px; color: var(--ink);
  box-shadow: var(--shadow); transition: border-color 0.12s, box-shadow 0.12s;
}
select { height: 36px; padding: 0 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 149, 214, 0.15); }
input:disabled { background: var(--soft); color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; line-height: 1.55; }
label.f { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* pillole, puntini, etichette */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--ink-2); white-space: nowrap; line-height: 1; }
.pill .ic { vertical-align: 0; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.pill .dot { opacity: 0.85; }
.tag { display: inline-flex; align-items: center; height: 20px; font-size: 11.5px; padding: 0 7px; border-radius: 5px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.ai-badge { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 500; color: var(--accent-ink); }
.ai-badge .ic { color: var(--accent); }

/* schede (tab) */
.tabs { display: inline-flex; padding: 3px; background: var(--line-2); border-radius: 9px; gap: 2px; flex-wrap: wrap; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(13, 34, 56, 0.08), 0 0 0 1px rgba(13, 34, 56, 0.03); }
.tabs.big { margin-bottom: 20px; }

/* tabelle */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td .btn { height: 30px; padding: 0 11px; font-size: 13px; }
td.row { display: table-cell; }
td.row .btn + .btn { margin-left: 6px; }
tr.fresh td { animation: flash 2.5s ease; }
@keyframes flash { from { background: var(--ok-soft); } }
pre.code { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12px; margin: 0; }

/* chiave/valore */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- dashboard */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-head h1 { font-size: 26px; }
.dash-head .lead { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 18px 20px 14px; display: grid; gap: 2px; align-content: start; }
.kpi > span { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi b { display: block; font-size: 26px; line-height: 1.25; letter-spacing: -0.025em; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi em { font-style: normal; font-size: 12.5px; color: var(--muted); display: block; margin-top: 2px; }
.kpi .spark { margin-top: 10px; height: 40px; }
.kpi .spark svg { display: block; width: 100%; height: 40px; overflow: visible; }
.kpi.accent b { color: var(--bad); }
.delta { font-variant-numeric: tabular-nums; font-weight: 500; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.meter { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--line-2); margin-top: 12px; }
.meter i { display: block; height: 100%; }
.meter-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.meter-legend span { display: inline-flex; align-items: center; gap: 6px; }
.meter-legend .dot { width: 7px; height: 7px; }

.dgrid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 16px; }
.dgrid > .s8 { grid-column: span 8; }
.dgrid > .s7 { grid-column: span 7; }
.dgrid > .s6 { grid-column: span 6; }
.dgrid > .s5 { grid-column: span 5; }
.dgrid > .s4 { grid-column: span 4; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.big-num { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.sq { width: 8px; height: 8px; border-radius: 2px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); margin: 18px -24px -22px; }
.stat-strip > div { padding: 14px 24px; border-right: 1px solid var(--line); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip span { display: block; font-size: 12px; color: var(--muted); }
.stat-strip b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-strip em { font-style: normal; font-size: 12px; margin-left: 6px; }
.stat-strip em span { display: inline; }

/* grafici */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 11.5px Inter, system-ui, sans-serif; fill: var(--faint); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .cross { stroke: #c9d3df; stroke-width: 1; stroke-dasharray: 3 3; shape-rendering: crispEdges; opacity: 0; transition: opacity 0.12s; }
.chart .hover-dot { opacity: 0; transition: opacity 0.12s; }
.chart.hovering .cross, .chart.hovering .hover-dot { opacity: 1; }
.chart .bar { transition: opacity 0.15s; }
.chart.hovering .bar-g:not(.on) .bar { opacity: 0.45; }
.ch-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-md);
  padding: 9px 12px; font-size: 12.5px; opacity: 0; transform: translateY(4px); transition: opacity 0.12s, transform 0.12s;
}
.chart.hovering .ch-tip { opacity: 1; transform: none; }
.ch-tip .t { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.ch-tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.ch-tip .r + .r { margin-top: 3px; }
.ch-tip .r span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.ch-tip .r b { font-weight: 600; }
.ch-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes growx { from { transform: scaleX(0); } }
.anim .line-path { stroke-dasharray: 1; animation: draw 1.1s cubic-bezier(0.4, 0, 0.2, 1) both; }
.anim .area-path { animation: fade 1.2s 0.2s ease both; }
.anim .bar { transform-box: fill-box; transform-origin: bottom; animation: grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.anim .spark-line { stroke-dasharray: 1; animation: draw 1s ease both; }
.anim .spark-area { animation: fade 1s 0.2s ease both; }

/* ciambella */
.donut-wrap { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 22px; align-items: center; }
.donut-wrap svg { width: 168px; height: 168px; display: block; }
.donut-center b { font-size: 17px; font-weight: 600; fill: var(--ink); letter-spacing: -0.02em; }
.donut-legend { display: grid; gap: 10px; }
.donut-legend > div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.donut-legend i { width: 8px; height: 8px; border-radius: 2px; }
.donut-legend span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend b { font-weight: 500; font-variant-numeric: tabular-nums; }
.donut-legend em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 6px; }

/* pipeline */
.funnel { display: grid; gap: 12px; }
.funnel-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 92px; gap: 14px; align-items: center; font-size: 13px; }
.funnel-row .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-row .lbl em { font-style: normal; color: var(--faint); margin-left: 6px; font-variant-numeric: tabular-nums; }
.funnel-row .track { height: 22px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.funnel-row .track i { display: block; height: 100%; border-radius: 5px; transform-origin: left; }
.anim .funnel-row .track i { animation: growx 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.funnel-row .val { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* avvisi "da fare" */
.alerts { display: grid; }
.alert {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) auto 64px; gap: 14px; align-items: center;
  padding: 12px 4px; text-decoration: none; border-bottom: 1px solid var(--line-2); font-size: 13.5px; color: var(--ink);
  transition: background 0.1s;
}
.alert:last-child { border-bottom: 0; }
.alert:hover { background: var(--hover); }
.alert > .dot { width: 7px; height: 7px; color: var(--accent); }
.alert.bad > .dot { color: var(--bad); }
.alert.warn > .dot { color: #e0a030; }
.alert.ok > .dot { color: var(--green); }
.alert time { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.alert .tag { justify-self: end; }

/* ---------------------------------------------------------------- liste, schede, dettaglio */
.list { display: grid; gap: 2px; }
.item { display: grid; gap: 3px; padding: 11px 12px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; width: 100%; transition: background 0.1s; }
.item:hover { background: var(--hover); }
.item.on { background: var(--accent-soft); border-color: var(--accent-line); }
.item .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
#list > .item[style*='cursor:default'] { border: 1px solid var(--line); background: var(--panel); padding: 14px; margin-bottom: 8px; }
#list > .item[style*='cursor:default']:hover { background: var(--panel); }
.split { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.box { padding: 16px; border-radius: 10px; background: var(--soft); border: 1px solid var(--line-2); }
.card.box { padding: 22px 24px; }
.box.ai { background: linear-gradient(180deg, #f3fafe, var(--panel) 85%); border: 1px solid var(--accent-line); }
.box.ok { background: var(--ok-soft); border-color: #d7ebc9; }
.box.late { background: linear-gradient(180deg, var(--bad-soft), var(--panel) 85%); border-color: #f3cfc9; }
.hist { display: grid; gap: 0; }
.hist > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; font-size: 13.5px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.hist > div:last-child { border-bottom: 0; }
.hist > div > div > .ic { color: var(--muted); margin-right: 4px; }
.hist time { font-size: 12px; color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.hist details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.hist pre { white-space: pre-wrap; font: 12px/1.55 var(--mono); background: var(--soft); border: 1px solid var(--line-2); padding: 12px; border-radius: 8px; max-height: 260px; overflow: auto; }
.progress { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 999px; }
.steps { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line-2); }
.step:last-child { border-bottom: 0; }
.step .chk { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #cdd6e1; display: grid; place-items: center; cursor: pointer; background: var(--panel); padding: 0; color: #fff; transition: all 0.12s; }
.step .chk:hover { border-color: var(--accent); }
.step.done .chk { background: var(--green); border-color: var(--green); }
.step.done .lbl { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.step.late .lbl { color: var(--bad); }
.step.late > span.small { color: var(--bad); }
.drop { border: 1.5px dashed #cdd6e1; border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color 0.15s, background 0.15s; background: var(--soft); }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fgrid .wide { grid-column: 1 / -1; }
.cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 16px; align-items: start; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.flow div { padding: 12px; border-radius: 10px; background: var(--soft); font-size: 12.5px; }
.flow div b { display: block; font-size: 13px; }
.flow div.on { background: var(--ok-soft); }

/* modale, toast, spinner */
.modal-bg { position: fixed; inset: 0; background: rgba(13, 34, 56, 0.28); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade 0.15s ease; }
.modal { width: min(820px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); border-radius: 14px; padding: 26px 28px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow-lg); animation: fadein 0.25s ease; max-width: calc(100% - 32px); font-size: 13.5px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot 0.8s linear infinite; vertical-align: -2px; opacity: 0.7; }
@keyframes rot { to { transform: rotate(360deg); } }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------------------------------------------------------------- linea clienti */
.client { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: start; }
.phone { display: grid; gap: 18px; }
.orb-wrap { display: grid; place-items: center; padding: 26px 0 8px; }
.orb { width: 136px; height: 136px; border-radius: 50%; background: radial-gradient(circle at 34% 28%, #ffffff, #bfe6f7 22%, var(--accent) 62%, var(--navy)); box-shadow: 0 22px 60px -10px rgba(0, 149, 214, 0.45); transition: transform 0.25s ease, filter 0.25s; }
.orb.idle { filter: grayscale(0.55) opacity(0.5); box-shadow: 0 12px 30px -12px rgba(13, 34, 56, 0.25); }
.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.08); } }
.call-state { text-align: center; color: var(--muted); min-height: 21px; font-size: 13.5px; }
.call-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.call-actions .btn { min-width: 160px; height: 40px; border-radius: 999px; }
.transcript { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; align-content: start; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 14px; background: var(--line-2); white-space: pre-wrap; font-size: 13.5px; }
.bubble.me { justify-self: end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { border-bottom-left-radius: 4px; }
.bubble.op { background: var(--ok-soft); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble small { display: block; font-size: 11px; opacity: 0.75; margin-bottom: 2px; }
.chat-form { display: flex; gap: 8px; }
.typing { color: var(--muted); font-size: 12.5px; min-height: 18px; margin-top: 6px; }
.feed { display: grid; gap: 12px; }
.feed-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; animation: fade 0.35s ease; }
.feed-item .ic-wrap, .feed-item .ic:not(svg) { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.feed-item b { font-weight: 500; }
.feed-item .mono { color: var(--muted); word-break: break-word; }
.hint { display: grid; gap: 8px; font-size: 13px; padding-left: 18px; margin: 0; }

/* ---------------------------------------------------------------- ufficio */
.ops { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
.conv-list { display: grid; gap: 2px; max-height: calc(100vh - 220px); overflow-y: auto; padding: 6px; }
.conv { display: grid; gap: 5px; padding: 12px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; transition: background 0.1s; }
.conv:hover { background: var(--hover); }
.conv.on { background: var(--accent-soft); border-color: var(--accent-line); }
.conv.alert { border-color: #f0b9b1; background: var(--bad-soft); animation: pulse 1.6s ease-in-out 3; display: grid; grid-template-columns: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(192, 57, 43, 0.12); } }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.detail { display: grid; gap: 16px; }
.handoff { border: 1px solid #f3d3a8; background: linear-gradient(180deg, var(--warn-soft), var(--panel) 75%); }
.handoff h2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.handoff h2 > .ic { color: var(--warn); }
.timeline { display: grid; gap: 12px; font-size: 13.5px; }
.timeline > div { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; }
.timeline time { color: var(--muted); font-size: 12px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.timeline .ic { color: var(--accent); margin-right: 4px; }
.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; }

/* ---------------------------------------------------------------- accesso */
body.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #e6f4fb, transparent 60%), var(--bg); }
body.login-page main { padding: 24px 16px; width: 100%; }
.login { max-width: 380px; margin: 0 auto; padding: 36px 32px 28px; box-shadow: var(--shadow-lg); border-radius: 16px; }
.login-logo { display: grid; justify-items: center; gap: 10px; margin-bottom: 28px; text-align: center; }
.login-logo img { width: 180px; height: auto; }
.login-logo span { font-size: 12.5px; color: var(--muted); }
.login .btn.primary { height: 40px; }

/* ---------------------------------------------------------------- contratto (stampa) */
.contract { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 48px; max-width: 820px; margin: 0 auto; font-size: 14px; line-height: 1.7; box-shadow: var(--shadow-md); }
.contract h1 { font-size: 20px; margin: 4px 0; }
.contract h3 { font-size: 14px; margin: 20px 0 4px; }
.contract .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.contract .signs span { display: block; border-bottom: 1px solid var(--ink); height: 40px; }
body.print main { max-width: 900px; }
@media print { .noprint, .side, .topbar, .side-scrim { display: none !important; } .content { margin: 0 !important; } body { background: #fff; } .contract { border: 0; padding: 0; box-shadow: none; } }

/* ---------------------------------------------------------------- architettura (eventuale) */
.arch svg { width: 100%; height: auto; display: block; }
.arch .box { fill: var(--panel); stroke: var(--line); }
.arch text { fill: var(--ink); font: 13px Inter, system-ui, sans-serif; }
.arch text.s { fill: var(--muted); font-size: 11px; }
.map td:first-child { font-weight: 500; white-space: nowrap; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dgrid > .s8, .dgrid > .s7, .dgrid > .s6, .dgrid > .s5, .dgrid > .s4 { grid-column: span 12; }
  .search { width: 220px; }
  .split { grid-template-columns: minmax(230px, 290px) minmax(0, 1fr); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: none; }
  .shell.open .side { transform: none; box-shadow: var(--shadow-lg); }
  .shell.open .side-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(13, 34, 56, 0.25); }
  .content { margin-left: 0; }
  .hamburger { display: inline-grid; }
  .topbar-in { padding: 0 16px; height: 56px; gap: 10px; }
  .search { display: none; }
  .btn.btn-copilot { padding: 0 11px; }
  main { padding: 22px 16px 56px; }
  h1 { font-size: 22px; }
  .client, .ops, .two, .cols, .cols3, .split, .fgrid, .flow { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conv-list { max-height: 300px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { margin-top: 8px; }
  .card { padding: 18px; }
  .stat-strip { margin: 16px -18px -18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > div { padding: 12px 18px; border-bottom: 1px solid var(--line); }
  .stat-strip > div:nth-child(2n) { border-right: 0; }
  .alert { grid-template-columns: 8px minmax(0, 1fr) 54px; gap: 10px; }
  .alert .tag { display: none; }
  .contract { padding: 20px; }
  .hist > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .table-wrap table { min-width: 640px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .btn.btn-copilot span { display: none; }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .donut-legend { width: 100%; }
  .funnel-row { grid-template-columns: 110px minmax(0, 1fr) 76px; gap: 10px; font-size: 12.5px; }
  .funnel-row .lbl em { display: none; }
}

/* chiave/valore in schede strette (es. con il pannello del copilota aperto) */
.two > .card, .split .card, .detail > .card, .cols .card { container-type: inline-size; }
@container (max-width: 380px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { margin-top: 8px; }
}

/* pannello del copilota: nascosto finché non arriva il suo foglio di stile (evita il lampo al caricamento) */
aside.copilot:not(.is-inline) { position: fixed; opacity: 0; pointer-events: none; }

/* righe e schede strette: il testo lungo si accorcia invece di uscire dalla colonna */
.card, .item, .cols > *, .cols3 > *, .grid > * { min-width: 0; }
.item .top-line > b { min-width: 0; flex: 1 1 auto; }
.item .top-line > .pill { flex: none; }
.item .row { min-width: 0; }

/* ---------------------------------------------------------------- menu laterale sospeso (30/10)
   Una barra di sole icone, staccata dai bordi e non a tutta altezza; passando il mouse si apre con le etichette
   e si richiude da sola quando il mouse esce. Sul telefono resta il menu con l'hamburger. */
@media (min-width: 901px) {
  .content { margin-left: 92px; }
  .side {
    inset: auto; top: 14px; left: 14px; width: 64px; max-height: calc(100vh - 28px);
    border: 1px solid var(--line); border-radius: 18px;
    background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(14px);
    box-shadow: 0 8px 28px rgba(16, 42, 67, 0.07);
    overflow: hidden;
    transition: width 0.26s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.26s;
  }
  .side:hover, .side:focus-within { width: 236px; box-shadow: 0 20px 50px rgba(16, 42, 67, 0.14); }
  .side-brand { padding: 18px 0 10px 19px; gap: 4px; }
  .side-brand img { width: 132px; max-width: none; clip-path: inset(0 calc(100% - 21px) 0 0); transition: clip-path 0.26s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .side:hover .side-brand img, .side:focus-within .side-brand img { clip-path: inset(0 0 0 0); }
  .side-nav { padding: 2px 10px 10px; overflow-x: hidden; }
  .side-sec { margin-top: 8px; }
  .side-sec + .side-sec { border-top: 1px solid var(--line-2, #eef2f6); padding-top: 8px; }
  .side-nav a { padding: 8px 12px; gap: 12px; white-space: nowrap; }
  .side-foot { padding: 10px 15px 12px; }
  .side-note { display: none; }
  .side-brand span, .side-label, .side-nav a span, .side-user div {
    opacity: 0; white-space: nowrap; transition: opacity 0.12s;
  }
  .side-label { height: 0; padding: 0 12px; overflow: hidden; transition: opacity 0.12s, height 0.2s; }
  .side:hover :is(.side-brand span, .side-label, .side-nav a span, .side-user div),
  .side:focus-within :is(.side-brand span, .side-label, .side-nav a span, .side-user div) { opacity: 1; transition-delay: 0.1s; }
  .side:hover .side-label, .side:focus-within .side-label { height: 22px; }
  .side:hover .side-sec + .side-sec, .side:focus-within .side-sec + .side-sec { border-top-color: transparent; }
}
/* il copilota ora è un pulsante in basso: niente pulsante in alto */
#copilot-open { display: none !important; }

/* ---------------------------------------------------------------- dashboard più fine (30/10) */
h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.025em; }
h2 { font-size: 13.5px; font-weight: 500; }
.kpi { padding: 16px 18px 12px; }
.kpi > span { font-size: 12.5px; font-weight: 400; }
.kpi b { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.kpi em { font-size: 12px; }
.kpi .spark, .kpi .spark svg { height: 32px; }
.chart text { font-size: 10.5px; font-weight: 400; }
.donut-wrap { grid-template-columns: 150px minmax(0, 1fr); }
.donut-wrap svg { width: 150px; height: 150px; }
.donut-legend > div { font-size: 12.5px; }
.donut-legend b { font-weight: 400; }
.card { box-shadow: 0 1px 2px rgba(16, 42, 67, 0.03); }
.funnel { gap: 14px; }
.funnel-row { font-size: 12.5px; }
.funnel-row .track { height: 8px; border-radius: 99px; }
.funnel-row .track i { border-radius: 99px; }
.funnel-row .val { font-weight: 400; }
