@import url("bsuite-dialogs.css");
@import url("bsuite-ui-depth.css");

:root {
  /* STEP 4 palette — primario #023661, dark leggibile, success/danger dedicati */
  --bg-body: #0a0c12;
  --bg-surface: #12151e;
  --bg-surface-alt: #161a24;
  --bg-card: var(--bsuite-depth-panel-2, #252f45);
  --bg-sidebar: #12151e;
  --bg-topbar: #12151e;
  --border-subtle: #76828e;
  --accent: #023661;
  --accent-soft: rgba(2, 54, 97, 0.12);
  --accent-strong: rgba(2, 54, 97, 0.45);
  --color-success: #308446;
  --color-danger: #dc143c;
  --color-accent-pink: #ff007f;
  --color-accent-yellow: #f8f32b;
  --text-main: #e8eaef;
  --text-muted: #76828e;
  --text-strong: #f9fafb;
  --input-bg: var(--bsuite-depth-field, #131b2a);
  --bg-main: var(--bsuite-depth-panel, #1e2638);
  --bg-elevated: var(--bsuite-depth-panel-2, #252f45);
  /* STEP 12+15 — zebra ancora più netta sulla shell principale */
  --table-zebra-odd: rgba(255, 255, 255, 0.045);
  --table-zebra-even: rgba(255, 255, 255, 0.3);
  --table-row-hover: rgba(2, 54, 97, 0.52);
  --table-row-selected: rgba(2, 54, 97, 0.68);
  --table-row-border: rgba(118, 130, 142, 0.45);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.68);
  --transition-fast: 150ms ease-out;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  /* Altezza guida topbar ≈ logo attivo + padding verticale layout-topbar (+20% rispetto a 67px) */
  --topbar-active-logo-h: 80px;
  /* Altezza “fascia” azioni modulo nello shell (pulsanti a tutta altezza utile della topbar) */
  --topbar-shell-actions-h: var(--topbar-active-logo-h);
  /* Sotto questa larghezza (per singolo tab) la label viene nascosta: solo icona + tooltip. */
  --shell-tab-btn-label-hide-below: 4.35rem;
  --topbar-height: 90px;
  --topbar-company-name-size: 13.5px;
  --topbar-username-size: 11.75px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

/* Shell principale: niente scroll sulla finestra (login / pagine senza layout-root restano scrollabili). */
html:has(> body > .layout-root),
body:has(> .layout-root) {
  overflow: hidden;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 18% 0%, #1a3a5c 0, #0a0c12 48%, #07080c 100%);
  color: var(--text-main);
}

.layout-root {
  display: flex;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.layout-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(160deg, #12151e 0%, #161a24 40%, #1a1f2e 100%);
  border-right: 1px solid var(--border-subtle);
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 2px 2px 8px 2px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  margin-bottom: 2px;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, #2a7ab8 0, #023661 45%, #012440 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 18px;
  box-shadow: 0 12px 32px rgba(2, 54, 97, 0.55);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
}

.sidebar-logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-build-badge {
  margin: 6px 0 0;
  padding: 0;
  max-width: 11rem;
  font-size: 10px;
  line-height: 1.35;
  color: var(--text-muted);
  opacity: 0.92;
}

.sidebar-active-company-line {
  padding: 0 4px 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.layout-root.sidebar-collapsed .sidebar-active-company-line {
  display: none;
}

.sidebar-shell-user-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.layout-root.sidebar-collapsed .sidebar-shell-user-line {
  display: none;
}

.sidebar-shell-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.35), rgba(15, 23, 42, 0.85));
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.45);
  flex-shrink: 0;
  user-select: none;
}

html[data-theme="light"] .sidebar-shell-user-avatar:not([style*="background-color"]) {
  background: linear-gradient(145deg, #e2e8f0, #f8fafc);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}

.sidebar-shell-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.3;
  word-break: break-word;
  min-width: 0;
}

.sidebar-company-logo-wrap {
  margin-bottom: 6px;
}

.sidebar-company-logo {
  display: block;
  max-width: 100%;
  max-height: 40px;
  object-fit: contain;
  border-radius: 6px;
}

.sidebar-active-company-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.35;
  word-break: break-word;
}

.sidebar-menu {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  margin-right: -2px;
}

.sidebar-section-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.32rem;
}

.sidebar-section-group:last-child {
  margin-bottom: 0;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0.16rem 4px 0;
  font-weight: 600;
}

.sidebar-section-toggle {
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin: 0.16rem 4px 0;
  padding: 0.28rem 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.sidebar-section-toggle:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.18);
}

.sidebar-section-toggle-text {
  flex: 1;
  min-width: 0;
}

.sidebar-section-toggle-caret {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-bottom: 3px;
  opacity: 0.72;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-section-collapsed .sidebar-section-toggle-caret {
  transform: rotate(-135deg);
  margin-bottom: -1px;
}

.sidebar-section-collapsed .sidebar-section-items {
  display: none !important;
}

/* Non sovrascrivere: con sidebar globale compressa i gruppi devono poter nascondere le voci figlie. */

.sidebar-section-group:first-child .sidebar-section-label,
.sidebar-section-group:first-child .sidebar-section-toggle {
  margin-top: 0;
}

.sidebar-section-toggle {
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.32rem 6px;
  margin: 0.16rem 4px 0;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.sidebar-section-group:first-child .sidebar-section-toggle {
  margin-top: 0;
}

.sidebar-section-toggle:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.18);
}

.sidebar-section-toggle-text {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.sidebar-section-toggle-caret {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-bottom: 3px;
  opacity: 0.72;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-section-divider {
  height: 1px;
  margin: 0 4px 2px;
  border: 0;
  background: rgba(148, 163, 184, 0.28);
  flex-shrink: 0;
}

.sidebar-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  padding: 6px 9px;
  min-height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12.75px;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.sidebar-item:hover:not(.active) {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-strong);
  border: 1px solid rgba(148, 163, 184, 0.22);
  transform: translateY(-0.5px);
}

.sidebar-item.active {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.62), rgba(79, 70, 229, 0.52));
  color: #ffffff;
  border: 1px solid rgba(147, 197, 253, 0.9);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45), inset 3px 0 0 rgba(219, 234, 254, 0.95);
}

.sidebar-item.active:hover {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.72), rgba(79, 70, 229, 0.6));
  border-color: rgba(191, 219, 254, 0.95);
  color: #ffffff;
}

.sidebar-item-label {
  flex: 1;
}

.sidebar-item-icon {
  flex-shrink: 0;
  width: 1.28rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.15;
  cursor: pointer;
  user-select: none;
}

.sidebar-module-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-module-wrap--att {
  gap: 4px;
  padding: 2px 0 4px;
}

.sidebar-item.sidebar-item--att-tab {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12.5px;
}

.sidebar-item.sidebar-item--att-tab.active {
  box-shadow: inset 3px 0 0 rgba(219, 234, 254, 0.95);
}

.sidebar-item-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}

.sidebar-item-row > .sidebar-item {
  flex: 1;
  min-width: 0;
}

.sidebar-submenu-toggle {
  flex-shrink: 0;
  width: 32px;
  min-width: 32px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.45);
  color: var(--text-main);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-submenu-toggle:hover {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.4);
}

.sidebar-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 10px;
  margin-left: 4px;
  border-left: 2px solid rgba(148, 163, 184, 0.22);
}

/* Stime e Budget / Commesse: pannello sotto-voci solo se il modulo è attivo nell’iframe (classe da app.js). */
.sidebar-module-wrap[data-shell-contextual-submenu] .sidebar-submenu--contextual {
  display: none !important;
}

.sidebar-module-wrap[data-shell-contextual-submenu].sidebar-module-wrap--shell-active .sidebar-submenu--contextual {
  display: flex !important;
  flex-direction: column;
}

.sidebar-subitem {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, rgba(148, 163, 184, 0.92));
  text-align: left;
  padding: 5px 8px 5px 10px;
  min-height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-subitem:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.18);
}

.sidebar-subitem.active {
  background: rgba(37, 99, 235, 0.22);
  color: #e2e8f0;
  border-color: rgba(147, 197, 253, 0.45);
  box-shadow: inset 3px 0 0 rgba(147, 197, 253, 0.75);
}

html[data-theme="light"] .sidebar-subitem {
  color: rgba(51, 65, 85, 0.88);
}

html[data-theme="light"] .sidebar-subitem.active {
  background: rgba(37, 99, 235, 0.14);
  color: #0f172a;
  border-color: rgba(37, 99, 235, 0.35);
}

/* Preferiti utente (Commesse) sotto «Moduli base» nella shell. */
.shell-user-favorites-block {
  margin: 0.35rem 0 0.5rem;
  padding: 0 2px 0 4px;
}

.shell-user-favorites-rule {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  margin: 0.35rem 4px 0.3rem;
}

.shell-user-favorites-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, rgba(148, 163, 184, 0.92));
  padding: 0 6px 4px;
}

.shell-user-favorites-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: min(38vh, 14rem);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 2px 4px 4px;
  scrollbar-width: thin;
}

.shell-user-favorite-item {
  width: 100%;
  margin: 0;
  padding: 5px 8px 5px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, rgba(148, 163, 184, 0.92));
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.shell-user-favorite-item:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.18);
}

.shell-user-favorite-code {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: inherit;
  opacity: 0.95;
}

.shell-user-favorite-name {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1px;
  color: inherit;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.shell-user-favorites-empty {
  margin: 0;
  padding: 4px 8px 6px 10px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-muted, rgba(148, 163, 184, 0.85));
}

html[data-theme="light"] .shell-user-favorites-rule {
  border-top-color: rgba(148, 163, 184, 0.45);
}

html[data-theme="light"] .shell-user-favorite-item {
  color: rgba(51, 65, 85, 0.9);
}

html[data-theme="light"] .shell-user-favorite-item:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
}

.sidebar-menu-toggle-wrap {
  margin-top: 0;
  width: auto;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: border var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast),
    width var(--transition-fast), transform var(--transition-fast);
}

.sidebar-toggle-btn .sidebar-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.layout-root:not(.sidebar-collapsed) .sidebar-toggle-icon--to-expand {
  display: none !important;
}

.layout-root.sidebar-collapsed .sidebar-toggle-icon--to-collapse {
  display: none !important;
}

.layout-root.sidebar-collapsed .sidebar-menu-toggle-wrap {
  display: flex;
  justify-content: center;
}

.layout-root.sidebar-collapsed .sidebar-toggle-btn {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.sidebar-toggle-btn:hover {
  border-color: rgba(96, 165, 250, 0.75);
  background: rgba(30, 41, 59, 0.95);
  transform: translateY(-0.5px);
}

.topbar-shell-context {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  flex: 0 1 auto;
}

.topbar-company-block {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  max-width: min(58vw, 520px);
  height: var(--topbar-active-logo-h);
  max-height: var(--topbar-active-logo-h);
  min-height: var(--topbar-active-logo-h);
}

.topbar-company-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
  height: 100%;
  max-height: var(--topbar-active-logo-h);
  overflow: hidden;
}

.topbar-context-box {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  max-width: min(52vw, 420px);
  margin: 0;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 7px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.22);
}

.topbar-context-cell {
  padding: 3px 8px 4px;
  vertical-align: top;
  text-align: left;
  min-width: 0;
}

.topbar-context-box tbody tr + tr .topbar-context-cell {
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.topbar-context-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(148, 163, 184, 0.78);
  line-height: 1.15;
  margin-bottom: 2px;
}

.topbar-context-user-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.topbar-context-value {
  font-size: var(--topbar-company-name-size);
  font-weight: 650;
  line-height: 1.18;
  color: #f8fafc;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.topbar-context-value--user {
  font-size: var(--topbar-username-size);
  font-weight: 500;
  line-height: 1.22;
  color: rgba(226, 232, 240, 0.92);
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-company-text {
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

.topbar-active-company-name {
  font-size: var(--topbar-company-name-size);
  font-weight: 650;
  line-height: 1.18;
  color: #ffffff;
  text-align: left;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.topbar-user-logout-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

.topbar-active-username {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--topbar-username-size);
  font-weight: 500;
  line-height: 1.22;
  color: var(--text-muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  user-select: text;
}

.topbar-settings-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(203, 213, 225, 0.45);
  background: rgba(30, 41, 59, 0.98);
  color: #f8fafc;
  cursor: pointer;
  transition: border var(--transition-fast), background var(--transition-fast), color var(--transition-fast),
    transform var(--transition-fast);
}

.topbar-settings-btn:hover {
  border-color: rgba(248, 250, 252, 0.55);
  background: rgba(51, 65, 85, 1);
  color: #ffffff;
  transform: translateY(-0.5px);
}

.topbar-settings-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.85);
  outline-offset: 2px;
}

html[data-theme="light"] .topbar-settings-btn {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}

html[data-theme="light"] .topbar-settings-btn:hover {
  border-color: rgba(37, 99, 235, 0.55);
  background: #eff6ff;
  color: #1d4ed8;
}

.topbar-logout-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.35);
  color: rgba(203, 213, 225, 0.82);
  cursor: pointer;
  transition: border var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.topbar-logout-btn:hover {
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(30, 41, 59, 0.72);
  color: #f1f5f9;
}

html[data-theme="light"] .topbar-logout-btn {
  background: rgba(248, 250, 252, 0.9);
  color: rgba(71, 85, 105, 0.95);
  border-color: rgba(148, 163, 184, 0.45);
}

html[data-theme="light"] .topbar-logout-btn:hover {
  border-color: rgba(100, 116, 139, 0.65);
  background: #f1f5f9;
  color: #0f172a;
}

.topbar-active-company-logo-wrap {
  margin-bottom: 0 !important;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  align-self: stretch;
  height: 100%;
}

.topbar-active-company-logo {
  display: block;
  width: auto;
  height: var(--topbar-active-logo-h) !important;
  max-height: var(--topbar-active-logo-h);
  max-width: min(240px, 34vw);
  object-fit: contain;
}

@media (min-width: 901px) {
  .layout-root.sidebar-collapsed .sidebar-header-row {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
  }

  .layout-root.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    width: 100%;
  }

  .layout-root.sidebar-collapsed .layout-sidebar {
    width: var(--sidebar-collapsed-width);
    padding: 18px 8px;
  }

  .layout-root.sidebar-collapsed .sidebar-logo-text,
  .layout-root.sidebar-collapsed .sidebar-section-toggle-text,
  .layout-root.sidebar-collapsed .sidebar-section-divider,
  .layout-root.sidebar-collapsed .sidebar-item-label {
    display: none;
  }

  .layout-root.sidebar-collapsed .sidebar-section-toggle {
    justify-content: center;
    padding: 4px;
    margin-left: 2px;
    margin-right: 2px;
  }

  .layout-root.sidebar-collapsed .sidebar-item {
    justify-content: center;
  }

  .layout-root.sidebar-collapsed .sidebar-submenu,
  .layout-root.sidebar-collapsed .sidebar-submenu-toggle {
    display: none !important;
  }

  .layout-root.sidebar-collapsed .theme-toggle-label {
    display: none;
  }
}

/* Tooltip moduli: solo sidebar compressa desktop (mostrato via JS) */
.sidebar-collapsed-tooltip {
  position: fixed;
  z-index: 10050;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: #f1f5f9;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  max-width: min(240px, 70vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="light"] .sidebar-collapsed-tooltip {
  color: #0f172a;
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.55);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .sidebar-toggle-btn {
  background: #ffffff;
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.6);
}

html[data-theme="light"] .sidebar-toggle-btn:hover {
  background: #f1f5f9;
  border-color: rgba(37, 99, 235, 0.45);
}

.layout-main {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.layout-topbar {
  position: relative;
  z-index: 40;
  flex-shrink: 0;
  min-height: calc(var(--topbar-active-logo-h) + 10px);
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr minmax(0, max-content);
  align-items: stretch;
  gap: 10px;
  padding: 5px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), #0f1b30 58%);
  backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.topbar-left {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 12px;
  min-width: 0;
}

.topbar-company-logo-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  max-width: min(42vw, 200px);
}

.topbar-company-logo-wrap.hidden {
  display: none !important;
}

.topbar-active-company-logo {
  display: block;
  max-height: 40px;
  max-width: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}

.topbar-center {
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.topbar-right > .topbar-reminders-wrap,
.topbar-right > .topbar-user-cluster,
.topbar-right > .topbar-settings-stack {
  align-self: center;
}

.topbar-settings-stack {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Icona undo Commesse: stesse dimensioni della rotella impostazioni */
.topbar-settings-btn.topbar-commesse-undo-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.topbar-settings-btn.topbar-commesse-undo-btn:hover:not(:disabled) {
  border-color: rgba(248, 250, 252, 0.55);
  background: rgba(51, 65, 85, 1);
  color: #ffffff;
  transform: translateY(-0.5px);
}

html[data-theme="light"] .topbar-settings-btn.topbar-commesse-undo-btn:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.55);
  background: #eff6ff;
  color: #1d4ed8;
}

.topbar-user-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.shell-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.35), rgba(15, 23, 42, 0.85));
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.45);
  flex-shrink: 0;
  user-select: none;
}

html[data-theme="light"] .shell-user-avatar:not([style*="background-color"]) {
  background: linear-gradient(145deg, #e2e8f0, #f8fafc);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}

.topbar-settings-stack .topbar-settings-btn--trailing {
  flex-shrink: 0;
  margin-left: 0;
}

.shell-pdf-export-btn {
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.72));
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.shell-pdf-export-btn:hover:not(:disabled) {
  border-color: rgba(96, 165, 250, 0.85);
}

.shell-pdf-export-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

html[data-theme="light"] .shell-pdf-export-btn {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.65);
}

/* Azioni contestuali del modulo (nodi spostati dall’iframe; stili qui perché il CSS del modulo non vale nel parent). */
.topbar-module-actions {
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  align-content: center;
  justify-content: center;
  gap: 8px 10px;
  max-width: 100%;
  width: 100%;
  min-height: var(--topbar-shell-actions-h);
}

.topbar-module-actions .app-header-ops {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-height: var(--topbar-shell-actions-h);
}

.topbar-module-actions .app-header-ops-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.85);
  white-space: nowrap;
  align-self: center;
  flex-shrink: 0;
}

.topbar-module-actions .inv-mode-toolbar .app-header-ops-label {
  align-self: center;
  margin-right: 2px;
}

.topbar-module-actions .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--topbar-shell-actions-h);
  padding: 8px 12px;
  border-radius: 12px;
  border: none;
  background: rgba(15, 23, 42, 0.92);
  color: #f9fafb;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.45);
}

.topbar-module-actions .icon-button:hover {
  background: #020617;
}

.topbar-module-actions .icon-circle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  background: #e5e7eb;
  color: #0f172a;
}

/* Commesse / Stime e Budget nello shell: una sola riga, altezza = fascia topbar, larghezze uniformi (flex), nessuno scroll orizzontale; sotto soglia → solo icona (label sr-only, tooltip da title). */
.topbar-module-actions .bsuite-shell-segment-toolbar {
  container-type: inline-size;
  display: flex;
  flex-flow: row nowrap;
  align-items: stretch;
  align-self: stretch;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0 auto;
  min-height: var(--topbar-shell-actions-h);
  overflow-x: hidden;
  overflow-y: visible;
}

.topbar-module-actions .bsuite-shell-segment-toolbar > .commesse-shell-toolbar-sep {
  flex: 0 0 1px;
  width: 1px;
  min-width: 1px;
  max-width: 1px;
  align-self: stretch;
  min-height: var(--topbar-shell-actions-h);
  background: rgba(148, 163, 184, 0.45);
}

.topbar-module-actions .bsuite-shell-segment-toolbar .commesse-shell-toolbar-nth-bridge {
  display: none !important;
  flex: 0 0 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Tutti i pulsanti diretti della toolbar segment (Commesse, Budget, Fatture, RINT, …). */
.topbar-module-actions .bsuite-shell-segment-toolbar > button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  max-width: none;
  height: var(--topbar-shell-actions-h);
  min-height: var(--topbar-shell-actions-h);
  max-height: var(--topbar-shell-actions-h);
  padding: 5px 6px;
  gap: 4px;
  container-type: inline-size;
  container-name: shell-tab-btn;
  text-align: center;
  font-weight: 600;
  line-height: 1.15;
  white-space: normal;
  cursor: pointer;
}

.topbar-module-actions .bsuite-shell-segment-toolbar > button.commesse-mode-btn {
  border-radius: 12px;
  border: 2px solid rgba(129, 140, 248, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e0e7ff;
  font-size: 10px;
}

.topbar-module-actions .bsuite-shell-segment-toolbar > button.inv-mode-btn {
  border-radius: var(--radius-sm, 8px);
  border: 1px solid rgba(129, 140, 248, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e0e7ff;
  font-size: 10px;
}

/* Cashflow / azioni icona: stessa altezza fascia, etichetta sotto l’icona. */
.topbar-module-actions .bsuite-shell-segment-toolbar > button.icon-button {
  border-radius: 12px;
  border: none;
  background: rgba(15, 23, 42, 0.92);
  color: #f9fafb;
  font-size: 9px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.45);
}

.topbar-module-actions .bsuite-shell-segment-toolbar > button.icon-button:hover {
  background: #020617;
}

.topbar-module-actions .bsuite-shell-segment-toolbar > button.icon-button .icon-circle {
  width: 32px;
  height: 32px;
  font-size: 17px;
  flex-shrink: 0;
}

.topbar-module-actions .bsuite-shell-segment-toolbar .bsuite-shell-tab-ic {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.topbar-module-actions .bsuite-shell-segment-toolbar .bsuite-shell-tab-lbl {
  font-size: 10px;
  font-weight: 600;
  max-width: 100%;
  width: 100%;
  white-space: normal;
  line-height: 1.12;
  text-wrap: balance;
  overflow-wrap: break-word;
}

/* Etichetta modulo (PRESENZE, CRM, …): non occupare spazio nella shell unificata. */
.topbar-module-actions .bsuite-shell-segment-toolbar > .app-header-ops-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.topbar-module-actions .app-header-ops.bsuite-shell-segment-toolbar {
  container-type: inline-size;
  display: flex;
  flex-flow: row nowrap;
  align-items: stretch;
  align-self: stretch;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0 auto;
  min-height: var(--topbar-shell-actions-h);
  overflow-x: hidden;
  overflow-y: visible;
}

html[data-theme="light"] .topbar-module-actions .bsuite-shell-segment-toolbar > button.icon-button {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.65);
  box-shadow: none;
}

html[data-theme="light"] .topbar-module-actions .bsuite-shell-segment-toolbar > button.icon-button:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: #312e81;
}

/* Costo dipendenti: unico “tab” statico nella shell. */
.topbar-module-actions .bsuite-shell-segment-toolbar > .inv-mode-btn--static {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  height: var(--topbar-shell-actions-h);
  min-height: var(--topbar-shell-actions-h);
  max-height: var(--topbar-shell-actions-h);
  margin: 0;
  padding: 5px 8px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid rgba(129, 140, 248, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e0e7ff;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  cursor: default;
}

.topbar-module-actions .bsuite-shell-segment-toolbar .commesse-shell-btn-ic {
  font-size: 1.45rem;
  line-height: 1;
  flex-shrink: 0;
}

.topbar-module-actions .bsuite-shell-segment-toolbar .commesse-shell-btn-lbl {
  font-size: 10px;
  font-weight: 600;
  max-width: 100%;
  width: 100%;
  white-space: normal;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.topbar-module-actions .commesse-mode-btn.is-on {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.16) 0%, rgba(37, 99, 235, 0.42) 45%, rgba(15, 23, 42, 0.55) 100%);
  border-color: rgba(125, 211, 252, 0.88);
  font-weight: 700;
  color: #ffffff;
  box-shadow: var(--bsuite-shell-tab-active-glow);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.topbar-module-actions .commesse-mode-btn:hover:not(.is-on) {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(96, 165, 250, 0.55);
  color: #f8fafc;
}

/* Commesse shell: tinte distinte per pulsante (stato base non selezionato) — nel topbar la classe -for-shell viene rimossa dal nodo. */
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(1) {
  border-color: rgba(34, 211, 238, 0.72);
  background: rgba(8, 47, 73, 0.78);
  color: #ecfeff;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(2) {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(69, 26, 3, 0.45);
  color: #fffbeb;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(3) {
  border-color: rgba(192, 132, 252, 0.65);
  background: rgba(59, 7, 100, 0.42);
  color: #faf5ff;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(4) {
  border-color: rgba(52, 211, 153, 0.68);
  background: rgba(6, 78, 59, 0.45);
  color: #ecfdf5;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(5) {
  border-color: rgba(251, 113, 133, 0.68);
  background: rgba(69, 10, 10, 0.5);
  color: #fff1f2;
}

.topbar-module-actions .commesse-mode-btn:focus-visible,
.topbar-module-actions .inv-mode-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.95);
  outline-offset: 2px;
}

.topbar-module-actions .inv-mode-toolbar:not(.bsuite-shell-segment-toolbar),
.topbar-module-actions .cb-mode-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  align-self: stretch;
  gap: 8px 10px;
  justify-content: flex-end;
  min-height: var(--topbar-shell-actions-h);
}

.topbar-module-actions .inv-mode-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--topbar-shell-actions-h);
  min-width: 3.5rem;
  max-width: 7.5rem;
  padding: 6px 10px;
  border-radius: 12px;
  border: 2px solid rgba(129, 140, 248, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e0e7ff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
}

.topbar-module-actions .inv-mode-toolbar:not(.esb-stime-shell-toolbar) .inv-mode-btn > span:first-child {
  font-size: 1.5rem;
  line-height: 1;
}

.topbar-module-actions .inv-mode-toolbar .esb-shell-tab-label {
  display: block;
  max-width: 6.75rem;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
}

/* Stime e Budget nello shell: icona sopra, testo sotto (layout comune su .bsuite-shell-segment-toolbar > button). */
.topbar-module-actions .bsuite-shell-segment-toolbar.inv-mode-toolbar.esb-stime-shell-toolbar .esb-shell-tab-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  gap: 0.22rem;
  text-align: center;
}

.topbar-module-actions .bsuite-shell-segment-toolbar.inv-mode-toolbar.esb-stime-shell-toolbar .inv-mode-btn .esb-shell-tab-stack > span:first-child {
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.topbar-module-actions .bsuite-shell-segment-toolbar.inv-mode-toolbar.esb-stime-shell-toolbar .inv-mode-btn .esb-shell-tab-label {
  display: block;
  max-width: 100%;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
  overflow-wrap: break-word;
}

/* Budget + Commesse + tab generici: quando il singolo tab è stretto, solo icona (title/aria-label restano per tooltip e accessibilità). */
/* Allineare a :root --shell-tab-btn-label-hide-below (i container query non accettano var ovunque). */
@container shell-tab-btn (max-width: 4.35rem) {
  .topbar-module-actions .bsuite-shell-segment-toolbar > button .commesse-shell-btn-lbl,
  .topbar-module-actions .bsuite-shell-segment-toolbar > button .esb-shell-tab-label,
  .topbar-module-actions .bsuite-shell-segment-toolbar > button .bsuite-shell-tab-lbl {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip-path: inset(50%);
    white-space: nowrap !important;
    border: 0 !important;
  }

  .topbar-module-actions .bsuite-shell-segment-toolbar .commesse-shell-btn-ic {
    font-size: 1.6rem;
  }

  .topbar-module-actions .bsuite-shell-segment-toolbar .inv-mode-btn .esb-shell-tab-stack > span:first-child {
    font-size: 1.32rem;
  }

  .topbar-module-actions .bsuite-shell-segment-toolbar .bsuite-shell-tab-ic {
    font-size: 1.5rem;
  }
}

.topbar-module-actions .inv-mode-btn.inv-mode-btn-active {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.14) 0%, rgba(37, 99, 235, 0.4) 45%, rgba(15, 23, 42, 0.55) 100%);
  border-color: rgba(125, 211, 252, 0.88);
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--bsuite-shell-tab-active-glow);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.topbar-module-actions .inv-mode-btn:hover:not(.inv-mode-btn-active) {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.55);
  color: #f8fafc;
}

/* Toolbar shell (RINT, Presenze, ESB, …): palette a stacchi tra pulsanti */
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(1) {
  border-color: rgba(34, 211, 238, 0.72);
  background: rgba(8, 47, 73, 0.78);
  color: #ecfeff;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(2) {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(69, 26, 3, 0.45);
  color: #fffbeb;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(3) {
  border-color: rgba(192, 132, 252, 0.65);
  background: rgba(59, 7, 100, 0.42);
  color: #faf5ff;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(4) {
  border-color: rgba(251, 113, 133, 0.68);
  background: rgba(69, 10, 10, 0.5);
  color: #fff1f2;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(5) {
  border-color: rgba(52, 211, 153, 0.68);
  background: rgba(6, 78, 59, 0.45);
  color: #ecfdf5;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(6) {
  border-color: rgba(96, 165, 250, 0.72);
  background: rgba(23, 37, 84, 0.55);
  color: #eff6ff;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(7) {
  border-color: rgba(250, 204, 21, 0.6);
  background: rgba(66, 32, 6, 0.42);
  color: #fefce8;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(8) {
  border-color: rgba(125, 211, 252, 0.68);
  background: rgba(12, 74, 110, 0.45);
  color: #f0f9ff;
}

.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(1) {
  background: linear-gradient(160deg, rgba(6, 182, 212, 0.55), rgba(15, 23, 42, 0.92));
  border-color: rgba(34, 211, 238, 0.95);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(2) {
  background: linear-gradient(160deg, rgba(245, 158, 11, 0.55), rgba(15, 23, 42, 0.92));
  border-color: rgba(251, 191, 36, 0.9);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(3) {
  background: linear-gradient(160deg, rgba(168, 85, 247, 0.5), rgba(15, 23, 42, 0.92));
  border-color: rgba(192, 132, 252, 0.92);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(4) {
  background: linear-gradient(160deg, rgba(244, 63, 94, 0.48), rgba(15, 23, 42, 0.92));
  border-color: rgba(251, 113, 133, 0.9);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(5) {
  background: linear-gradient(160deg, rgba(16, 185, 129, 0.5), rgba(15, 23, 42, 0.92));
  border-color: rgba(52, 211, 153, 0.9);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(6) {
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.55), rgba(15, 23, 42, 0.92));
  border-color: rgba(96, 165, 250, 0.92);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(7) {
  background: linear-gradient(160deg, rgba(234, 179, 8, 0.5), rgba(15, 23, 42, 0.92));
  border-color: rgba(250, 204, 21, 0.88);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(8) {
  background: linear-gradient(160deg, rgba(14, 165, 233, 0.52), rgba(15, 23, 42, 0.92));
  border-color: rgba(125, 211, 252, 0.9);
  color: #f8fafc;
}

.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(1) {
  background: rgba(6, 182, 212, 0.28);
  border-color: rgba(34, 211, 238, 0.85);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(2) {
  background: rgba(245, 158, 11, 0.28);
  border-color: rgba(251, 191, 36, 0.8);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(3) {
  background: rgba(168, 85, 247, 0.26);
  border-color: rgba(192, 132, 252, 0.82);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(4) {
  background: rgba(244, 63, 94, 0.26);
  border-color: rgba(251, 113, 133, 0.82);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(5) {
  background: rgba(16, 185, 129, 0.26);
  border-color: rgba(52, 211, 153, 0.82);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(6) {
  background: rgba(59, 130, 246, 0.28);
  border-color: rgba(96, 165, 250, 0.85);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(7) {
  background: rgba(234, 179, 8, 0.26);
  border-color: rgba(250, 204, 21, 0.78);
  color: #f8fafc;
}
.topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:hover:not(.inv-mode-btn-active):nth-of-type(8) {
  background: rgba(14, 165, 233, 0.26);
  border-color: rgba(125, 211, 252, 0.82);
  color: #f8fafc;
}

.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(1) {
  background: linear-gradient(160deg, rgba(6, 182, 212, 0.55), rgba(15, 23, 42, 0.92));
  border-color: rgba(34, 211, 238, 0.95);
  color: #f8fafc;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(2) {
  background: linear-gradient(160deg, rgba(245, 158, 11, 0.55), rgba(15, 23, 42, 0.92));
  border-color: rgba(251, 191, 36, 0.9);
  color: #f8fafc;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(3) {
  background: linear-gradient(160deg, rgba(168, 85, 247, 0.5), rgba(15, 23, 42, 0.92));
  border-color: rgba(192, 132, 252, 0.92);
  color: #f8fafc;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(4) {
  background: linear-gradient(160deg, rgba(16, 185, 129, 0.5), rgba(15, 23, 42, 0.92));
  border-color: rgba(52, 211, 153, 0.9);
  color: #f8fafc;
}
.topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(5) {
  background: linear-gradient(160deg, rgba(244, 63, 94, 0.48), rgba(15, 23, 42, 0.92));
  border-color: rgba(251, 113, 133, 0.9);
  color: #f8fafc;
}

.topbar-module-actions .ec-toolbar-for-shell.inv-mode-toolbar {
  gap: 8px 10px;
}

.topbar-module-actions .ec-toolbar-for-shell.bsuite-shell-segment-toolbar.inv-mode-toolbar {
  flex-flow: row nowrap;
  overflow-x: hidden;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
}

.topbar-module-actions .ec-toolbar-for-shell .inv-mode-btn {
  max-width: 9rem;
  padding: 7px 14px;
  border-radius: 12px;
  border: 2px solid rgba(129, 140, 248, 0.55);
  font-size: 12px;
  font-weight: 600;
}

.topbar-module-actions .ec-toolbar-for-shell.bsuite-shell-segment-toolbar .inv-mode-btn {
  max-width: none;
  padding: 5px 8px;
  height: var(--topbar-shell-actions-h);
  min-height: var(--topbar-shell-actions-h);
  max-height: var(--topbar-shell-actions-h);
}

.topbar-module-actions .ec-toolbar-for-shell .inv-mode-btn.inv-mode-btn-active {
  background: linear-gradient(135deg, #045a8f, #023661 55%, #012440);
  border-color: rgba(125, 211, 252, 0.9);
  color: #f8fafc;
  box-shadow: var(--bsuite-shell-tab-active-glow), 0 4px 18px rgba(2, 54, 97, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Cashflow in shell (layout toolbar unificato: vedi .app-header-ops.bsuite-shell-segment-toolbar). */
.topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-button {
  min-height: var(--topbar-shell-actions-h);
  padding: 6px 12px;
  border-radius: 12px;
  border: 2px solid rgba(129, 140, 248, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e0e7ff;
  box-shadow: none;
  font-size: 15px;
}

.topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-button:hover {
  background: rgba(37, 99, 235, 0.35);
  border-color: rgba(96, 165, 250, 0.75);
  color: #f8fafc;
}

.topbar-module-actions .app-header-ops .icon-button:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.95);
  outline-offset: 2px;
}

.topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-circle {
  width: auto;
  height: auto;
  min-width: 2.35rem;
  min-height: 2.35rem;
  border-radius: 0;
  background: transparent !important;
  color: inherit;
  font-size: 1.45rem;
  line-height: 1;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html[data-theme="light"] .topbar-module-actions .app-header-ops-label {
  color: rgba(51, 65, 85, 0.9);
}

html[data-theme="light"] .topbar-module-actions .icon-button {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .topbar-module-actions .icon-button:hover {
  background: #f1f5f9;
}

html[data-theme="light"] .topbar-module-actions .icon-circle {
  background: #f1f5f9;
  color: #0f172a;
}

html[data-theme="light"] .topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-button {
  background: #ffffff;
  color: #3730a3;
  border-color: #c7d2fe;
  box-shadow: none;
}

html[data-theme="light"] .topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-button:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: #312e81;
}

html[data-theme="light"] .topbar-module-actions .app-header-ops:not(.bsuite-shell-segment-toolbar) .icon-circle {
  background: transparent !important;
  color: inherit;
}

html[data-theme="light"] .topbar-module-actions .commesse-mode-btn {
  background: #ffffff;
  color: #3730a3;
  border-color: #c7d2fe;
}

html[data-theme="light"] .topbar-module-actions .commesse-mode-btn.is-on {
  background: linear-gradient(165deg, #ffffff 0%, #e0e7ff 55%, #c7d2fe 100%);
  border-color: #4f46e5;
  color: #1e1b4b;
  font-weight: 700;
  box-shadow: var(--bsuite-shell-tab-active-glow);
}

html[data-theme="light"] .topbar-module-actions .commesse-shell-toolbar-sep {
  background: rgba(148, 163, 184, 0.55);
}

html[data-theme="light"] .topbar-module-actions .inv-mode-btn {
  background: #ffffff;
  color: #3730a3;
  border-color: #c7d2fe;
}

html[data-theme="light"] .topbar-module-actions .inv-mode-btn.inv-mode-btn-active {
  background: linear-gradient(165deg, #ffffff 0%, #e0e7ff 55%, #c7d2fe 100%);
  border-color: #4f46e5;
  color: #1e1b4b;
  font-weight: 700;
  box-shadow: var(--bsuite-shell-tab-active-glow);
}

html[data-theme="light"] .topbar-module-actions .inv-mode-btn:hover:not(.inv-mode-btn-active) {
  background: #f1f5f9;
  border-color: #a5b4fc;
  color: #312e81;
}

html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(1) {
  background: #ecfeff;
  color: #0e7490;
  border-color: rgba(6, 182, 212, 0.55);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(2) {
  background: #fffbeb;
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.5);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(3) {
  background: #faf5ff;
  color: #6b21a8;
  border-color: rgba(168, 85, 247, 0.45);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(4) {
  background: #fff1f2;
  color: #be123c;
  border-color: rgba(244, 63, 94, 0.45);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(5) {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(16, 185, 129, 0.45);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(6) {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.5);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(7) {
  background: #fefce8;
  color: #a16207;
  border-color: rgba(234, 179, 8, 0.5);
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn:nth-of-type(8) {
  background: #f0f9ff;
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.5);
}

html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(1) {
  background: #cffafe;
  border-color: #06b6d4;
  color: #164e63;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(2) {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(3) {
  background: #f3e8ff;
  border-color: #a855f7;
  color: #581c87;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(4) {
  background: #ffe4e6;
  border-color: #f43f5e;
  color: #881337;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(5) {
  background: #d1fae5;
  border-color: #10b981;
  color: #064e3b;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(6) {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e3a8a;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(7) {
  background: #fef9c3;
  border-color: #eab308;
  color: #713f12;
}
html[data-theme="light"] .topbar-module-actions .inv-mode-toolbar > button.inv-mode-btn.inv-mode-btn-active:nth-of-type(8) {
  background: #e0f2fe;
  border-color: #0ea5e9;
  color: #0c4a6e;
}

html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(1) {
  background: #ecfeff;
  color: #0e7490;
  border-color: rgba(6, 182, 212, 0.55);
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(2) {
  background: #fffbeb;
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.5);
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(3) {
  background: #faf5ff;
  color: #6b21a8;
  border-color: rgba(168, 85, 247, 0.45);
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(4) {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(16, 185, 129, 0.45);
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn:nth-of-type(5) {
  background: #fff1f2;
  color: #be123c;
  border-color: rgba(244, 63, 94, 0.45);
}

html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(1) {
  background: #cffafe;
  border-color: #06b6d4;
  color: #164e63;
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(2) {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(3) {
  background: #f3e8ff;
  border-color: #a855f7;
  color: #581c87;
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(4) {
  background: #d1fae5;
  border-color: #10b981;
  color: #064e3b;
}
html[data-theme="light"] .topbar-module-actions .commesse-mode-toolbar > button.commesse-mode-btn.is-on:nth-of-type(5) {
  background: #ffe4e6;
  border-color: #f43f5e;
  color: #881337;
}

html[data-theme="light"] .topbar-module-actions .ec-toolbar-for-shell .inv-mode-btn {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(2, 54, 97, 0.45);
}

html[data-theme="light"] .topbar-module-actions .ec-toolbar-for-shell .inv-mode-btn.inv-mode-btn-active {
  background: linear-gradient(135deg, #023661, #045a8f);
  color: #f8fafc;
  border-color: rgba(2, 54, 97, 0.85);
  box-shadow: 0 4px 12px rgba(2, 54, 97, 0.25);
}

.topbar-company,
.topbar-user {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar-action-btn {
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.6));
  color: var(--text-strong);
  font-size: 12px;
  cursor: pointer;
}

.topbar-action-btn:hover {
  border-color: rgba(96, 165, 250, 0.95);
}

.topbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.topbar-pill {
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.6));
  color: var(--text-strong);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), transform var(--transition-fast);
}

.topbar-pill:hover {
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3), 0 12px 32px rgba(15, 23, 42, 0.9);
  transform: translateY(-0.5px);
}

.layout-content {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
}

/* Dashboard / assistenza: scroll interno; niente crescita dell’intera shell */
.layout-content > #dashboardSection.content-card,
.layout-content > #supportAccessShellSection {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Iframe moduli: riempie l’area sotto la topbar (min-height:0 abilita overflow nei figli) */
#moduleFrame.shell-module-frame {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  border: none;
  border-radius: 14px;
  background: transparent;
}

/* Overlay navigazione moduli (shell): feedback immediato su iframe lento o vuoto */
.shell-module-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
}

.shell-module-loading-overlay[hidden] {
  display: none !important;
}

.shell-module-loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(155deg, rgba(17, 28, 46, 0.96), rgba(20, 34, 56, 0.94));
  box-shadow: var(--shadow-soft);
}

.shell-module-loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.shell-module-loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.25);
  border-top-color: rgba(96, 165, 250, 0.95);
  animation: shell-module-loading-spin 0.75s linear infinite;
}

@keyframes shell-module-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell-module-loading-spinner {
    animation: none;
    border-top-color: rgba(96, 165, 250, 0.65);
  }
}

html[data-theme="light"] .shell-module-loading-overlay {
  background: rgba(248, 250, 252, 0.55);
}

html[data-theme="light"] .shell-module-loading-panel {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(203, 213, 225, 0.85);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .shell-module-loading-text {
  color: var(--text-muted);
}

.content-card {
  width: 100%;
  max-width: none;
  background: linear-gradient(155deg, rgba(17, 28, 46, 0.96), rgba(20, 34, 56, 0.94));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.38);
  padding: 20px 24px 22px;
  box-shadow: var(--shadow-soft);
}

.content-title {
  margin: 0 0 10px;
  font-size: 22px;
  color: var(--text-strong);
}

.content-text {
  margin: 6px 0;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.5;
}

.content-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.primary-button {
  border-radius: var(--radius-pill);
  border: none;
  padding: 8px 18px;
  background: linear-gradient(135deg, #023661, #045a8f);
  color: #f9fafb;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(2, 54, 97, 0.55);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    filter var(--transition-fast);
}

.primary-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 18px 40px rgba(2, 54, 97, 0.65);
}

@media (max-width: 900px) {
  .layout-root {
    flex-direction: column;
  }

  .layout-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
  }

  .sidebar-header {
    border-bottom: none;
    margin-bottom: 0;
    margin-right: 16px;
  }

  .sidebar-menu {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
  }

  .sidebar-section-group {
    flex-shrink: 0;
    margin-bottom: 0;
  }

  .sidebar-item {
    white-space: nowrap;
  }

  .layout-main {
    flex: 1;
  }

  .layout-topbar {
    padding: 8px 14px;
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
  }

  .layout-content {
    padding: 10px 12px 14px;
  }
}

/* Light theme (modern + subtle) */
html[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-topbar: rgba(255, 255, 255, 0.75);
  --border-subtle: rgba(226, 232, 240, 1);
  --text-main: #0f172a;
  --text-muted: #6b7280;
  --text-strong: #0b1220;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.1);
  --table-zebra-odd: rgba(2, 54, 97, 0.055);
  --table-zebra-even: rgba(2, 54, 97, 0.2);
  --table-row-border: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .topbar-active-company-name {
  color: var(--text-strong);
}

html[data-theme="light"] .topbar-context-box {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(248, 250, 252, 0.55);
}

html[data-theme="light"] .topbar-context-box tbody tr + tr .topbar-context-cell {
  border-top-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="light"] .topbar-context-label {
  color: var(--text-muted);
}

html[data-theme="light"] .topbar-context-value {
  color: var(--text-strong);
}

html[data-theme="light"] .topbar-context-value--user {
  color: rgba(51, 65, 85, 0.92);
}

html[data-theme="light"] body {
  background: #f8fafc;
  color: var(--text-main);
}

html[data-theme="light"] .layout-sidebar {
  background: #ffffff;
  border-right: 1px solid rgba(226, 232, 240, 1);
}

html[data-theme="light"] .sidebar-section-divider {
  background: rgba(148, 163, 184, 0.4);
}

html[data-theme="light"] .sidebar-section-label,
html[data-theme="light"] .topbar-label,
html[data-theme="light"] .theme-toggle-label {
  color: var(--text-muted);
}

html[data-theme="light"] .sidebar-item {
  color: var(--text-main);
}

html[data-theme="light"] .sidebar-item:hover:not(.active) {
  background: rgba(37, 99, 235, 0.1);
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.4);
  transform: translateY(-0.5px);
}

html[data-theme="light"] .sidebar-item.active {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.3), rgba(79, 70, 229, 0.2));
  color: var(--text-strong);
  border: 1px solid rgba(96, 165, 250, 0.55);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.14), inset 3px 0 0 rgba(37, 99, 235, 0.42);
}

html[data-theme="light"] .sidebar-item.active:hover {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.38), rgba(79, 70, 229, 0.28));
  border-color: rgba(59, 130, 246, 0.65);
  color: var(--text-strong);
}

html[data-theme="light"] .layout-topbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(226, 232, 240, 1);
  backdrop-filter: none;
}

html[data-theme="light"] .topbar-pill {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--text-strong);
}

html[data-theme="light"] .topbar-action-btn {
  background: linear-gradient(135deg, #ffffff, #f3f4f6);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: var(--text-strong);
}

html[data-theme="light"] .topbar-pill:hover {
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15), 0 12px 32px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .content-card {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--shadow-soft);
}

html[data-theme="light"] .content-title {
  color: var(--text-strong);
}

html[data-theme="light"] .content-text {
  color: #111827;
}

html[data-theme="light"] .primary-button {
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.25);
}

html[data-theme="light"] .sidebar-bottom {
  border-top: 1px solid rgba(148, 163, 184, 0.55);
}

html[data-theme="light"] .theme-slider {
  background: rgba(148, 163, 184, 0.45);
  border-color: rgba(148, 163, 184, 0.55);
}

html[data-theme="light"] .theme-switch input:checked + .theme-slider {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(37, 99, 235, 0.35);
}

.sidebar-active-company-logo-wrap {
  margin-bottom: 0;
}

.sidebar-active-company-logo {
  display: block;
  width: auto;
  height: 36px;
  max-width: 100%;
  object-fit: contain;
}

.hidden {
  display: none !important;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.sidebar-mobile-link {
  display: block;
  margin-bottom: 10px;
  padding: 8px 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
}

.sidebar-mobile-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.theme-toggle-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  transition: background 150ms ease-out, border-color 150ms ease-out;
}

.theme-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 2px;
  background: var(--text-strong);
  border-radius: 999px;
  transition: transform 150ms ease-out;
}

.theme-switch input:checked + .theme-slider {
  background: rgba(37, 99, 235, 0.35);
  border-color: rgba(37, 99, 235, 0.45);
}

.theme-switch input:checked + .theme-slider:before {
  transform: translateX(20px);
}

/* Build manifest (deploy) — discreto in topbar e login */
.build-badge {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(420px, 100%);
}

.login-page .build-badge {
  margin-top: 10px;
  text-align: center;
  justify-content: center;
  max-width: none;
}

.sidebar-logo-text .build-badge {
  text-align: left;
}

/* Licenza tenant — banner sotto topbar (no popup) */
.license-banner-host {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.license-banner {
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-main);
}

.license-banner__title {
  font-weight: 600;
  color: var(--text-strong);
}

.license-banner--info {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
}

.license-banner--warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}

.license-banner--danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
}

.license-banner--ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.sidebar-item.sidebar-item--license-disabled {
  opacity: 0.38;
  pointer-events: none;
}

/* Assistenza fornitore (shell cliente) */
#supportAccessShellSection {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 16px 24px;
}
.support-access-shell-inner {
  max-width: 960px;
  margin: 0 auto;
}
.support-shell-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.support-shell-hint--err {
  color: #fca5a5;
}
.support-shell-muted {
  color: var(--text-muted);
  font-size: 13px;
}
.support-shell-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.support-shell-block {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.support-shell-block h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--text-strong);
}
.support-shell-block p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}
.support-shell-table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.support-shell-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.support-shell-table th,
.support-shell-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.support-shell-actions-col {
  min-width: 200px;
}
.support-shell-inline-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.support-shell-dt-label {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.support-shell-dt {
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-main);
}
.support-shell-row-btn {
  align-self: flex-start;
}
.support-shell-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12px;
}
.support-shell-btn-secondary:hover {
  border-color: var(--accent);
}
.support-shell-form .form-row {
  margin-bottom: 10px;
}
.support-shell-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.support-shell-form textarea,
.support-shell-form input[type="text"] {
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--bsuite-border-field, var(--border-subtle));
  background: var(--bsuite-depth-field, var(--bg-surface));
  color: var(--text-main);
  font: inherit;
  box-shadow: var(--bsuite-shadow-field-inset, none);
}
.partner-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 14px;
  margin: 10px 0 12px;
  max-height: 280px;
  overflow: auto;
  padding: 4px 0;
}
.partner-module-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}
.partner-module-toggle input {
  margin-top: 3px;
}
.partner-support-panel {
  border: 1px solid var(--bs-border, #2a2f3a);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--bs-surface-2, #1e232e);
  font-size: 0.82rem;
  line-height: 1.45;
}
.partner-support-req {
  border-bottom: 1px solid var(--bs-border, #2a2f3a);
  padding: 0.5rem 0;
}
.partner-support-req:last-child {
  border-bottom: none;
}

/* Campi testuali: regole base in bsuite-ui-depth.css (shell + moduli che importano sheets). */

/* STEP 4+9 — zebra tabelle / elenchi tabellari (iframe moduli inclusi) */
table thead th {
  border-bottom: 2px solid var(--table-row-border);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
table tbody td {
  border-bottom: 1px solid var(--table-row-border);
}
table tbody tr:nth-child(odd) {
  background-color: var(--table-zebra-odd);
}
table tbody tr:nth-child(even) {
  background-color: var(--table-zebra-even);
}
table tbody tr:hover {
  background-color: var(--table-row-hover) !important;
}
table tbody tr.is-active,
table tbody tr.is-selected,
table tbody tr.row-selected,
table tbody tr[data-selected="true"] {
  background-color: var(--table-row-selected) !important;
  box-shadow: inset 3px 0 0 0 var(--accent);
}

/* Avvisi shell */
.topbar-reminders-wrap {
  position: relative;
  margin-right: 0.35rem;
}

.topbar-reminders-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-reminders-btn:hover {
  border-color: var(--accent);
}
.topbar-reminders-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.topbar-reminders-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(360px, 92vw);
  max-height: 70vh;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  z-index: 80;
  padding: 0.5rem 0.65rem 0.75rem;
}
.topbar-reminders-popover-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.topbar-reminders-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.topbar-reminders-item {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(118, 130, 142, 0.35);
  font-size: 0.82rem;
}
.topbar-reminders-item--unread {
  border-left: 3px solid var(--color-accent-yellow);
  padding-left: 0.5rem;
}

/* Letti di recente (~7 gg): ancora ben visibili; poi attenuati per non intasare la lista */
.topbar-reminders-item--read-recent {
  border-left: 3px solid rgba(34, 197, 94, 0.45);
  padding-left: 0.5rem;
  opacity: 0.95;
}

.topbar-reminders-item-title {
  font-weight: 600;
}
.topbar-reminders-item-body {
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.topbar-reminders-item-due {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.topbar-rem-type {
  font-size: 0.68rem;
  opacity: 0.75;
  font-weight: 400;
}

.topbar-reminders-item-actions {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  align-items: center;
}

.topbar-reminders-open-commessa {
  font-size: 0.75rem;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(37, 99, 235, 0.5);
  background: rgba(37, 99, 235, 0.14);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 600;
}

html[data-theme="light"] .topbar-reminders-open-commessa {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(219, 234, 254, 0.9);
}

.topbar-reminders-markread {
  margin-top: 0;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  cursor: pointer;
}

.topbar-reminders-markread.topbar-reminders-markunread {
  font-size: 0.68rem;
  padding: 0.14rem 0.36rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  opacity: 0.7;
  border-color: rgba(148, 163, 184, 0.28);
  background: transparent;
  box-shadow: none;
}

.topbar-reminders-markread.topbar-reminders-markunread:hover {
  opacity: 0.92;
  color: var(--text-muted);
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.08);
}

html[data-theme="dark"] .topbar-reminders-markread.topbar-reminders-markunread {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.22);
  opacity: 0.65;
}

html[data-theme="dark"] .topbar-reminders-markread.topbar-reminders-markunread:hover {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(148, 163, 184, 0.1);
  opacity: 0.9;
}
.topbar-reminders-empty {
  margin: 0.35rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.topbar-reminder-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  max-width: 320px;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  font-size: 0.88rem;
  z-index: 90;
}

/* --- Dashboard shell personalizzata --- */
.dashboard-shell-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.dashboard-shell-title {
  margin: 0;
}

.dashboard-shell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.dashboard-shell-intro {
  margin-top: 0;
  margin-bottom: 1rem;
}

.dashboard-section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

button.dashboard-section-tab {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
  color: var(--text-main);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

button.dashboard-section-tab:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(37, 99, 235, 0.08);
}

button.dashboard-section-tab[aria-pressed="true"] {
  border-color: rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.16);
  color: var(--text-strong);
}

.dashboard-commesse-favorites {
  margin: 0 0 1rem;
}

.dashboard-commesse-favorites-inner {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: 0.65rem 0.85rem;
}

.dashboard-commesse-favorites-title {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-strong);
}

.dashboard-commesse-favorites-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.dashboard-commessa-favorite-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
  cursor: pointer;
  text-align: left;
  max-width: 260px;
  font: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.dashboard-commessa-favorite-chip:hover {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.dashboard-commessa-favorite-chip-code {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dashboard-commessa-favorite-chip-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dashboard-commesse-favorites-empty,
.dashboard-commesse-favorites-loading {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dashboard-widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.dashboard-widget-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: 0;
  min-height: 120px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.dashboard-widget-card--live {
  grid-column: span 1;
  min-height: 200px;
}

@media (min-width: 900px) {
  .dashboard-widget-card--live.dashboard-widget-card--wide {
    grid-column: span 2;
  }
}

.dashboard-widget-card-inner {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
}

.dashboard-widget-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.01em;
}

.dashboard-widget-desc,
.dashboard-widget-body {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.dashboard-widget-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.dashboard-widget-action {
  align-self: flex-start;
}

.dashboard-live-body {
  flex: 1;
  min-height: 4rem;
  max-height: 280px;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
}

.dashboard-live-loading,
.dashboard-live-error,
.dashboard-live-empty {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dashboard-live-error {
  color: #b91c1c;
}

html[data-theme="dark"] .dashboard-live-error,
html:not([data-theme="light"]) .dashboard-live-error {
  color: #fca5a5;
}

.dashboard-live-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.dashboard-live-table th,
.dashboard-live-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.dashboard-live-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
  position: sticky;
  top: 0;
  z-index: 1;
}

.dashboard-live-table tr:hover td {
  background: rgba(37, 99, 235, 0.06);
}

.dashboard-live-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-live-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--accent, #2563eb);
  cursor: pointer;
  text-decoration: underline;
  text-align: left;
}

.dashboard-empty-hint {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dashboard-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dashboard-modal[hidden] {
  display: none !important;
}

.dashboard-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
}

.dashboard-modal-panel {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}

.dashboard-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.dashboard-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.dashboard-modal-body {
  padding: 1rem 1.1rem;
  flex: 1;
  overflow: auto;
}

.dashboard-modal-footer {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.dashboard-modal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.dashboard-modal-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dashboard-modal-sep {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 0.85rem 0;
}

.dashboard-modal-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.65rem;
}

.dashboard-modal-subtitle {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.9rem;
}

.dashboard-modal-widgets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dashboard-modal-widget-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, 0.08);
  font-size: 0.82rem;
}

.dashboard-modal-widget-row input,
.dashboard-modal-widget-row textarea,
.dashboard-modal-widget-row select {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
  color: var(--text-main);
  max-width: 100%;
}

.dashboard-modal-widget-row textarea {
  min-width: 180px;
  flex: 1 1 200px;
}

/* Login azienda: QR 2FA ingrandito, SVG scalato nel contenitore */
#companyTwofaQr svg {
  display: block;
  width: 100%;
  height: auto;
}
