/* ── Colore primario (CSS custom properties) ── */
:root {
  --primary: #374151;
  --primary-hover: #1f2937;
  --primary-light: #f3f4f6;
  --primary-ring: #4b5563;
  --input-focus-border: var(--primary);
  --input-focus-ring: color-mix(in srgb, var(--primary-ring) 35%, transparent);
}
.bg-primary { background: var(--primary); }
.bg-primary-hover { background: var(--primary-hover); }
.bg-primary-light { background: var(--primary-light); }
.hover\:bg-primary:hover { background: var(--primary); }
.hover\:bg-primary-hover:hover { background: var(--primary-hover); }
.text-primary { color: var(--primary); }
.text-primary-hover { color: var(--primary-hover); }
.hover\:text-primary:hover { color: var(--primary); }
.border-primary { border-color: var(--primary); }
.ring-primary { --tw-ring-color: var(--primary-ring); }
.accent-primary { accent-color: var(--primary); }
.focus\:ring-primary:focus { --tw-ring-color: var(--primary-ring); }
.focus\:border-primary:focus { border-color: var(--primary); }
.hover\:bg-primary-light:hover { background: var(--primary-light); }
.hover\:border-primary-light:hover { border-color: var(--primary-light); }
.hover\:border-primary:hover { border-color: var(--primary); }

/* ── Palette swatches ── */
.palette-swatch {
  width: 24px; height: 24px; border-radius: 9999px;
  border: 2px solid transparent; cursor: pointer;
  transition: border-color 0.15s;
}
.palette-swatch:hover { border-color: #9ca3af; }
.palette-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* ── Dialog ── */
.app-dialog {
  position: relative;
  width: min(92vw, 420px);
  margin: auto;
  padding: 14px 16px 14px;
  border: 0;
  border-radius: 2px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  background: #fff;
  color: #111827;
  overflow: visible !important;
}
.app-dialog--wide { width: min(94vw, 640px); padding: 12px; }
.app-dialog::backdrop { background: rgba(0,0,0,0.35); }
.app-dialog__close {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; padding: 0; border: 0;
  background: transparent; color: #9ca3af;
  font-size: 18px; line-height: 1; cursor: pointer;
}
.app-dialog__close:hover { color: #111827; }
.app-dialog__title { margin: 0 28px 10px 0; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.app-dialog__body { overflow: visible !important; max-height: none; }

/* ── Dialog form controls (shadcn/ui) ── */
.app-dialog__body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
.app-dialog__body select,
.app-dialog__body textarea {
  width: 100%;
  height: 32px;
  padding: 0.25rem 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: #09090b;
  background-color: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 0.375rem;
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}
.app-dialog__body .choices {
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
  border: none !important;
}
.app-dialog__body textarea {
  height: auto;
  min-height: 72px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.app-dialog__body input:focus,
.app-dialog__body input:focus-visible,
.app-dialog__body select:focus,
.app-dialog__body select:focus-visible,
.app-dialog__body textarea:focus,
.app-dialog__body textarea:focus-visible,
.app-dialog__body .choices.is-focused .choices__inner,
.app-dialog__body .choices.is-open .choices__inner {
  border-color: var(--input-focus-border) !important;
  box-shadow: 0 0 0 1px var(--input-focus-border), 0 0 0 4px var(--input-focus-ring) !important;
  border-radius: 0.375rem !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
}

/* ── Dialog buttons (shadcn/ui) ── */
.app-dialog__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 1rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.app-dialog__btn--secondary {
  border: 1px solid #e4e4e7;
  background-color: #ffffff;
  color: #18181b;
}
.app-dialog__btn--secondary:hover { background-color: #f4f4f5; }
.app-dialog__btn--primary {
  border: 0;
  background-color: #18181b;
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.app-dialog__btn--primary:hover { background-color: #27272a; }

/* ── Sidebar ── */
#sidebar-outer, #sidebar { overflow: visible; }
.sidebar {
  width: 256px;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed.hover-expand { width: 256px; }

/* Label / testi: fade + collasso layout (niente display:none istantaneo) */
.sidebar .sidebar-hide {
  overflow: hidden;
  white-space: nowrap;
  max-width: 220px;
  opacity: 1;
  transition: opacity 0.2s ease 0.1s, max-width 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar.collapsed:not(.hover-expand) .sidebar-hide {
  opacity: 0;
  max-width: 0;
  min-width: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  pointer-events: none;
  transition: opacity 0.12s ease, max-width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar.collapsed .nav-icon-only { display: flex; }
.sidebar:not(.collapsed) .nav-icon-only,
.sidebar.collapsed.hover-expand .nav-icon-only { display: none; }

/* ── Nav dropdown collapsible ── */
.nav-chevron { transition: transform 0.2s; }
.nav-dropdown.open .nav-chevron { transform: rotate(180deg); }
.nav-sub { overflow: hidden; max-height: 0; transition: max-height 0.2s; }
.nav-dropdown.open .nav-sub { max-height: 200px; }

/* ── Notification offcanvas ── */
.notif-offcanvas {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 50;
  width: 360px; background: #fff;
  border-radius: 12px;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.2s;
  border: 1px solid #e4e4e7;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
}
.notif-offcanvas.open { transform: translateX(0); }
.notif-backdrop {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(0,0,0,0.3);
  display: none;
}
.notif-backdrop.open { display: block; }

/* ── Side drawer (quick view) ── */
.side-drawer {
  position: fixed; inset: 0 0 0 auto; z-index: 40;
  width: 20rem; background: #fff;
  transform: translateX(100%);
  transition: transform 0.2s;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
}
.side-drawer.open { transform: translateX(0); }
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.3);
  display: none;
}
.drawer-backdrop.open { display: block; }

/* ── Help button ── */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; padding: 0;
  border: 1px solid #9ca3af; border-radius: 9999px;
  background: #fff; color: #6b7280;
  font-size: 9px; font-weight: 700; line-height: 1;
  cursor: pointer; flex-shrink: 0;
}
.help-btn:hover { background: #f3f4f6; color: #111827; border-color: #6b7280; }

/* ── Bar chart ── */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 100px; }
.bar-chart__item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; }
.bar-chart__bar { width: 100%; border-radius: 2px 2px 0 0; min-height: 4px; transition: height 0.3s; background: #d1d5db; }
.bar-chart__bar--active { background: var(--primary); }
.bar-chart__label { font-size: 9px; color: #9ca3af; white-space: nowrap; }
.bar-chart__value { font-size: 9px; color: #6b7280; }

/* ── Calendar ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-cell { text-align: center; font-size: 10px; padding: 3px 0; color: #6b7280; border-radius: 2px; }
.cal-cell--header { color: #9ca3af; font-size: 9px; font-weight: 600; }
.cal-cell--today { background: #18181b; color: #fff; font-weight: 600; }
.cal-cell--muted { color: #d1d5db; }

/* ── Filter pill ── */
.filter-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; font-size: 10px;
  border: 1px solid #d1d5db; border-radius: 9999px;
  background: #fff; color: #6b7280;
  cursor: pointer; transition: all 0.15s;
}
.filter-pill:hover { border-color: #9ca3af; color: #374151; }
.filter-pill--active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.filter-pill--active:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

/* ── Tooltip ── */
[tooltip] { position: relative; }
[tooltip]::after {
  content: attr(tooltip);
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #1f2937; color: #fff;
  font-size: 9px; padding: 2px 6px;
  border-radius: 2px; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
}
[tooltip]:hover::after { opacity: 1; }

/* ── Scrollbar ── */
.sidebar-scroll::-webkit-scrollbar { width: 3px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 2px; }

/* ── Progress bar ── */
.progress-bar { height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.progress-bar__fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }

/* ── Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 2px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Tabulator override (shadcn/ui data-table) ── */
.tabulator {
  font-size: 12px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

/* ── Header reset ── */
.tabulator .tabulator-header {
  background: #ffffff !important;
  border-bottom: 1px solid #e4e4e7 !important;
  color: #09090b;
  font-weight: 600;
}
.tabulator .tabulator-header .tabulator-header-contents,
.tabulator .tabulator-header .tabulator-headers {
  background: #ffffff !important;
}
.tabulator .tabulator-header .tabulator-col {
  background: #ffffff !important;
  border: none !important;
  border-right: none !important;
  height: 40px !important;
  min-height: 40px !important;
}
.tabulator .tabulator-header .tabulator-col.bulk-select-col {
  width: 48px !important;
  max-width: 48px !important;
  min-width: 48px !important;
  flex: 0 0 48px !important;
  border-right: none !important;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start;
  padding: 0 0.75rem !important;
  height: 40px !important;
  box-sizing: border-box;
  position: relative;
}
.tabulator .tabulator-header .tabulator-col:first-child .tabulator-col-content,
.tabulator .tabulator-header .tabulator-col.bulk-select-col .tabulator-col-content {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  padding: 0 !important;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title-holder {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  display: flex !important;
  align-items: center;
  width: 100%;
  min-width: 0;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #09090b !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  white-space: nowrap;
  line-height: 1;
}
.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
  padding-right: 0 !important;
}

/* Hide native Tabulator sort UI (custom ChevronsUpDown via titleFormatter) */
.tabulator .tabulator-header .tabulator-col .tabulator-col-sorter,
.tabulator .tabulator-col .tabulator-col-sorter,
.tabulator .tabulator-col .tabulator-arrow {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Custom sort icons — show one based on aria-sort */
.sort-header-icons {
  display: inline-flex;
  align-items: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.sort-header-icons svg {
  width: 14px;
  height: 14px;
  display: none;
}
.sort-header-icons .sort-icon--unsorted {
  display: block;
  color: #a1a1aa;
}
.tabulator .tabulator-header .tabulator-col:hover .sort-header-icons .sort-icon--unsorted {
  color: #3f3f46;
}
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"] .sort-icon--unsorted,
.tabulator .tabulator-header .tabulator-col.tabulator-col-sorter-asc .sort-icon--unsorted,
.tabulator .tabulator-header .tabulator-col[aria-sort="descending"] .sort-icon--unsorted,
.tabulator .tabulator-header .tabulator-col.tabulator-col-sorter-desc .sort-icon--unsorted {
  display: none;
}
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"] .sort-icon--asc,
.tabulator .tabulator-header .tabulator-col.tabulator-col-sorter-asc .sort-icon--asc {
  display: block;
  color: #09090b;
}
.tabulator .tabulator-header .tabulator-col[aria-sort="descending"] .sort-icon--desc,
.tabulator .tabulator-header .tabulator-col.tabulator-col-sorter-desc .sort-icon--desc {
  display: block;
  color: #09090b;
}

.tabulator .tabulator-header .tabulator-col:hover {
  background: #fafafa !important;
}
.tabulator .tabulator-col-resize-handle {
  display: none !important;
}

/* ── Rows (h-12 dense) ── */
.tabulator .tabulator-tableholder .tabulator-row {
  background: #ffffff !important;
  border-bottom: 1px solid #f4f4f5 !important;
  min-height: 48px !important;
  height: 48px !important;
}
.tabulator .tabulator-tableholder .tabulator-row:hover {
  background: #fafafa !important;
}
.tabulator .tabulator-tableholder .tabulator-row.tabulator-selected,
.tabulator .tabulator-tableholder .tabulator-row.row-selected {
  background: #f4f4f5 !important;
}
.tabulator .tabulator-tableholder .tabulator-row.tabulator-selected:hover,
.tabulator .tabulator-tableholder .tabulator-row.row-selected:hover {
  background: #f4f4f5 !important;
}

/* ── Cells — shadcn vertical centering ── */
.tabulator .tabulator-row .tabulator-cell {
  display: inline-flex !important;
  align-items: center !important;
  height: 48px !important;
  padding: 0 0.75rem !important;
  border: none !important;
  border-right: none !important;
  box-sizing: border-box;
  font-size: 0.875rem !important;
  line-height: 1.25rem !important;
  color: #18181b;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tabulator .tabulator-row .tabulator-cell:first-child,
.tabulator .tabulator-row .tabulator-cell.bulk-select-col {
  display: inline-flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 48px !important;
  max-width: 48px !important;
  min-width: 48px !important;
  flex: 0 0 48px !important;
  padding: 0 !important;
  border-right: none !important;
}
.tabulator .tabulator-row .tabulator-cell:first-child > *,
.tabulator .tabulator-row .tabulator-cell.bulk-select-col > * {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
}

/* Badges stay vertically centered inside flex cells */
.tabulator .tabulator-row .tabulator-cell > span[class*="rounded-full"],
.tabulator .tabulator-row .tabulator-cell .badge {
  display: inline-flex !important;
  align-items: center !important;
  line-height: 1 !important;
  vertical-align: middle;
}

/* Currency / numeric columns — match header alignment */
.tabulator .tabulator-row .tabulator-cell.cell-currency,
.tabulator .tabulator-row .tabulator-cell[tabulator-field="fatturato"],
.tabulator .tabulator-row .tabulator-cell[tabulator-field="importo"] {
  justify-content: flex-end !important;
}
.tabulator .tabulator-header .tabulator-col[tabulator-field="fatturato"] .tabulator-col-content,
.tabulator .tabulator-header .tabulator-col[tabulator-field="importo"] .tabulator-col-content {
  justify-content: flex-end !important;
}
.tabulator .tabulator-header .tabulator-col[tabulator-field="fatturato"] .tabulator-col-title,
.tabulator .tabulator-header .tabulator-col[tabulator-field="importo"] .tabulator-col-title {
  justify-content: flex-end !important;
  width: 100%;
}

/* Action buttons column */
.tabulator .tabulator-row .tabulator-cell:last-child {
  justify-content: center !important;
}

.tabulator .tabulator-footer {
  display: none;
}

/* ── shadcn checkbox in Tabulator header ── */
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .ui-checkbox {
  margin: 0 auto;
}
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fafafa;
}
.bulk-bar.hidden { display: none; }
.bulk-bar__count {
  font-size: 12px;
  font-weight: 500;
  color: #18181b;
}
.bulk-bar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bulk-bar__btn {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #d4d4d8;
  background: #fff;
  color: #3f3f46;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.bulk-bar__btn:hover { background: #f4f4f5; border-color: #a1a1aa; }
.bulk-bar__btn--danger { color: #b91c1c; border-color: #fecaca; }
.bulk-bar__btn--danger:hover { background: #fef2f2; border-color: #f87171; }
.bulk-bar__btn--ghost { border-color: transparent; background: transparent; color: #71717a; }
.bulk-bar__btn--ghost:hover { background: #f4f4f5; color: #3f3f46; }

/* ── Choices.js override (shadcn/ui) ── */
.choices {
  margin: 0;
  font-size: 0.75rem;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
}
.choices.is-focused,
.choices.is-open {
  outline: 2px solid transparent !important;
  box-shadow: none !important;
  border: none !important;
}
.choices .choices__inner {
  background-color: #ffffff !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 0.375rem !important;
  min-height: 32px !important;
  height: 32px !important;
  padding: 0 0.5rem !important;
  font-size: 0.75rem !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}
.choices.is-focused .choices__inner,
.choices.is-open .choices__inner {
  border-color: var(--input-focus-border) !important;
  box-shadow: 0 0 0 1px var(--input-focus-border), 0 0 0 4px var(--input-focus-ring) !important;
  border-radius: 0.375rem !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
}
.choices .choices__list--single {
  padding: 0 !important;
  font-size: 0.75rem !important;
  line-height: 1rem !important;
}
.choices[data-type*="select-one"]::after {
  margin-top: -2px !important;
  border-width: 4px !important;
}
.choices .choices__list--dropdown {
  z-index: 9999 !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 0.375rem !important;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1) !important;
  background-color: #ffffff !important;
  margin-top: 4px !important;
}
.choices .choices__input {
  border-bottom: 1px solid #f4f4f5 !important;
  font-size: 0.75rem !important;
  padding: 0.5rem !important;
  margin-bottom: 0 !important;
  background: transparent !important;
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}
.choices .choices__input:focus,
.choices .choices__input:focus-visible {
  outline: 2px solid transparent !important;
  box-shadow: none !important;
  border-color: #f4f4f5 !important;
}
.choices .choices__item--choice {
  padding: 0.375rem 0.75rem !important;
  font-size: 0.875rem !important;
  text-align: left !important;
  color: #09090b !important;
  transition: background-color 0.15s !important;
}
.choices .choices__item--selectable.is-highlighted {
  background-color: #f4f4f5 !important;
  color: #09090b !important;
  font-weight: 500 !important;
}
.choices .choices__placeholder { opacity: 0.5; }
.choices .choices__button { display: none; }

/* ── Tab form ── */
.form-tab {
  display: none;
}
.form-tab.active {
  display: block;
}
.form-tab-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 10px;
  border: 1px solid #d1d5db; border-radius: 9999px;
  background: #fff; color: #6b7280; cursor: pointer;
  transition: all 0.15s;
}
.form-tab-indicator.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.form-tab-indicator.done {
  border-color: #10b981; color: #10b981;
}
.form-tab-indicator.done::before {
  content: '✓';
  margin-right: 2px;
}

/* ── Impostazioni tabs ── */
.settings-tab {
  display: none;
}
.settings-tab.active {
  display: block;
}

/* ── Toggle switch ── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle__slider {
  position: relative;
  width: 28px;
  height: 16px;
  background: #d1d5db;
  border-radius: 9999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle__slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle__slider {
  background: var(--primary);
}
.toggle input:checked + .toggle__slider::after {
  transform: translateX(12px);
}

/* ── Multistep modal ── */
#multistep-dialog { width: min(94vw, 520px); }

/* ── Nascondi dropdown profilo quando sidebar collassata ── */
.sidebar.collapsed #profile-dropdown { display: none !important; }

/* ── Version sempre visibile in sidebar collassata ── */
.sidebar.collapsed .sidebar-version { display: block !important; }
.sidebar.collapsed:not(.hover-expand) .sidebar-version { text-align: center; }

/* ── Sidebar collassata: layout omogeneo (icone centrate, no label section) ── */
.sidebar.collapsed:not(.hover-expand) .sidebar-section-label,
.sidebar.collapsed:not(.hover-expand) .nav-sub {
  display: none !important;
}

.sidebar.collapsed:not(.hover-expand) .sidebar-hide {
  flex: none !important;
}

.sidebar.collapsed:not(.hover-expand) .sidebar-logo-row {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.sidebar.collapsed:not(.hover-expand) .sidebar-logo-row > a {
  flex: none;
  justify-content: center;
  min-width: 0;
}

.sidebar.collapsed:not(.hover-expand) .sidebar-profile-row {
  justify-content: center;
  gap: 0;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.375rem;
  padding-right: 0.375rem;
  width: fit-content;
  max-width: 100%;
}

.sidebar.collapsed:not(.hover-expand) nav {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  align-items: center;
}
.sidebar.collapsed:not(.hover-expand) nav a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}
.sidebar.collapsed:not(.hover-expand) nav a svg { margin: 0; }
.sidebar.collapsed:not(.hover-expand) .nav-dropdown { width: 100%; }
.sidebar.collapsed:not(.hover-expand) .nav-dropdown-toggle { justify-content: center; }

.sidebar.collapsed:not(.hover-expand) #superadmin-wrap .px-1\.5,
.sidebar.collapsed:not(.hover-expand) #superadmin-wrap .px-3 {
  padding-left: 0;
  padding-right: 0;
}
.sidebar.collapsed:not(.hover-expand) #superadmin-toggle {
  justify-content: center;
  gap: 0;
  padding-left: 0.375rem;
  padding-right: 0.375rem;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ── Fix overflow orizzontale ── */
body { overflow-x: hidden; }

/* ── Toast minimal ── */
#toast-container {
  position: fixed; top: 12px; right: 12px; z-index: 9999;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.toast-msg {
  pointer-events: auto;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  color: #fff;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  max-width: 260px;
}
.toast-msg.show { opacity: 1; transform: translateY(0); }
.toast-msg.success { background: #059669; }
.toast-msg.error   { background: #dc2626; }
.toast-msg.info    { background: #374151; }
.toast-msg.warning { background: #d97706; }

/* ── Filter bar (shadcn Data Table toolbar) ── */
.filter-group { position: relative; display: inline-flex; }

.filter-btn.is-active {
  border-style: solid;
  border-color: #18181b;
  background: #fafafa;
  color: #18181b;
}
.filter-btn__label { white-space: nowrap; }
.filter-btn__pills {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}
.filter-btn__divider {
  width: 1px; height: 14px;
  background: #e4e4e7;
  margin: 0 4px;
}
.filter-btn__pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  color: #18181b;
  background: #f4f4f5;
  border-radius: 4px;
  white-space: nowrap;
}

.filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: #71717a;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
}
.filter-reset:hover { color: #18181b; }
.filter-reset.hidden { display: none; }

/* Popover panel */
.filter-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  z-index: 50;
  overflow: hidden;
}
.filter-popover.hidden { display: none; }
.filter-popover__search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #f4f4f5;
}
.filter-popover__search-icon {
  width: 14px; height: 14px; flex-shrink: 0;
  stroke: #a1a1aa; stroke-width: 2; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.filter-popover__search input {
  flex: 1;
  border: 0; outline: 0;
  font-size: 11px;
  color: #18181b;
  background: transparent;
}
.filter-popover__search input::placeholder { color: #a1a1aa; }
.filter-popover__list {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}
.filter-popover__list::-webkit-scrollbar { width: 4px; }
.filter-popover__list::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 2px; }

/* Option items */
.filter-popover__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 11px;
  color: #374151;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}
.filter-popover__option:hover { background: #f4f4f5; }
.filter-popover__option.is-selected { background: #f4f4f5; font-weight: 500; }
.filter-popover__option[hidden] { display: none; }

/* Checkbox */
.filter-popover__check {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 1px solid #d4d4d8; border-radius: 3px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.filter-popover__option.is-selected .filter-popover__check {
  background: var(--primary); border-color: var(--primary);
}
.filter-popover__check svg {
  width: 10px; height: 10px; stroke: #fff; stroke-width: 2.5;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.15s;
}
.filter-popover__option.is-selected .filter-popover__check svg { opacity: 1; }

.filter-popover__option-label { flex: 1; }
.filter-popover__option-count {
  margin-left: auto;
  font-size: 10px;
  color: #a1a1aa;
  font-weight: 400;
}

/* Separator */
.filter-popover__sep {
  height: 1px; margin: 4px 4px;
  background: #f4f4f5;
}

/* Footer — clear button */
.filter-popover__footer {
  padding: 4px;
  border-top: 1px solid #f4f4f5;
}
.filter-popover__footer.hidden { display: none; }
.filter-popover__clear {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  font-size: 11px;
  color: #71717a;
  border: 0;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.filter-popover__clear:hover { color: #ef4444; background: #fef2f2; }


/* Search input — legacy hook; prefer Tailwind classes on .filter-search */

.filter-popover__empty {
  padding: 12px 8px;
  font-size: 11px;
  color: #a1a1aa;
  text-align: center;
}

/* ── Command palette ── */
#cmd-palette { filter: drop-shadow(0 8px 32px rgba(0,0,0,0.12)); }

/* ── Custom table pagination ── */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 0 0 2px 2px;
  font-size: 12px;
  color: #71717a;
}
.table-pagination__status { font-size: 11px; color: #a1a1aa; }
.table-pagination__controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.table-pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.table-pagination__btn:hover:not(.disabled):not(.active) { background: #f4f4f5; }
.table-pagination__btn.active { background: #18181b; border-color: #18181b; color: #fff; }
.table-pagination__btn.disabled { opacity: 0.3; cursor: not-allowed; }
.table-pagination__btn svg { width: 12px; height: 12px; }
.table-pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 26px;
  font-size: 11px;
  color: #a1a1aa;
}
.table-pagination__size {
  height: 26px;
  padding: 0 6px;
  font-size: 11px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.table-pagination__size:focus { outline: none; border-color: var(--primary); }
