/* Componenti riutilizzabili */

/* ---------- Bottoni ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-md);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast),
    box-shadow var(--d-fast), transform var(--d-instant) var(--ease-out);
  user-select: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); transition-duration: 60ms; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 20, 40, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-primary:active { background: var(--accent-active); }

.btn-danger { border-color: transparent; background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); border-color: transparent; }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--text); }

.btn-soft { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft-2); border-color: transparent; }

.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-xs { height: 24px; padding: 0 8px; font-size: var(--fs-xs); border-radius: var(--r-xs); gap: 4px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 24px; }
.btn-block { width: 100%; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) transparent transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn:not(.btn-primary).is-loading::after { border-color: var(--text-2) var(--text-2) transparent transparent; }
.btn.is-done { animation: pop-in var(--d) var(--ease-spring); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }
.field__error { font-size: var(--fs-xs); color: var(--danger); animation: rise-in var(--d) var(--ease-out); }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--d-fast), box-shadow var(--d-fast), background var(--d-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: var(--lh); }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23858b9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.input-sm, .select.input-sm { height: 30px; font-size: var(--fs-sm); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; width: 16px; height: 16px; }
.input-group > .input { padding-left: 34px; }
.input-group > .input-group__end { position: absolute; right: 4px; display: flex; gap: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }

/* Checkbox */
.check {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: background var(--d-fast), border-color var(--d-fast), transform var(--d-instant);
}
.check::after {
  content: "";
  width: 9px;
  height: 5px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform var(--d) var(--ease-spring);
}
.check:checked, .check:indeterminate { background: var(--accent); border-color: var(--accent); }
.check:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check:indeterminate::after { width: 8px; height: 0; border-left: 0; border-bottom: 2px solid #fff; transform: none; }
.check:active { transform: scale(0.9); }

/* Switch */
.switch { position: relative; display: inline-flex; flex: none; width: 34px; height: 20px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch__track {
  width: 100%;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--d) var(--ease-out);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--d) var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }

/* ---------- Segmented control con indicatore animato ---------- */
.seg {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r);
  background: var(--surface-3);
  isolation: isolate;
}
.seg__btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--d-fast);
}
.seg__btn:hover { color: var(--text); }
.seg__btn[aria-pressed="true"] { color: var(--text); }
.seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
.seg__btn .icon { width: 15px; height: 15px; }
.seg__indicator {
  position: absolute;
  z-index: 0;
  top: 3px;
  left: 0;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--d-slow) var(--ease-out), width var(--d-slow) var(--ease-out);
}

/* Tabs */
.tabs { position: relative; display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); }
.tab {
  height: 38px;
  padding: 0 12px;
  color: var(--text-3);
  font-weight: 500;
  transition: color var(--d-fast);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tabs__ink {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transition: transform var(--d-slow) var(--ease-out), width var(--d-slow) var(--ease-out);
}

/* ---------- Card ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: var(--fs-md); font-weight: 600; flex: 1; }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }

/* ---------- Badge, tag, avatar ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge--plain::before { display: none; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }
.badge--muted { background: var(--surface-3); color: var(--text-3); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  background: var(--c-slate-bg);
  color: var(--c-slate-fg);
  animation: pop-in var(--d) var(--ease-spring);
}
.tag button { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: -3px; border-radius: 3px; opacity: 0.6; }
.tag button:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }
.tag button .icon { width: 11px; height: 11px; stroke-width: 2.4; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

[data-color="violet"] { --cb: var(--c-violet-bg); --cf: var(--c-violet-fg); --cs: var(--c-violet); }
[data-color="blue"] { --cb: var(--c-blue-bg); --cf: var(--c-blue-fg); --cs: var(--c-blue); }
[data-color="teal"] { --cb: var(--c-teal-bg); --cf: var(--c-teal-fg); --cs: var(--c-teal); }
[data-color="green"] { --cb: var(--c-green-bg); --cf: var(--c-green-fg); --cs: var(--c-green); }
[data-color="amber"] { --cb: var(--c-amber-bg); --cf: var(--c-amber-fg); --cs: var(--c-amber); }
[data-color="orange"] { --cb: var(--c-orange-bg); --cf: var(--c-orange-fg); --cs: var(--c-orange); }
[data-color="rose"] { --cb: var(--c-rose-bg); --cf: var(--c-rose-fg); --cs: var(--c-rose); }
[data-color="pink"] { --cb: var(--c-pink-bg); --cf: var(--c-pink-fg); --cs: var(--c-pink); }
[data-color="slate"] { --cb: var(--c-slate-bg); --cf: var(--c-slate-fg); --cs: var(--c-slate); }
.tag[data-color] { background: var(--cb); color: var(--cf); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cs, var(--text-3)); flex: none; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--av, var(--brand-violet));
  user-select: none;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--xs { width: 20px; height: 20px; font-size: 9px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.avatar--xl { width: 64px; height: 64px; font-size: 22px; }
.avatar--sq { border-radius: 8px; }
.avatar[data-color="0"] { --av: linear-gradient(135deg, #995794, #b97ab3); }
.avatar[data-color="1"] { --av: linear-gradient(135deg, #0097b8, #00b2d7); }
.avatar[data-color="2"] { --av: linear-gradient(135deg, #14b8a6, #2dd4bf); }
.avatar[data-color="3"] { --av: linear-gradient(135deg, #f97316, #fb923c); }
.avatar[data-color="4"] { --av: linear-gradient(135deg, #f43f5e, #fb7185); }
.avatar[data-color="5"] { --av: linear-gradient(135deg, #22a55a, #4ade80); }
.avatar[data-color="6"] { --av: linear-gradient(135deg, #d946ef, #e879f9); }
.avatar[data-color="7"] { --av: linear-gradient(135deg, #64748b, #94a3b8); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* ---------- Tabella ---------- */
.table-wrap { overflow: auto; }
.table { font-size: var(--fs-md); }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40px;
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table th:first-child, .table td:first-child { padding-left: var(--sp-5); }
.table th:last-child, .table td:last-child { padding-right: var(--sp-5); }
.table td {
  height: 54px;
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--d-fast); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-selected { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.table .col-check { width: 44px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-enter { animation: rise-in var(--d-slow) var(--ease-out) both; }

.person { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.person__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.person__name { font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person__sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Menu / popover ---------- */
.popover {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  max-width: min(360px, calc(100vw - 24px));
  max-height: min(420px, calc(100vh - 24px));
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  transform-origin: var(--origin, top left);
  animation: popover-in var(--d-slow) var(--ease-out);
}
.popover.is-leaving { animation: popover-out var(--d-fast) var(--ease-in) forwards; }
@keyframes popover-in { from { opacity: 0; transform: scale(0.97) translateY(-6px); } }
@keyframes popover-out { to { opacity: 0; transform: scale(0.98) translateY(-3px); } }
.menu__label { padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
  font-size: var(--fs-md);
  transition: background var(--d-instant);
}
.menu__item:hover, .menu__item.is-active { background: var(--surface-hover); }
.menu__item .icon { color: var(--text-3); width: 16px; height: 16px; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger .icon { color: var(--danger); }
.menu__item .check-mark { margin-left: auto; color: var(--accent); opacity: 0; }
.menu__item[aria-checked="true"] .check-mark { opacity: 1; }
.menu__sep { height: 1px; margin: 5px -5px; background: var(--border); }
.menu__search { padding: 4px 4px 6px; }

/* ---------- Overlay: modale e slide-over ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(var(--blur-overlay)) saturate(1.1);
  backdrop-filter: blur(var(--blur-overlay)) saturate(1.1);
  animation: fade-in var(--d-slow) var(--ease-out);
}
.overlay.is-leaving { animation: fade-out var(--d) var(--ease-in) forwards; }

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 64px);
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  animation: modal-in var(--d-slower) var(--ease-elastic);
}
.modal--lg { width: min(820px, calc(100vw - 32px)); }
.modal--sm { width: min(420px, calc(100vw - 32px)); }
.overlay.is-leaving .modal { animation: modal-out var(--d-fast) var(--ease-in) forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.975); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(0.985); } }
.modal__head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4); }
.modal__head h2 { font-size: var(--fs-lg); flex: 1; }
.modal__head p { margin-top: 4px; font-size: var(--fs-sm); }
.modal__body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  height: 100%;
  margin-left: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  animation: sheet-in var(--d-slower) var(--ease-elastic);
}
.sheet--wide { width: min(720px, 100vw); }
.overlay.is-leaving .sheet { animation: sheet-out var(--d) var(--ease-in) forwards; }
@keyframes sheet-in { from { transform: translateX(100%); } }
@keyframes sheet-out { to { transform: translateX(100%); } }
.sheet__body > * { animation: rise-in var(--d-slower) var(--ease-out) 90ms both; }
.sheet__head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.sheet__body { flex: 1; overflow: auto; }
.sheet__foot { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 400;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative;
  display: flex;
  gap: var(--sp-3);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  overflow: hidden;
  animation: toast-in var(--d-slower) var(--ease-elastic);
}
.toast.is-leaving { animation: toast-out var(--d) var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px) scale(0.98); } }
.toast__icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); }
.toast__icon .icon { width: 16px; height: 16px; }
.toast--success .toast__icon { background: var(--success-soft); color: var(--success); }
.toast--error .toast__icon { background: var(--danger-soft); color: var(--danger); }
.toast--warning .toast__icon { background: var(--warning-soft); color: var(--warning); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 600; font-size: var(--fs-md); }
.toast__text { font-size: var(--fs-sm); color: var(--text-2); margin-top: 1px; }
.toast__action { margin-top: 6px; }
.toast__close { align-self: flex-start; color: var(--text-3); padding: 2px; border-radius: 4px; }
.toast__close:hover { color: var(--text); background: var(--surface-hover); }
.toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  opacity: 0.5;
  transform-origin: left;
}

/* ---------- Command palette ---------- */
.palette {
  width: min(620px, calc(100vw - 32px));
  margin: 12vh auto auto;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modal-in var(--d-slow) var(--ease-elastic);
}
.overlay.is-leaving .palette { animation: modal-out var(--d-fast) var(--ease-in) forwards; }
.palette__input { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-5); border-bottom: 1px solid var(--border); }
.palette__input .icon { color: var(--text-3); }
.palette__input input { flex: 1; height: 56px; border: 0; background: transparent; font-size: var(--fs-lg); outline: none; }
.palette__list { max-height: min(420px, 60vh); overflow: auto; padding: 6px; }
.palette__group { padding: 10px 12px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.palette__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 42px;
  padding: 6px 12px;
  border-radius: var(--r);
  text-align: left;
  color: var(--text);
}
.palette__item .icon { color: var(--text-3); }
.palette__item.is-active { background: var(--accent-soft); }
.palette__item.is-active .icon { color: var(--accent-text); }
.palette__item mark { background: transparent; color: var(--accent-text); font-weight: 600; }
.palette__meta { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); }
.palette__foot { display: flex; gap: var(--sp-4); padding: 10px var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-3); }
.palette__foot span { display: inline-flex; align-items: center; gap: 6px; }
.palette__empty { padding: var(--sp-8); text-align: center; color: var(--text-3); }

/* ---------- Skeleton ed empty state ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--skeleton);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent);
  animation: shimmer 1.3s infinite;
}
.sk-line { height: 12px; }
.sk-title { height: 22px; width: 40%; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-6);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--sp-2);
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.empty__icon .icon { width: 24px; height: 24px; }
.empty h3 { font-size: var(--fs-lg); }
.empty p { max-width: 380px; font-size: var(--fs-md); }
.empty .btn { margin-top: var(--sp-3); }

/* ---------- Varie ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--d-fast), border-color var(--d-fast), color var(--d-fast);
}
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.is-active { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.chip .icon { width: 14px; height: 14px; }
.chip__count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; }

.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px var(--sp-4); align-items: center; font-size: var(--fs-md); }
.kv dt { color: var(--text-3); font-size: var(--fs-sm); }
.kv dd { margin: 0; min-width: 0; }

.inline-edit {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  margin: -4px -8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  transition: border-color var(--d-fast), background var(--d-fast);
}
.inline-edit:hover { background: var(--surface-hover); }
.inline-edit:focus { border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); outline: none; }
.saved-flash { animation: saved-flash 900ms var(--ease-out); }
@keyframes saved-flash { 0% { box-shadow: 0 0 0 0 var(--success); } 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 35%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }

.code-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.code-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--info-soft);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.callout .icon { color: var(--info); margin-top: 1px; }
.callout--accent { background: var(--accent-soft); }
.callout--accent .icon { color: var(--accent-text); }
.callout--warning { background: var(--warning-soft); }
.callout--warning .icon { color: var(--warning); }

.bulkbar {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 7px 7px 7px 16px;
  border-radius: var(--r-lg);
  background: #14161f;
  color: #fff;
  box-shadow: var(--shadow-xl);
  transform: translate(-50%, 0);
  animation: bulk-in var(--d-slower) var(--ease-elastic);
}
.bulkbar.is-leaving { animation: bulk-out var(--d) var(--ease-in) forwards; }
@keyframes bulk-in { from { opacity: 0; transform: translate(-50%, 18px) scale(0.97); } }
@keyframes bulk-out { to { opacity: 0; transform: translate(-50%, 16px); } }
.bulkbar__count { font-weight: 600; margin-right: var(--sp-2); white-space: nowrap; }
.bulkbar .btn { background: rgba(255, 255, 255, 0.08); border-color: transparent; color: #fff; box-shadow: none; }
.bulkbar .btn:hover { background: rgba(255, 255, 255, 0.16); }
.bulkbar .btn-danger-text { color: #ff8c90; }
:root[data-theme="dark"] .bulkbar { background: #272b38; }

.pagination { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-3); }

.tooltip {
  position: fixed;
  z-index: 500;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  background: #14161f;
  color: #fff;
  font-size: var(--fs-xs);
  pointer-events: none;
  animation: pop-in var(--d-fast) var(--ease-out);
}

/* Errori di form senza campo dedicato (riepilogo in cima) */
.form-error { margin-bottom: var(--sp-2); }
.form-error > div > div + div { margin-top: 2px; }
/* Link nella cella principale delle tabelle (riga operabile da tastiera) */
.row-link { font: inherit; color: inherit; text-align: left; padding: 0; background: none; border: 0; cursor: pointer; }
.row-link:hover { text-decoration: underline; }
.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
