/* ===== Icone ===== */
.ic { width: 20px; height: 20px; }
.btn .ic, .chip .ic { width: 18px; height: 18px; }

/* ===== Pulsanti ===== */
.btn {
  --bh: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--bh); padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 650; font-size: var(--fs-md); line-height: 1; white-space: nowrap; text-decoration: none;
  transition: transform var(--d-press) var(--ease-out), background-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { --bh: 36px; padding: 0 12px; font-size: var(--fs-sm); border-radius: 10px; }
.btn-lg { --bh: 52px; padding: 0 24px; font-size: var(--fs-lg); border-radius: 14px; }
.btn-primary { background: var(--blu); color: #fff !important; box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 6px 16px -8px rgba(15, 78, 122, 0.7); }
.btn-accent { background: var(--corallo); color: var(--navy); box-shadow: var(--sh-coral); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--sh-1); }
.btn-quiet { background: transparent; color: var(--blu); }
.btn-danger { background: #C53A3A; color: #fff; }
.btn-wa { background: #128049; color: #fff; }
.btn-ghost-dark { background: rgba(255,255,255,0.1); color: #fff; }
.btn-block { width: 100%; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { background: var(--blu-700); }
  .btn-accent:hover:not(:disabled) { background: var(--corallo-600); }
  .btn-ghost:hover:not(:disabled) { border-color: var(--blu-chiaro-2); background: var(--surface-2); }
  .btn-quiet:hover:not(:disabled) { background: var(--blu-chiaro); }
  .btn-danger:hover:not(:disabled) { background: #AE3030; }
  .btn-wa:hover:not(:disabled) { background: #0E6B3C; }
  .btn-ghost-dark:hover { background: rgba(255,255,255,0.18); }
}

.btn-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  color: var(--ink-2);
  transition: transform var(--d-press) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.btn-icon:active { transform: scale(0.97); }
.btn-icon-sm { width: 32px; height: 32px; border-radius: 9px; }
.btn-icon-sm .ic { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .btn-icon:hover { background: var(--surface-3); color: var(--ink); } }
@media (pointer: coarse) { .btn-icon { width: 44px; height: 44px; } }

/* ===== Chip filtro ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -4px; padding-inline: 4px; overscroll-behavior-x: contain; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; white-space: nowrap;
  min-height: 36px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 600;
  transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.chip:active { transform: scale(0.97); }
.chip-n { font-family: var(--f-mono); font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); display: inline-grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.is-active .chip-n { background: rgba(255,255,255,0.16); color: #fff; }
.chip.tone-scaduto .chip-n { background: var(--st-scaduto-bg); color: var(--st-scaduto-t); }
.chip.tone-ricontatto .chip-n { background: var(--st-ricontatto-bg); color: var(--st-ricontatto-t); }
.chip.tone-attivo .chip-n { background: var(--st-attivo-bg); color: var(--st-attivo-t); }
.chip.is-active[class*="tone-"] .chip-n { background: rgba(255,255,255,0.2); color: #fff; }
@media (hover: hover) and (pointer: fine) { .chip:not(.is-active):hover { border-color: var(--blu-chiaro-2); color: var(--ink); } }
@media (pointer: coarse) { .chip { min-height: 40px; } }

/* ===== Badge di stato ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 650; line-height: 1;
  background: var(--b-bg); color: var(--b-t);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--b-c); color: var(--b-c); }
.st-attivo { --b-bg: var(--st-attivo-bg); --b-t: var(--st-attivo-t); --b-c: var(--st-attivo); }
.st-scaduto { --b-bg: var(--st-scaduto-bg); --b-t: var(--st-scaduto-t); --b-c: var(--st-scaduto); }
.st-ricontatto { --b-bg: var(--st-ricontatto-bg); --b-t: var(--st-ricontatto-t); --b-c: var(--st-ricontatto); }
.st-lead { --b-bg: var(--st-lead-bg); --b-t: var(--st-lead-t); --b-c: var(--st-lead); }
.st-cliente { --b-bg: var(--st-cliente-bg); --b-t: var(--st-cliente-t); --b-c: var(--st-cliente); }
.st-inattivo { --b-bg: var(--st-inattivo-bg); --b-t: var(--st-inattivo-t); --b-c: var(--st-inattivo); }
.st-perso { --b-bg: var(--st-perso-bg); --b-t: var(--st-perso-t); --b-c: var(--st-perso); }
.st-concluso { --b-bg: #EEF2F6; --b-t: #4F6170; --b-c: #8EA0AF; }
.st-bozza { --b-bg: #F1F3F5; --b-t: #5F6C77; --b-c: #B4BEC7; }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.tag .ic { width: 14px; height: 14px; }
.tag-coral { background: var(--corallo-chiaro); color: var(--corallo-testo); }
.tag-blue { background: var(--blu-chiaro); color: var(--blu); }
.tag-red { background: var(--st-scaduto-bg); color: var(--st-scaduto-t); }
.tag-teal { background: var(--st-attivo-bg); color: var(--st-attivo-t); }

.kbd { font-family: var(--f-mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--ink-2); line-height: 1.3; }

/* ===== Avatar ===== */
.avatar {
  --av: var(--blu);
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  font-family: var(--f-title); font-weight: 700; font-size: 13px; letter-spacing: 0.02em;
  color: #fff; background: var(--av);
  background-image: linear-gradient(135deg, rgba(255,255,255,0.18), transparent 60%);
}
.avatar-lg { width: 48px; height: 48px; border-radius: 15px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; }
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }

/* ===== Targa italiana ===== */
.plate {
  display: inline-flex; align-items: stretch; height: 26px; flex-shrink: 0;
  background: #fff; border: 1.5px solid #1C2B36; border-radius: 5px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(10,42,64,.08), 0 2px 6px -2px rgba(10,42,64,.25);
  font-family: var(--f-mono); font-weight: 700; color: #101A22; letter-spacing: 0.04em; font-size: 13px; line-height: 1;
}
.plate-eu { width: 14px; background: #1F4EB4; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.plate-eu svg { width: 9px; height: 9px; }
.plate-eu b { font-size: 7.5px; font-family: var(--f-ui); }
.plate-txt { display: flex; align-items: center; padding: 0 7px; white-space: nowrap; }
.plate-r { width: 9px; background: #1F4EB4; }
.plate-sm { height: 21px; font-size: 11px; }
.plate-sm .plate-eu { width: 11px; }
.plate-sm .plate-eu svg { width: 7px; height: 7px; }
.plate-sm .plate-eu b { font-size: 6px; }
.plate-sm .plate-r { width: 6px; }
.plate-lg { height: 34px; font-size: 17px; }
.plate-lg .plate-eu { width: 18px; }
.plate-lg .plate-r { width: 12px; }

/* ===== Card ===== */
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5) 0; min-height: 52px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: var(--fs-lg); }
.card-head .sub { color: var(--ink-3); font-size: var(--fs-sm); }
.card-body { padding: var(--s4) var(--s5) var(--s5); }
/* Angolo con il triangolo del logo */
.card-tri::after {
  content: ""; position: absolute; top: 0; right: 22px; width: 18px; height: 16px;
  background: var(--corallo); clip-path: path("M0 0H18Q18 9 11 16Z");
}
.section-title { display: flex; align-items: center; gap: 10px; font-family: var(--f-title); font-weight: 650; font-size: var(--fs-lg); }
.section-title .ic { color: var(--corallo-600); }

/* Divisore a tratteggio stradale */
.road-line { height: 4px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--blu-chiaro-2) 0 14px, transparent 14px 24px); border: 0; margin: 0; }

/* ===== Form ===== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field .req { color: var(--corallo-testo); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; color: var(--ink);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: #647789; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--st-lead); box-shadow: var(--ring); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
.input.mono { font-family: var(--f-mono); letter-spacing: 0.03em; }
.textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235A6F82' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field-hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field-hint .ic, p .ic, .small > .ic, .tag-inline .ic { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.field-err { font-size: var(--fs-xs); color: var(--st-scaduto-t); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.field.has-err .input, .field.has-err .select { border-color: var(--st-scaduto); }
.field.is-ok .input { border-color: var(--st-attivo); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .input-ic { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--st-attivo); }
.input-pre { position: relative; }
.input-pre .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-pre .input { padding-left: 42px; }
.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.form-grid > * { grid-column: span 12; }
.sez .card-body, .modal-body, .wiz-step, .tabpanel { container-type: inline-size; }
@media (min-width: 640px) {
  .form-grid .c2 { grid-column: span 2; } .form-grid .c3 { grid-column: span 3; } .form-grid .c4 { grid-column: span 4; }
  .form-grid .c5 { grid-column: span 5; } .form-grid .c6 { grid-column: span 6; } .form-grid .c8 { grid-column: span 8; } .form-grid .c9 { grid-column: span 9; }
}
/* Dentro contenitori stretti i campi si allargano: due per riga, poi uno */
@container (max-width: 720px) {
  .form-grid .c2, .form-grid .c3 { grid-column: span 4; }
  .form-grid .c4, .form-grid .c5 { grid-column: span 6; }
  .form-grid .c8, .form-grid .c9 { grid-column: span 12; }
}
@container (max-width: 520px) {
  .form-grid .c2, .form-grid .c3 { grid-column: span 6; }
  .form-grid .c4, .form-grid .c5, .form-grid .c6 { grid-column: span 12; }
}

/* Segmentato */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 3px; gap: 2px; position: relative; }
.seg button, .seg label { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 9px; font-size: var(--fs-sm); font-weight: 650; color: var(--ink-3); transition: color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out); cursor: pointer; }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg input:checked + span { color: var(--ink); background: var(--surface); box-shadow: var(--sh-1); }
.seg label { padding: 0; }
.seg label span { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 9px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (pointer: coarse) { .seg button, .seg label span { min-height: 40px; } }

/* Scelte a carta (kit, polizze, tipi) */
.card-choice {
  position: relative; display: flex; flex-direction: column; gap: 6px; cursor: pointer;
  padding: 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out), transform var(--d-press) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.card-choice input { position: absolute; opacity: 0; pointer-events: none; }
.card-choice:active { transform: scale(0.985); }
.card-choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.card-choice:has(input:checked) { border-color: var(--blu); background: linear-gradient(180deg, #fff, var(--blu-chiaro)); box-shadow: 0 0 0 2px var(--blu), var(--sh-2); }
.card-choice .cc-check {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--line); display: grid; place-items: center; background: #fff;
  transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}
.card-choice .cc-check svg { width: 14px; height: 14px; color: #fff; opacity: 0; transform: scale(0.6); transition: opacity var(--d-fast) var(--ease-out), transform var(--d-std) var(--ease-out); }
.card-choice:has(input:checked) .cc-check { background: var(--blu); border-color: var(--blu); }
.card-choice:has(input:checked) .cc-check svg { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) { .card-choice:hover { border-color: var(--blu-chiaro-2); box-shadow: var(--sh-2); } }

/* Interruttore */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; }
.switch .sw { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background-color var(--d-std) var(--ease-out); flex-shrink: 0; }
.switch .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform var(--d-std) var(--ease-out); }
.switch input:checked + .sw { background: var(--st-attivo); }
.switch input:checked + .sw::after { transform: translateX(18px); }
.switch input:focus-visible + .sw { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ===== Tabelle ===== */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table th button { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.table th button .ic { width: 14px; height: 14px; opacity: .6; }
.table th[aria-sort="ascending"] button .ic, .table th[aria-sort="descending"] button .ic { opacity: 1; color: var(--blu); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: background-color var(--d-fast) var(--ease-out); }
.table tbody tr[data-row] { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-right { text-align: right; }
.table .t-main { font-weight: 650; color: var(--ink); }
.table .t-sub { font-size: 12px; color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .table tbody tr[data-row]:hover { background: var(--ghiaccio); } }
.table tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ===== Strati: pannelli e finestre ===== */
.layer { position: fixed; inset: 0; z-index: var(--z-drawer); }
.layer-modal { z-index: var(--z-modal); display: grid; place-items: center; padding: 16px; }
.layer-backdrop { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity var(--d-panel) var(--ease-out); backdrop-filter: blur(2px); }
.layer.is-open .layer-backdrop { opacity: 1; }

.layer-drawer .layer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  background: var(--surface); box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--d-panel) var(--ease-drawer);
  border-radius: 24px 0 0 24px; overflow: hidden;
}
.layer-drawer.is-wide .layer-panel { width: min(760px, 100vw); }
.layer-drawer.is-open .layer-panel { transform: none; }
.drawer-grip { display: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 14px 24px; border-bottom: 1px solid var(--line-2); }
.drawer-title { font-size: var(--fs-xl); }
.drawer-sub { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--ink-3); font-size: var(--fs-sm); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 28px; overscroll-behavior: contain; }
.drawer-foot { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 24px calc(14px + var(--safe-b)); border-top: 1px solid var(--line-2); background: var(--surface-2); }

@media (max-width: 767px) {
  .layer-drawer .layer-panel {
    top: auto; left: 0; width: 100%; max-height: calc(100dvh - 40px - var(--safe-t));
    border-radius: 24px 24px 0 0; transform: translateY(100%);
  }
  .layer-drawer.is-wide .layer-panel { width: 100%; }
  .drawer-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .drawer-head { padding: 10px 16px 12px 20px; }
  .drawer-body { padding: 16px 20px 24px; }
  .drawer-foot { padding: 12px 16px calc(12px + var(--safe-b)); }
  .layer-drawer.drawer-full .layer-panel { top: var(--safe-t); max-height: none; }
}

.layer-modal .layer-panel {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px);
  background: var(--surface); border-radius: 22px; box-shadow: var(--sh-3);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: scale(0.96);
  transition: opacity var(--d-modal) var(--ease-out), transform var(--d-modal) var(--ease-out);
}
.layer-modal.size-sm .layer-panel { width: min(440px, 100%); }
.layer-modal.size-lg .layer-panel { width: min(820px, 100%); }
.layer-modal.size-xl .layer-panel { width: min(1080px, 100%); }
.layer-modal.is-open .layer-panel { opacity: 1; transform: none; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 16px 12px 24px; }
.modal-title { font-size: var(--fs-xl); flex: 1; }
.modal-body { padding: 4px 24px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 24px calc(16px + var(--safe-b)); border-top: 1px solid var(--line-2); background: var(--surface-2); }
.confirm-text { color: var(--ink-2); }
@media (max-width: 559px) {
  .layer-modal { padding: 0; place-items: end stretch; }
  .layer-modal .layer-panel { width: 100% !important; max-height: calc(100dvh - 24px); border-radius: 22px 22px 0 0; transform: translateY(24px); }
  .modal-foot .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .layer-drawer .layer-panel, .layer-modal .layer-panel { transform: none !important; transition: opacity var(--d-std) var(--ease-out); opacity: 0; }
  .layer.is-open .layer-panel { opacity: 1; }
}

/* ===== Menu ===== */
.menu {
  position: fixed; z-index: var(--z-palette); min-width: 220px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-3); padding: 6px;
  opacity: 0; transform: scale(0.96);
  transition: opacity var(--d-menu) var(--ease-out), transform var(--d-menu) var(--ease-out);
}
.menu.is-open { opacity: 1; transform: none; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; text-align: left; color: var(--ink); }
.menu-item .ic { width: 18px; height: 18px; color: var(--ink-3); }
.menu-item:focus-visible { outline-offset: -2px; background: var(--blu-chiaro); }
.menu-item.is-danger { color: var(--st-scaduto-t); }
.menu-item:disabled { opacity: .45; }
.menu-hint { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--line-2); margin: 6px 4px; }
@media (hover: hover) and (pointer: fine) { .menu-item:hover:not(:disabled) { background: var(--ghiaccio); } }
@media (pointer: coarse) { .menu-item { min-height: 46px; } }

/* ===== Toast ===== */
.toasts { position: fixed; z-index: var(--z-toast); right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; width: min(400px, calc(100vw - 32px));
  padding: 12px 10px 12px 14px; border-radius: 16px; background: var(--navy); color: #fff; box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(16px);
  transition: opacity var(--d-modal) var(--ease-out), transform var(--d-modal) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(16px); transition-duration: var(--d-std); }
.toast-ic { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: rgba(23, 163, 152, 0.22); color: #5FE0D4; }
.toast-ic .ic { width: 18px; height: 18px; }
.toast-warn .toast-ic, .toast-err .toast-ic { background: rgba(255, 127, 97, 0.22); color: var(--corallo); }
.toast-info .toast-ic { background: rgba(59, 154, 217, 0.25); color: #8CCBF3; }
.toast-title { font-weight: 700; font-size: var(--fs-sm); }
.toast-msg { font-size: 12.5px; color: rgba(255,255,255,0.78); margin-top: 1px; }
.toast .btn-icon { color: rgba(255,255,255,0.7); }
@media (hover: hover) and (pointer: fine) { .toast .btn-icon:hover { background: rgba(255,255,255,0.1); color: #fff; } }
@media (max-width: 1023px) {
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 16px + var(--safe-b)); align-items: center; }
  /* benvenuto: in alto sotto la barra superiore, non copre la barra delle schede né il bottone "Nuovo" */
  .toast-top { position: fixed; top: calc(var(--topbar-h) + var(--safe-t) + 8px); left: 50%; width: min(400px, calc(100vw - 32px)); transform: translate(-50%, -12px); }
  .toast-top.is-in { transform: translateX(-50%); }
  .toast-top.is-out { transform: translate(-50%, -12px); }
}
@media (prefers-reduced-motion: reduce) { .toast, .toast.is-out { transform: none; } }
@media (prefers-reduced-motion: reduce) and (max-width: 1023px) { .toast-top, .toast-top.is-in, .toast-top.is-out { transform: translateX(-50%); } }

/* ===== Tooltip ===== */
.tip {
  position: fixed; z-index: var(--z-tip); max-width: 280px; pointer-events: none;
  padding: 7px 10px; border-radius: 9px; background: var(--navy); color: #fff;
  font-size: 12.5px; font-weight: 550; line-height: 1.35; box-shadow: var(--sh-2);
  opacity: 0; transform: translateY(3px);
  transition: opacity var(--d-tip) var(--ease-out), transform var(--d-tip) var(--ease-out);
}
.tip.is-on { opacity: 1; transform: none; }
.tip.no-anim { transition: none; }
.tip.is-measuring { visibility: hidden; opacity: 1; transition: none; }

/* ===== Palette comandi (senza animazione) ===== */
.palette { position: fixed; inset: 0; z-index: var(--z-palette); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.palette-panel { position: relative; width: min(640px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--sh-3); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-in { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line-2); }
.palette-in .ic { color: var(--ink-3); }
.palette-in input { flex: 1; border: 0; height: 58px; font-size: 17px; background: none; min-width: 0; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.palette-item > .ic { color: var(--ink-3); }
.palette-item.is-sel { background: var(--blu-chiaro); }
.palette-item.is-sel > .ic { color: var(--blu); }
.pi-l { font-weight: 650; display: flex; align-items: center; gap: 8px; min-width: 0; }
.pi-s { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.pi-s .badge { height: 20px; font-size: 11px; }
.pi-go { color: var(--blu); }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--ink-3); }
.palette-foot { display: flex; gap: 16px; justify-content: flex-end; padding: 8px 14px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--ink-3); background: var(--surface-2); }
@media (max-width: 559px) { .palette { padding-top: 12px; } .palette-foot { display: none; } }

/* ===== Stati vuoti e caricamento ===== */
.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-art { width: 180px; height: auto; margin-bottom: 6px; }
.empty h3 { font-size: var(--fs-lg); }
.skeleton-list { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.sk-row { display: flex; align-items: center; gap: 12px; }
.sk { position: relative; overflow: hidden; display: block; border-radius: 8px; background: var(--surface-3); height: 14px; }
.sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.2s linear infinite; }
.sk-av { width: 36px; height: 36px; border-radius: 12px; }
.sk-l { flex: 1; } .sk-s { width: 80px; }
@media (prefers-reduced-motion: reduce) { .sk::after { animation: none; } }

/* ===== Odometro (cifre che scorrono) ===== */
.odo { display: inline-flex; align-items: baseline; font-family: var(--f-mono); font-variant-numeric: tabular-nums; line-height: 1; }
.odo-d { display: inline-block; height: 1em; overflow: hidden; position: relative; width: 0.62em; }
.odo-s { display: flex; flex-direction: column; transition: transform var(--d-slow) var(--ease-out); }
.odo-s span { height: 1em; display: block; text-align: center; }
.odo-c { display: inline-block; }
@media (prefers-reduced-motion: reduce) { .odo-s { transition: none; } }

/* ===== Anello ===== */
.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-3); }
.ring-fg { fill: none; stroke: var(--corallo); stroke-linecap: round; transition: stroke-dashoffset var(--d-slow) var(--ease-out); }

/* ===== Barra a tratteggio (avanzamento) ===== */
.dashbar { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.dashbar > span {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--p, 0));
  background: var(--bar, var(--st-attivo)); border-radius: 4px;
  transition: transform var(--d-enter) var(--ease-out);
}
.dashbar::after { content: ""; position: absolute; inset: 3px 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 8px, transparent 8px 16px); opacity: .55; pointer-events: none; mix-blend-mode: soft-light; }

/* ===== Documento A4 in anteprima ===== */
.doc-wrap { position: relative; overflow: hidden; border-radius: 12px; }
.doc-scale { width: 794px; transform-origin: top left; }

/* Grafici */
.chart .grid { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 4 5; }
.chart .hit { cursor: default; }
.spark { width: 100%; height: 96px; overflow: visible; }
.is-first-load .spark-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-line var(--d-data) var(--ease-out) var(--d-slow) forwards; }
@keyframes draw-line { to { stroke-dashoffset: 0; } }
.donut { width: 150px; height: 150px; }
.donut-n { font-family: var(--f-title); font-weight: 700; font-size: 26px; fill: var(--ink); }
.donut-l { font-size: 11px; fill: var(--ink-3); }
.donut-seg { transition: opacity var(--d-fast) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .donut:hover .donut-seg:not(:hover) { opacity: 0.45; } }
.funnel { display: flex; flex-direction: column; gap: 12px; }
.funnel-lab { display: flex; justify-content: space-between; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 4px; }
.funnel-track { height: 12px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.funnel-bar { display: block; height: 100%; border-radius: 6px; transform-origin: left; transform: scaleX(var(--w)); }
.is-first-load .funnel-bar { animation: grow-x var(--d-data) var(--ease-out) both; animation-delay: calc(200ms + var(--i) * 90ms); }
@keyframes grow-x { from { transform: scaleX(0.02); } }
.funnel-pct { margin-top: 3px; }
@media (prefers-reduced-motion: reduce) { .is-first-load .spark-line { animation: none; stroke-dashoffset: 0; } .is-first-load .funnel-bar { animation: none; } }

/* Spunta finale */
.done-mark { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: var(--st-attivo-bg); color: var(--st-attivo); margin: 0 auto; }
.done-mark .draw-check { width: 36px; height: 36px; }
