/* ==========================================================================
   core.css — Design system base + shell layout
   Loaded after bootstrap.min.css. Only overrides / extends what Bootstrap
   does not provide. All custom classes are prefixed with "core-".
   ========================================================================== */

/* ==========================================================================
   SECTION A — CSS Variables (design tokens)
   ========================================================================== */


/* Density — compact */
.density-compact {
  font-size: 13px;
}

/* Density — comfortable */

/* Dark mode — base variable overrides only (no full dark theme yet) */
@media (prefers-color-scheme: dark) {
  :root {
    /* ── Core design tokens ─────────────────────────────────────── */

    /* ── Bootstrap 5 global overrides ───────────────────────────── */
    --bs-body-bg: var(--tema-colore-blu-tenue-11);
    --bs-body-bg-rgb: 21, 23, 34;
    --bs-body-color: var(--tema-colore-azzurro-96);
    --bs-body-color-rgb: 241, 245, 249;
    --bs-emphasis-color: var(--tema-colore-azzurro-96);
    --bs-emphasis-color-rgb: 241, 245, 249;
    --bs-secondary-color: var(--tema-colore-azzurro-96-a75);
    --bs-secondary-color-rgb: 241, 245, 249;
    --bs-secondary-bg: var(--tema-colore-blu-tenue-21);
    --bs-secondary-bg-rgb: 42, 43, 64;
    --bs-tertiary-color: var(--tema-colore-azzurro-96-a50);
    --bs-tertiary-color-rgb: 241, 245, 249;
    --bs-tertiary-bg: var(--tema-colore-blu-tenue-15);
    --bs-tertiary-bg-rgb: 30, 33, 48;

    /* Borders */
    --bs-border-color: var(--tema-colore-azzurro-tenue-27);
    --bs-border-color-translucent: var(--tema-colore-bianco-a12);

    /* Links */
    --bs-link-color: var(--tema-colore-azzurro-vivo-68);
    --bs-link-color-rgb: 96, 165, 250;
    --bs-link-hover-color: var(--tema-colore-azzurro-vivo-78);
    --bs-link-hover-color-rgb: 147, 197, 253;

    /* Colour-scale RGB values used by utility classes */
    --bs-white-rgb: 30, 33, 48;
    --bs-light-rgb: 30, 33, 48;
    --bs-dark-rgb: 241, 245, 249;

    /* Form controls */
    --bs-form-control-bg: var(--tema-colore-blu-16);

    /* Semantic alert / badge overrides */
    --bs-danger-bg-subtle: var(--tema-colore-rosso-vivo-15);
    --bs-danger-text-emphasis: var(--tema-colore-rosso-vivo-82);
    --bs-warning-bg-subtle: var(--tema-colore-arancio-vivo-14);
    --bs-warning-text-emphasis: var(--tema-colore-giallo-vivo-56);
  }

  /* ── Component-level overrides ──────────────────────────────── */



  /* Cards */
  .card,
  .core-card {
    --bs-card-bg: var(--tema-colore-blu-16);
    --bs-card-color: var(--tema-colore-azzurro-96);
    --bs-card-border-color: var(--tema-colore-blu-tenue-23);
    --bs-card-cap-bg: var(--tema-colore-bianco-a03);
    --bs-card-cap-color: var(--tema-colore-azzurro-tenue-65);
  }

  .card-header {
    border-bottom-color: var(--tema-colore-blu-tenue-23);
  }

  .card-footer {
    border-top-color: var(--tema-colore-blu-tenue-23);
  }

  /* Tables */
  .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--tema-colore-azzurro-91);
    --bs-table-border-color: var(--tema-colore-blu-tenue-23);
    --bs-table-striped-bg: var(--tema-colore-bianco-a02);
    --bs-table-striped-color: var(--tema-colore-azzurro-91);
    --bs-table-hover-bg: var(--tema-colore-bianco-a05);
    --bs-table-hover-color: var(--tema-colore-azzurro-96);
    --bs-table-active-bg: var(--tema-colore-bianco-a08);
    --bs-table-active-color: var(--tema-colore-azzurro-96);
  }

  /* List groups */
  .list-group {
    --bs-list-group-bg: var(--tema-colore-blu-16);
    --bs-list-group-color: var(--tema-colore-azzurro-91);
    --bs-list-group-border-color: var(--tema-colore-blu-tenue-23);
    --bs-list-group-action-hover-bg: var(--tema-colore-blu-tenue-21);
    --bs-list-group-action-hover-color: var(--tema-colore-azzurro-96);
    --bs-list-group-action-active-bg: var(--tema-colore-azzurro-tenue-27);
    --bs-list-group-action-active-color: var(--tema-colore-azzurro-96);
    --bs-list-group-active-bg: var(--tema-marchio-primario);
    --bs-list-group-active-border-color: var(--tema-marchio-primario);
  }

  /* Modals */
  .modal {
    --bs-modal-bg: var(--tema-colore-blu-16);
    --bs-modal-color: var(--tema-colore-azzurro-91);
    --bs-modal-border-color: var(--tema-colore-blu-tenue-23);
    --bs-modal-header-border-color: var(--tema-colore-blu-tenue-23);
    --bs-modal-footer-border-color: var(--tema-colore-blu-tenue-23);
  }

  /* Dropdowns */
  .dropdown-menu {
    --bs-dropdown-bg: var(--tema-colore-blu-16);
    --bs-dropdown-color: var(--tema-colore-azzurro-91);
    --bs-dropdown-border-color: var(--tema-colore-blu-tenue-23);
    --bs-dropdown-link-color: var(--tema-colore-azzurro-91);
    --bs-dropdown-link-hover-bg: var(--tema-colore-blu-tenue-21);
    --bs-dropdown-link-hover-color: var(--tema-colore-azzurro-96);
    --bs-dropdown-link-active-bg: var(--tema-marchio-primario);
    --bs-dropdown-link-active-color: var(--tema-struttura-colore);
    --bs-dropdown-divider-bg: var(--tema-colore-blu-tenue-23);
  }

  /* Form controls */
  .form-control,
  .form-select {
    --bs-body-bg: var(--tema-colore-blu-16);
    color: var(--tema-colore-azzurro-91);
    background-color: var(--tema-colore-blu-16);
    border-color: var(--tema-colore-azzurro-tenue-27);
  }

  .form-control:focus,
  .form-select:focus {
    background-color: var(--tema-colore-blu-16);
    color: var(--tema-colore-azzurro-96);
    border-color: var(--tema-marchio-primario);
    box-shadow: 0 0 0 0.25rem var(--tema-marchio-primario-fuoco-anello);
  }

  .form-control::placeholder {
    color: var(--tema-colore-azzurro-tenue-47);
  }

  .form-check-input {
    background-color: var(--tema-colore-blu-16);
    border-color: var(--tema-colore-azzurro-tenue-35);
  }

  .form-check-input:checked {
    background-color: var(--tema-marchio-primario);
    border-color: var(--tema-marchio-primario);
  }

  .form-label,
  .form-text {
    color: var(--tema-colore-azzurro-tenue-65);
  }

  .input-group-text {
    background-color: var(--tema-colore-blu-tenue-21);
    color: var(--tema-colore-azzurro-tenue-65);
    border-color: var(--tema-colore-azzurro-tenue-27);
  }

  /* Accordion */
  .accordion {
    --bs-accordion-bg: var(--tema-colore-blu-16);
    --bs-accordion-color: var(--tema-colore-azzurro-91);
    --bs-accordion-border-color: var(--tema-colore-blu-tenue-23);
    --bs-accordion-btn-color: var(--tema-colore-azzurro-91);
    --bs-accordion-btn-bg: var(--tema-colore-blu-16);
    --bs-accordion-active-bg: var(--tema-colore-blu-tenue-21);
    --bs-accordion-active-color: var(--tema-colore-azzurro-96);
  }

  /* Nav tabs / pills */
  .nav-tabs {
    --bs-nav-tabs-border-color: var(--tema-colore-blu-tenue-23);
    --bs-nav-tabs-link-active-bg: var(--tema-colore-blu-16);
    --bs-nav-tabs-link-active-color: var(--tema-colore-azzurro-96);
    --bs-nav-tabs-link-active-border-color: var(--tema-colore-blu-tenue-23) var(--tema-colore-blu-tenue-23) var(--tema-colore-blu-16);
  }

  .nav-link {
    color: var(--tema-colore-azzurro-tenue-65);
  }

  .nav-link:hover,
  .nav-link:focus {
    color: var(--tema-colore-azzurro-96);
  }

  /* Breadcrumbs */
  .breadcrumb {
    --bs-breadcrumb-divider-color: var(--tema-colore-azzurro-tenue-47);
    --bs-breadcrumb-item-active-color: var(--tema-colore-azzurro-tenue-65);
  }

  /* Pagination */
  .pagination {
    --bs-pagination-bg: var(--tema-colore-blu-16);
    --bs-pagination-color: var(--tema-colore-azzurro-tenue-65);
    --bs-pagination-border-color: var(--tema-colore-blu-tenue-23);
    --bs-pagination-hover-bg: var(--tema-colore-blu-tenue-21);
    --bs-pagination-hover-color: var(--tema-colore-azzurro-96);
    --bs-pagination-hover-border-color: var(--tema-colore-azzurro-tenue-27);
    --bs-pagination-disabled-bg: var(--tema-colore-blu-tenue-11);
    --bs-pagination-disabled-color: var(--tema-colore-azzurro-tenue-35);
    --bs-pagination-active-bg: var(--tema-marchio-primario);
    --bs-pagination-active-border-color: var(--tema-marchio-primario);
  }

  /* Alerts */
  .alert-warning {
    --bs-alert-bg: var(--tema-colore-arancio-vivo-14);
    --bs-alert-color: var(--tema-colore-giallo-vivo-56);
    --bs-alert-border-color: var(--tema-colore-arancio-vivo-31);
  }

  .alert-danger {
    --bs-alert-bg: var(--tema-colore-rosso-vivo-15);
    --bs-alert-color: var(--tema-colore-rosso-vivo-82);
    --bs-alert-border-color: var(--tema-colore-rosso-vivo-35);
  }

  .alert-info {
    --bs-alert-bg: var(--tema-colore-azzurro-vivo-16);
    --bs-alert-color: var(--tema-colore-ciano-vivo-74);
    --bs-alert-border-color: var(--tema-colore-azzurro-vivo-23);
  }

  .alert-success {
    --bs-alert-bg: var(--tema-colore-verde-vivo-10);
    --bs-alert-color: var(--tema-colore-verde-vivo-73);
    --bs-alert-border-color: var(--tema-colore-verde-20);
  }

  /* Badges — keep bg visible on dark backgrounds */
  .badge.bg-light {
    color: var(--tema-colore-azzurro-91) !important;
  }

  /* Progress bars */
  .progress {
    --bs-progress-bg: var(--tema-colore-blu-tenue-21);
  }

  /* Tooltips and popovers */
  .tooltip {
    --bs-tooltip-bg: var(--tema-colore-blu-tenue-21);
    --bs-tooltip-color: var(--tema-colore-azzurro-96);
  }

  .popover {
    --bs-popover-bg: var(--tema-colore-blu-16);
    --bs-popover-border-color: var(--tema-colore-blu-tenue-23);
    --bs-popover-body-color: var(--tema-colore-azzurro-91);
    --bs-popover-header-bg: var(--tema-colore-blu-tenue-21);
    --bs-popover-header-color: var(--tema-colore-azzurro-96);
  }

  /* Close button */

  /* ── Utility class taming ───────────────────────────────────── */

  .text-muted {
    color: var(--tema-colore-azzurro-tenue-47) !important;
  }

  .border-bottom,
  .border-top,
  .border-start,
  .border-end,
  .border {
    border-color: var(--tema-colore-azzurro-tenue-27) !important;
  }

  hr {
    border-color: var(--tema-colore-azzurro-tenue-27);
    opacity: 0.4;
  }

  /* ── Shell-specific ─────────────────────────────────────────── */

  .core-nav-link:hover,
  .core-nav-link:focus {
    background-color: var(--tema-colore-bianco-a06);
  }

  .core-card .card-body,
  .core-card .card-header,
  .core-card .card-footer {
    background-color: inherit;
  }

  /* BRAND-3 — the hardcoded `.core-auth-body { background-color: #151722 }` that
     used to sit here was removed. It restated the dark value of
     --tema-contenuto-sfondo literally, so it changed nothing (the light rule already
     resolves that token), but it OVERRODE anything configured in ops for the
     entry pages: the colour chosen by an operator would have been ignored for
     every visitor in dark mode. One colour wins in both schemes, by design. */
}


/* Typography base */
body {
  font-family: var(--tema-font-famiglia);
  font-size: var(--tema-font-dimensione-base);
  font-weight: var(--tema-font-peso-normale);
  color: var(--tema-testo-primario);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ==========================================================================
   SECTION B — Shell layout
   ========================================================================== */

#core-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Fixed top header */
#core-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tema-testata-altezza);
  background: var(--tema-testata-sfondo);
  border-bottom: 1px solid var(--tema-testata-bordo);
  z-index: 1000;
  padding: 0 var(--tema-spazio-md);
}

/* Body row: sits below fixed header */
.core-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  padding-top: var(--tema-testata-altezza);
}

/* Fixed left sidebar */
#core-sidebar {
  position: fixed;
  top: var(--tema-testata-altezza);
  left: 0;
  bottom: 0;
  width: var(--tema-barra-larghezza);
  background: var(--tema-barra-sfondo);
  border-right: 1px solid var(--tema-bordo-tenue);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--tema-spazio-sm) 0;
  z-index: 900;
  transition: left 0.25s ease, width 0.25s ease;
}

/* Main content area */
#core-main {
  margin-left: var(--tema-barra-larghezza);
  flex: 1;
  padding: var(--tema-densita-pagina-riquadro-y) var(--tema-densita-pagina-riquadro-x);
  min-width: 0;
}

/* Content inner container */
#core-content {
  max-width: var(--tema-contenuto-larghezza-massima);
}

/* Footer — margin-left matches #core-main so the fixed sidebar doesn't overlap it */
#core-footer {
  background: var(--tema-piede-sfondo);
  border-top: 1px solid var(--tema-bordo-tenue);
  padding: 8px 20px;
  height: var(--tema-piede-altezza);
  margin-left: var(--tema-barra-larghezza);
}


/* ==========================================================================
   SECTION C — Header styling
   ========================================================================== */

.core-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: var(--tema-spazio-md);
}

/* Brand / logo area */
.core-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

/*
 * Header logo sizing (BRAND-4). The slider is a percentage of a STANDARD height
 * in the header, identical for every asset — NOT of the file's natural size.
 *
 * Why not the previous `max-height: calc(96px * scale/100)`: max-height caps and
 * never enlarges, so for any logo naturally shorter than 48px the cap never bit
 * and the whole 50-200 range rendered the same pixels (BRAND-2c). `height` with
 * `width: auto` sets the size instead of bounding it, so every step of the
 * slider moves the rendering for every asset, tall or short.
 *
 * The two numbers are derived, not chosen: the slot is what the 52px header can
 * host without the logo leaving it, and the base is HALF the slot so that 200%
 * exactly fills it. That is what keeps the guard from ever biting BEFORE the top
 * of the range — which would recreate the dead region we just removed.
 */
.core-brand-logo {
  height: calc(var(--tema-logo-base) * var(--tema-logo-scala, 100) / 100);
  /* Hard guard: whatever the scale and whatever the asset, the logo can never
     leave the header. Reached exactly at 200%, never before. */
  max-height: var(--tema-logo-alloggio);
  width: auto;
  object-fit: contain;
  display: block;
}

/*
 * Header-slot preview (BRAND-4) — used by the ops Branding page and by the tenant
 * Organizzazione page. It reproduces the header slot exactly (same height, same
 * background, same .core-brand-logo rule), so what the operator sees while
 * dragging is what the shell will render. Never a second sizing mechanism.
 */
.core-logo-slot-preview {
  display: flex;
  align-items: center;
  height: var(--tema-testata-altezza);
  padding: 0 var(--tema-spazio-md);
  background: var(--tema-testata-sfondo);
  border: 1px solid var(--tema-testata-bordo);
  border-radius: 6px;
  overflow: hidden;
}

/* Tenant switcher */
.core-tenant-switcher {
  border: 1px solid var(--tema-bordo-chiaro);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 0;
  max-width: 220px;
}


.core-tenant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* RP-RAPPORTI-3 (A3) — il selettore è un <details>: si apre senza JavaScript. */
.core-tenant-switcher {
  position: relative;
}

.core-tenant-switcher > summary {
  list-style: none;
}

/* «I miei mondi» (C2-bis): il menu si apre verso sinistra, perché sta più a destra. */
.core-mondi .core-tenant-menu {
  left: auto;
  right: 0;
}

.core-tenant-switcher > summary::-webkit-details-marker {
  display: none;
}

.core-tenant-menu {
  position: absolute;
  top: calc(100% + var(--tema-spazio-xs));
  left: 0;
  z-index: 1050;
  min-width: 240px;
  padding: var(--tema-spazio-xs);
  background: var(--tema-testata-sfondo);
  border: 1px solid var(--tema-bordo-chiaro);
  border-radius: 6px;
  box-shadow: var(--bs-box-shadow);
}

.core-tenant-option {
  display: block;
  width: 100%;
  padding: var(--tema-spazio-xs) var(--tema-spazio-sm);
  background: none;
  border: none;
  border-radius: 4px;
  text-align: left;
  font-size: var(--tema-font-dimensione-piccola);
  color: inherit;
  cursor: pointer;
}

.core-tenant-option:hover:not([disabled]),
.core-tenant-option:focus-visible {
  background: var(--tema-bordo-chiaro);
}

.core-tenant-option[aria-current="true"] {
  font-weight: 600;
  cursor: default;
}

/* Right-side actions cluster */
.core-header-actions {
  display: flex;
  align-items: center;
  gap: var(--tema-spazio-md);
  flex-shrink: 0;
  margin-left: auto;
}

/* Icon button — square, circular hover */



/* Primary action buttons — outline amber, neutral text (#6c6c6c 4.98:1 on white) */




.text-primary {
  color: var(--tema-marchio-primario-testo) !important;
}

/* Nav tabs — amber active indicator */
.nav-tabs .nav-link.active {
  color: var(--tema-marchio-primario-testo);
  border-bottom-color: var(--tema-marchio-primario);
}

.nav-tabs .nav-link:hover {
  color: var(--tema-marchio-primario-testo);
}

.nav-tabs .nav-link:focus-visible {
  box-shadow: 0 0 0 0.25rem var(--tema-marchio-primario-fuoco-anello);
}

/* Pagination — amber active page */
.pagination .page-item.active .page-link {
  background-color: var(--tema-marchio-primario);
  border-color: var(--tema-marchio-primario);
  color: var(--tema-struttura-colore);
}

.pagination .page-link:focus {
  box-shadow: 0 0 0 0.25rem var(--tema-marchio-primario-fuoco-anello);
}

.pagination .page-link {
  color: var(--tema-marchio-primario-testo);
}

/* Links — amber text (WCAG AA on white) */
a {
  color: var(--tema-marchio-primario-testo);
}

a:hover {
  color: var(--tema-marchio-primario-hover);
}

/* Form focus — amber ring */
.form-control:focus,
.form-select:focus {
  border-color: var(--tema-marchio-primario);
  box-shadow: 0 0 0 0.25rem var(--tema-marchio-primario-fuoco-anello);
}

/* Form check — amber checked state */
.form-check-input:checked {
  background-color: var(--tema-marchio-primario);
  border-color: var(--tema-marchio-primario);
}

.form-check-input:focus {
  border-color: var(--tema-marchio-primario);
  box-shadow: 0 0 0 0.25rem var(--tema-marchio-primario-fuoco-anello);
}

/* Notification badge */
.core-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background-color: var(--bs-danger, var(--tema-colore-rosso-vivo-54));
  color: var(--tema-colore-bianco);
  font-size: 9px;
  font-weight: 600;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* User menu */
.core-user-menu {
  display: flex;
  align-items: center;
}


.core-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bs-info, var(--tema-colore-ciano-vivo-50));
  color: var(--tema-colore-bianco);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1;
}

.core-user-name {
  font-size: 13px;
  font-weight: 500;
}


/* ==========================================================================
   SECTION D — Sidebar styling
   ========================================================================== */

.core-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  padding: 0 var(--tema-spazio-sm);
}

.core-nav-item {
  margin: 2px 0;
}

.core-nav-link {
  display: flex;
  align-items: center;
  gap: var(--tema-spazio-sm);
  padding: var(--tema-densita-navigazione-riquadro-y) var(--tema-densita-navigazione-riquadro-x);
  border-radius: 6px;
  border-left: 3px solid transparent;
  color: var(--tema-testo-secondario);
  text-decoration: none;
  font-size: var(--tema-densita-navigazione-font-dimensione);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.core-nav-link:hover {
  background-color: var(--tema-colore-nero-a04);
  color: var(--tema-testo-primario);
}

.core-nav-link.active {
  background-color: var(--tema-barra-attivo-sfondo);
  color: var(--tema-barra-attivo-colore);
  font-weight: 500;
  border-left-color: var(--tema-marchio-accento);
}

.core-nav-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.core-nav-link .bi {
  font-size: 16px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.core-nav-divider {
  border: none;
  border-top: 1px solid var(--tema-bordo-tenue);
  margin: 8px 12px;
}

.core-nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tema-testo-terziario);
  font-weight: var(--tema-font-peso-semigrassetto);
  padding: 0 var(--tema-densita-navigazione-riquadro-x);
  margin: var(--tema-spazio-xs) 0 var(--tema-spazio-sm);
  display: block;
}

/* Push bottom links to end of sidebar */
.core-nav-bottom {
  margin-top: auto;
}


/* ---------- Chat-mode sidebar ---------- */

#chat-sidebar-panel {
  display: none;
}

body.chat-mode #core-sidebar .core-nav-list:not(.core-nav-bottom),
body.chat-mode #core-sidebar .core-nav-divider:not(.core-nav-divider--bottom),
body.chat-mode #core-sidebar .core-nav-section-label {
  display: none;
}

/* Editorial sidebar wordmark (F1a) — hidden by default on EVERY page (this rule
 * lives in core.css so it applies where chat.css is not loaded, e.g. dashboard);
 * chat.css reveals + styles it only in body.chat-mode. */
.chat-sidebar-wordmark {
  display: none;
}

body.chat-mode #chat-sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0 var(--tema-spazio-sm);
}

body.chat-mode #chat-sidebar-panel[hidden] {
  display: flex;
}


/* ---------- Module-specific sidebar (registry-driven) ---------- */

/* Container injected by base.html when UI_REGISTRY has a sidebar_template
   for the current module.  The standard nav lists are NOT rendered when
   this panel is active — server-side switch, not CSS toggle. */

.core-module-sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0 var(--tema-spazio-sm);
}

.core-module-sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--tema-spazio-sm);
  padding: var(--tema-spazio-md) var(--tema-spazio-sm) var(--tema-spazio-sm);
  font-weight: var(--tema-font-peso-semigrassetto);
  font-size: 0.95rem;
  color: var(--tema-testo-primario);
}

.core-module-sidebar-header i {
  font-size: 1.1rem;
}

.core-module-sidebar-back {
  display: flex;
  align-items: center;
  gap: var(--tema-spazio-sm);
  padding: var(--tema-spazio-sm);
  border-radius: var(--tema-raggio-sm, 4px);
  color: var(--tema-testo-secondario);
  text-decoration: none;
  font-size: 0.875rem;
}

.core-module-sidebar-back:hover {
  background-color: var(--tema-colore-nero-a04);
  color: var(--tema-testo-primario);
}

.core-module-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.core-module-sidebar-list .core-nav-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.core-module-sidebar-divider {
  margin: var(--tema-spazio-sm) 0;
  border: 0;
  border-top: 1px solid var(--tema-bordo-tenue);
}

.core-module-sidebar-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tema-testo-terziario);
  font-weight: var(--tema-font-peso-semigrassetto);
  padding: var(--tema-spazio-sm) var(--tema-spazio-sm) 4px;
  margin: 0;
}


/* ==========================================================================
   SECTION E — Content area patterns
   ========================================================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--tema-densita-sezione-spazio);
  flex-wrap: wrap;
  gap: var(--tema-spazio-md);
}

.page-header h1,
.page-header .page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: var(--tema-font-peso-semigrassetto);
  color: var(--tema-testo-primario);
}

/* KPI grid — 2 columns (fits inside col-lg-8), 1 on mobile */
.core-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--tema-spazio-lg);
  margin-bottom: var(--tema-densita-sezione-spazio);
}

/* KPI card — full-width spanning both grid columns */
.core-kpi-card--wide {
  grid-column: 1 / -1;
}

/* KPI text value — for non-numeric values (e.g. tenant name) */
.core-kpi-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--tema-testo-primario);
}

/* KPI number — large bold value */
.core-kpi-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tema-testo-primario);
}

/* KPI label — secondary text below the number */
.core-kpi-label {
  font-size: var(--tema-font-dimensione-piccola);
  color: var(--tema-testo-secondario);
}

/* Card icon colour variants */
.core-card-icon--primary {
  background: var(--tema-colore-arancio-vivo-50-a10-2);
  color: var(--tema-colore-arancio-vivo-44);
}

.core-card-icon--success {
  background: var(--tema-colore-petrolio-vivo-39-a10);
  color: var(--tema-colore-petrolio-vivo-30);
}

.core-card-icon--warning {
  background: var(--tema-colore-arancio-vivo-50-a10-2);
  color: var(--tema-colore-arancio-vivo-44);
}

.core-card-icon--info {
  background: var(--tema-colore-ciano-vivo-48-a10);
  color: var(--tema-colore-azzurro-vivo-39);
}

/* Card icon — accent variant (amber) */
.core-card-icon--accent {
  background: var(--tema-colore-arancio-vivo-50-a10-2);
  color: var(--tema-colore-arancio-vivo-44);
}

/* KPI card accent border-left */
.core-card--accent {
  border-left: 3px solid var(--tema-marchio-accento);
}

/* Event icon in activity log */
.core-event-icon {
  color: var(--tema-testo-terziario);
  font-size: 14px;
  flex-shrink: 0;
}

/* Activity widget */

.core-activity-widget .list-group-item {
  padding: var(--tema-spazio-sm) var(--tema-spazio-md);
  font-size: var(--tema-font-dimensione-piccola);
}

/* Card body — 24px internal padding */
.core-card .card-body {
  padding: var(--tema-spazio-lg);
}

/* Breadcrumb refinements */
.breadcrumb {
  font-size: var(--tema-font-dimensione-piccola);
  margin-bottom: var(--tema-spazio-md);
}

.breadcrumb-item a {
  color: var(--tema-testo-terziario);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--tema-marchio-primario);
}

.breadcrumb-item.active {
  color: var(--tema-testo-secondario);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--tema-bordo-chiaro);
}

/* Accent button — outline amber, same pattern as .btn-primary */



/* Quick links grid */
.core-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tema-spazio-sm);
}

/* Placeholder patterns — minimal styles, detailed theming per-page */

.core-empty-state {
  text-align: center;
  padding: var(--tema-spazio-xl) var(--tema-spazio-lg);
  color: var(--tema-testo-secondario);
}

.core-empty-state .core-empty-icon {
  font-size: 48px;
  margin-bottom: var(--tema-spazio-md);
  opacity: 0.4;
}

/* Card pattern */
.core-card {
  background: var(--tema-colore-bianco);
  border: none;
  border-radius: var(--tema-card-raggio);
  box-shadow: var(--tema-card-ombra);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.core-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--tema-card-ombra-hover);
}

.core-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tema-card-icona-sfondo);
  color: var(--tema-marchio-primario);
  font-size: 20px;
  flex-shrink: 0;
}

/* Table pattern */
.core-table {
  width: 100%;
  border-collapse: collapse;
}

.core-table thead th {
  font-weight: var(--tema-font-peso-semigrassetto);
  font-size: var(--tema-font-dimensione-piccola);
  color: var(--tema-tabella-testata-colore);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: var(--tema-spazio-sm) var(--tema-spazio-md);
  border-bottom: 1px solid var(--tema-bordo-chiaro);
  text-align: left;
}

.core-table tbody td {
  padding: var(--tema-spazio-sm) var(--tema-spazio-md);
  min-height: var(--tema-tabella-riga-minimo-altezza);
  vertical-align: middle;
  border-bottom: 1px solid var(--tema-bordo-tenue);
}

.core-table tbody tr {
  transition: background-color 0.1s ease;
}

.core-table tbody tr:nth-child(even) {
  background-color: var(--tema-tabella-riga-alterna-sfondo);
}

.core-table tbody tr:hover {
  background-color: var(--tema-colore-arancio-vivo-50-a03);
}

.core-table-link {
  color: var(--tema-struttura-colore);
  text-decoration: none;
  font-weight: var(--tema-font-peso-semigrassetto);
}

.core-table-link:hover {
  color: var(--tema-struttura-colore);
  text-decoration: underline;
  text-decoration-color: var(--tema-marchio-primario);
  text-underline-offset: 2px;
}

.core-table a {
  color: var(--tema-struttura-colore);
  text-decoration: none;
}

.core-table a:hover {
  color: var(--tema-struttura-colore);
  text-decoration: underline;
  text-decoration-color: var(--tema-marchio-primario);
  text-underline-offset: 2px;
}

/* Status badge pills */
.core-badge-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: var(--tema-font-peso-semigrassetto);
  line-height: 1.6;
  white-space: nowrap;
}

.core-badge-draft {
  background-color: var(--tema-colore-azzurro-91);
  color: var(--tema-colore-azzurro-tenue-35);
}

.core-badge-review {
  background-color: var(--tema-colore-giallo-vivo-89);
  color: var(--tema-colore-arancio-vivo-31);
}

.core-badge-ready {
  background-color: var(--tema-colore-verde-vivo-90);
  color: var(--tema-colore-petrolio-vivo-20);
}

.core-badge-published {
  background-color: var(--tema-colore-azzurro-vivo-93);
  color: var(--tema-colore-blu-vivo-40);
}

/* Coming soon badge */
.core-badge-coming-soon {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: var(--tema-font-peso-semigrassetto);
  background-color: var(--tema-bordo-tenue);
  color: var(--tema-testo-secondario);
  line-height: 1.6;
}


/* ==========================================================================
   SECTION F — Footer
   ========================================================================== */

.core-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.core-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--tema-spazio-lg);
}

.core-footer-links a {
  font-size: 11px;
  color: var(--tema-testo-secondario);
  text-decoration: none;
}

.core-footer-links a:hover {
  color: var(--tema-testo-primario);
}

.core-footer-version {
  font-size: 11px;
  color: var(--tema-testo-secondario);
}


/* ==========================================================================
   SECTION G — Auth pages
   ========================================================================== */

.core-auth-body {
  min-height: 100vh;
  display: flex;
  /* GDPR-CURA-2 (2.2): IN COLONNA. Il riquadro resta centrato come prima (un figlio solo, stessi assi scambiati),
   * e la riga «Modifica privacy» va SOTTO invece che di fianco; in riga, inoltre, il riquadro si allargava fino
   * alla tabella più larga che conteneva (min-width: auto di un elemento flex). */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--tema-contenuto-sfondo);
  padding: var(--tema-spazio-lg) var(--tema-spazio-md);
}

.core-auth-wrapper {
  width: 100%;
  max-width: 480px;
  padding: var(--tema-spazio-lg);
}

.core-auth-brand {
  text-align: center;
  margin-bottom: var(--tema-spazio-xl);
}

.core-auth-brand a {
  display: inline-block;
}


/* --------------------------------------------------------------------------
   SECTION G-bis — Entry pages, configurable appearance (BRAND-3)

   Scope: `.core-auth-branded` is put on the <body> by base_auth.html, so these
   rules reach every template it serves — login, registration, recovery, email
   verification, invitations, MFA, onboarding. The two public DocShare pages
   override the body class (and the background block) and are therefore excluded
   BY CONSTRUCTION, not by a conditional: they carry the tenant's brand, not the
   platform's.

   Every declaration below reads a --tema-ingresso-* token with the CURRENT value as
   its fallback. /branding.css emits a token only when it is configured, so an
   empty configuration falls through to today's rendering everywhere — there is
   no default to keep in sync, because nothing is written at all.

   The four pre-existing Section G rules above are untouched: `.core-auth-branded`
   has the same specificity as `.core-auth-body` and sits LATER in the file, so
   source order decides, and only when a token exists.
   -------------------------------------------------------------------------- */

.core-auth-branded {
  background-color: var(--tema-ingresso-sfondo, var(--tema-contenuto-sfondo));
  color: var(--tema-ingresso-testo, inherit);
  /* The background layer is fixed; the content must sit above it. */
  position: relative;
}

/* Card surface, focus ring and accent are re-declared as Bootstrap/core tokens
   so every existing selector keeps working unchanged — no new consumer to keep
   aligned, which is the ridondanza the mandate forbids. */
.core-auth-branded {
  --bs-card-bg: var(--tema-ingresso-superficie, var(--bs-card-bg));
  /* Derived, never a token: keeps the strict #RRGGBB validator the only gate,
     so no unvalidatable rgba() can ever enter the stylesheet. */
}

.core-auth-branded .core-auth-wrapper {
  position: relative;
  z-index: 1;
}

/* The backdrop layer. Rendered ONLY when a background is configured (the whole
   element is absent from the markup otherwise), and only ever inside
   {% block auth_background %}, which DocShare overrides empty. */
.core-auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.core-auth-bg img,
.core-auth-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The veil. The ONLY configurable transparency in the entry pages, and it lives
   here — over the media, never over the surface that carries text. The token is
   an integer 0-80 validated server-side, so the calc() cannot be broken out of. */
.core-auth-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(var(--tema-colore-nero-canali) / calc(var(--tema-ingresso-velo, 0) * 1%));
}

/* Entry-page logo. Same slot/base mechanism as the header logo (BRAND-4): the
   scale is a percentage of a standard height, never of the file's own size.

   BRAND-5 — it reads --tema-ingresso-logo-scala, i.e. the token /branding.css already
   emits, instead of a second custom property fed by a data attribute. There used
   to be BOTH: the stylesheet emitted a token nobody consumed while the attribute
   drove the rendering. One value, one path — which is also what lets the ops
   preview run this exact rule by setting this exact token. */
.core-auth-logo {
  height: calc(var(--tema-ingresso-logo-base) * var(--tema-ingresso-logo-scala, 100) / 100);
  max-height: var(--tema-ingresso-logo-alloggio);
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* HUB-4b — il ripiego neutro dell'ingresso di un hub: il NOME dell'ambiente,
   quando il canale non ha caricato un logo. E' lo stesso ripiego che il portale
   usa da PORTAL-1, e la ragione e' la stessa: mostrare il marchio della
   piattaforma su un dominio che non e' suo sarebbe peggio di non mostrare
   niente. Usa i token dell'ingresso, quindi segue la tavolozza dell'Ambiente. */
/* Il marchio dell'hub e' un collegamento verso la vetrina: senza questa riga
   il nome dell'ambiente comparirebbe SOTTOLINEATO, che nessun marchio e'. Il
   logo, essendo un'immagine, non aveva il problema — ed e' il motivo per cui
   non e' mai emerso prima del ripiego testuale. */
.core-auth-brand-link {
  text-decoration: none;
  color: inherit;
}

/* HUB-4d — un `.btn-link` dentro le pagine d'ingresso segue la TAVOLOZZA.
   Bootstrap lo colora con `--bs-link-color`, cioe' il blu di serie: sul login
   di piattaforma coincide con l'accento e nessuno se n'e' mai accorto, su un
   ambiente con la propria tavolozza no — nella stessa scheda «Richiedi un
   nuovo codice» era blu accanto a bottoni e collegamenti color ambra.
   Il RIPIEGO E' IL VALORE DI OGGI (`--bs-link-color`), quindi una pagina senza
   tavolozza configurata — tutte quelle di piattaforma — resta identica: e' la
   stessa disciplina dichiarata in cima a questa sezione. */

.core-auth-wordmark {
  display: block;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  /* `--tema-ingresso-su-sfondo` e NON `--tema-ingresso-testo`: questo testo sta sullo SFONDO,
     non dentro il riquadro. `text` finisce sul <body> e lo eredita il riquadro,
     dove sta tutto il resto del testo — con uno sfondo scuro e un riquadro
     chiaro i due colori non possono essere lo stesso, e usare `text` qui rende
     il nome dell'ambiente invisibile. Il ripiego e' `text`, quindi una
     tavolozza che non dichiara `on-bg` si comporta come prima. */
  color: var(--tema-ingresso-su-sfondo, var(--tema-ingresso-testo, var(--tema-testo-primario, var(--tema-colore-grigio-10))));
}


/* ---- Sidebar collapse toggle (top of sidebar) ---- */
.core-sidebar-toggle-wrap {
  display: flex;
  justify-content: flex-end;
  padding: var(--tema-spazio-xs) var(--tema-spazio-sm);
  flex-shrink: 0;
}



body.sidebar-collapsed .core-sidebar-toggle-wrap {
  justify-content: center;
}


/* ---- Sidebar collapsed state (desktop toggle) ---- */
body.sidebar-collapsed #core-sidebar {
  width: var(--tema-barra-chiusa-larghezza);
}

body.sidebar-collapsed #core-sidebar .core-nav-link span,
body.sidebar-collapsed #core-sidebar .core-nav-section-label,
body.sidebar-collapsed #core-sidebar .core-tenant-name {
  display: none;
}

body.sidebar-collapsed #core-sidebar .core-nav-link {
  justify-content: center;
  padding: var(--tema-densita-navigazione-riquadro-y) 0;
}

body.sidebar-collapsed #core-sidebar .core-nav-divider {
  margin: 8px 8px;
}

body.sidebar-collapsed #core-main,
body.sidebar-collapsed #core-footer {
  margin-left: var(--tema-barra-chiusa-larghezza);
}

/* ---- Module sidebar panel collapsed state ---- */
body.sidebar-collapsed #core-sidebar .core-module-sidebar-back span,
body.sidebar-collapsed #core-sidebar .core-module-sidebar-header span,
body.sidebar-collapsed #core-sidebar .core-module-sidebar-section-label {
  display: none;
}

body.sidebar-collapsed #core-sidebar .core-module-sidebar-header {
  display: none;
}

body.sidebar-collapsed #core-sidebar .core-module-sidebar-back {
  justify-content: center;
  padding: var(--tema-densita-navigazione-riquadro-y) 0;
}

body.sidebar-collapsed #core-sidebar .core-module-sidebar-divider {
  margin: 8px 8px;
}

/* ---- Chat sidebar panel collapsed state ---- */
body.sidebar-collapsed #chat-sidebar-panel .chat-sidebar-back span {
  display: none;
}

body.sidebar-collapsed #chat-sidebar-panel .chat-history-item,
body.sidebar-collapsed #chat-sidebar-panel .chat-history-date-label {
  display: none;
}

body.sidebar-collapsed #chat-sidebar-panel .chat-sidebar-back {
  justify-content: center;
  padding: var(--tema-densita-navigazione-riquadro-y) 0;
}



body.sidebar-collapsed #chat-sidebar-panel .chat-kb-section {
  padding: var(--tema-spazio-xs) 0;
  border-top: none;
}

body.sidebar-collapsed #chat-sidebar-panel .chat-kb-header {
  justify-content: center;
  cursor: pointer;
}

/* Collapsed rail (F5 P3) — the KB section reduces to ONLY the accent upload circle,
   centred and clickable (same file input), in BOTH source states (0 and >=1). The
   circle's pulse is disabled in the rail (chat.css) — no permanent animation at
   64px. Everything else (labels, list, hint, compact button) is hidden. */
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-header span,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-list,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-more,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-drop-title,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-drop-hint,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-add-compact {
  display: none;
}

/* Force the dropzone visible (its circle) even when >=1 source hides it expanded,
   and strip the card chrome so only the circle remains, centred. */
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-dropzone,
body.sidebar-collapsed #chat-sidebar-panel .chat-kb-section[data-has-sources="true"] .chat-kb-dropzone {
  display: flex;
  border: none;
  background: none;
  padding: 0;
}

/* Smooth transition */
#core-sidebar {
  transition: width 0.2s ease;
}

#core-main,
#core-footer {
  transition: margin-left 0.2s ease;
}

/* ==========================================================================
   SECTION H — Responsive breakpoints
   ========================================================================== */

/* ---- Tablet (≤ 991px): sidebar collapses to icon-only 64px ---- */
@media (max-width: 991px) {
  #core-sidebar {
    width: var(--tema-barra-chiusa-larghezza);
  }

  /* Hide text labels, keep icons */
  #core-sidebar .core-nav-link span,
  #core-sidebar .core-nav-section-label,
  #core-sidebar .core-tenant-name {
    display: none;
  }

  #core-sidebar .core-nav-link {
    justify-content: center;
    padding: var(--tema-densita-navigazione-riquadro-y) 0;
  }

  #core-sidebar .core-nav-divider {
    margin: 8px 8px;
  }

  #core-main,
  #core-footer {
    margin-left: var(--tema-barra-chiusa-larghezza);
  }

  /* KPI grid stays 2 columns on tablet — already the base */

  /* Hide user name text in header */
  .core-user-name {
    display: none;
  }

  /* Chat-mode: keep sidebar expanded at full width on tablet (unless manually collapsed) */
  body.chat-mode:not(.sidebar-collapsed) #core-sidebar {
    width: var(--tema-barra-larghezza);
  }

  body.chat-mode:not(.sidebar-collapsed) #core-sidebar #chat-sidebar-panel span,
  body.chat-mode:not(.sidebar-collapsed) #core-sidebar .core-nav-bottom .core-nav-link span {
    display: revert;
  }

  body.chat-mode:not(.sidebar-collapsed) #core-sidebar .core-nav-bottom .core-nav-link {
    justify-content: flex-start;
    padding: var(--tema-densita-navigazione-riquadro-y) var(--tema-densita-navigazione-riquadro-x);
  }

  body.chat-mode:not(.sidebar-collapsed) #core-main,
  body.chat-mode:not(.sidebar-collapsed) #core-footer {
    margin-left: var(--tema-barra-larghezza);
  }

  /* Chat-mode collapsed on tablet: hide conversation items, show only icons */
  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-sidebar-back span {
    display: none;
  }

  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-history-item,
  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-history-date-label {
    display: none;
  }


  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-kb-header span {
    display: none;
  }

  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-kb-header {
    justify-content: center;
    cursor: pointer;
  }

  body.chat-mode.sidebar-collapsed #core-sidebar #chat-sidebar-panel .chat-kb-list {
    display: none;
  }
}

/* ---- Mobile (≤ 767px): sidebar off-screen, toggled by JS ---- */
@media (max-width: 767px) {
  .core-sidebar-toggle-wrap {
    display: none;
  }

  #core-sidebar {
    width: var(--tema-barra-larghezza);
    left: calc(-1 * var(--tema-barra-larghezza));

    /* Restore text labels hidden at tablet breakpoint */
    .core-nav-link span,
    .core-nav-section-label {
      display: revert;
    }

    .core-nav-link {
      justify-content: flex-start;
      padding: var(--tema-densita-navigazione-riquadro-y) var(--tema-densita-navigazione-riquadro-x);
    }

    .core-nav-divider {
      margin: 8px 12px;
    }
  }

  /* Sidebar visible when toggled */
  body.core-sidebar-open #core-sidebar {
    left: 0;
  }

  /* Semi-transparent overlay behind open sidebar */
  body.core-sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--tema-colore-nero-a40);
    z-index: 850;
  }

  #core-main,
  #core-footer {
    margin-left: 0;
  }

  /* EDITOR-1 — on a phone the footer links go onto more lines instead of widening the page: with «Licenze» the row
     no longer fits in 390px (creator smoke, «nessuno scorrimento orizzontale»). The height follows the content. */
  #core-footer {
    height: auto;
    min-height: var(--tema-piede-altezza);
  }

  .core-footer-inner {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .core-footer-links {
    flex-wrap: wrap;
    row-gap: 2px;
    column-gap: var(--tema-spazio-md);
  }

  body.sidebar-collapsed:not(.core-sidebar-open) #core-sidebar {
    width: var(--tema-barra-larghezza);
    left: calc(-1 * var(--tema-barra-larghezza));
  }

  body.sidebar-collapsed:not(.core-sidebar-open) #core-main,
  body.sidebar-collapsed:not(.core-sidebar-open) #core-footer {
    margin-left: 0;
  }

  body.sidebar-collapsed.core-sidebar-open #core-sidebar {
    width: var(--tema-barra-larghezza);
    left: 0;
  }

  body.sidebar-collapsed.core-sidebar-open #core-sidebar .core-nav-link span,
  body.sidebar-collapsed.core-sidebar-open #core-sidebar .core-nav-section-label,
  body.sidebar-collapsed.core-sidebar-open #core-sidebar .core-tenant-name {
    display: revert;
  }

  body.sidebar-collapsed.core-sidebar-open #core-sidebar .core-nav-link {
    justify-content: flex-start;
    padding: var(--tema-densita-navigazione-riquadro-y) var(--tema-densita-navigazione-riquadro-x);
  }

  body.sidebar-collapsed.core-sidebar-open #core-sidebar .core-nav-divider {
    margin: 8px 12px;
  }

  body.core-sidebar-open .core-sidebar-toggle-wrap {
    display: flex;
  }

  body.chat-mode.sidebar-collapsed.core-sidebar-open #core-sidebar .core-nav-section-label {
    display: none;
  }

  body.chat-mode #core-main,
  body.chat-mode #core-footer {
    margin-left: 0;
  }

  #core-main {
    padding: var(--tema-spazio-md);
  }

  /* KPI grid: single column on mobile */
  .core-kpi-grid {
    grid-template-columns: 1fr;
  }

  .core-kpi-number {
    font-size: 24px;
  }

  /* Page header stacks vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}


/* ==========================================================================
   SECTION I — Utility classes
   ========================================================================== */

/* Visible only on desktop (≥ 768px), hidden below */
.d-desktop-only {
  display: revert;
}

@media (max-width: 767px) {
  .d-desktop-only {
    display: none !important;
  }
}

/* Visible only on mobile (< 768px), hidden on desktop.
 * TEMI-1 (A7): `!important` come le utility `d-*` di Bootstrap — la parte dei bottoni (`.core-icon-btn`, stessa
 * specificità) si carica DOPO questo foglio e, senza, mostrerebbe l'hamburger sul desktop (golden #4). */
.d-mobile-only {
  display: none !important;
}

@media (max-width: 767px) {
  .d-mobile-only {
    display: revert !important;
  }
}

.core-brand-logo-sm {
  height: 48px;
  width: auto;
}


/* ==========================================================================
   SECTION J — Dark mode overrides for components defined after SECTION A
   Must appear AFTER light-mode definitions so cascade order is correct.
   ========================================================================== */

@media (prefers-color-scheme: dark) {

  /* ── core-card — override hardcoded #fff background ──────── */
  .core-card {
    background: var(--tema-colore-blu-16);
    border-color: var(--tema-colore-blu-tenue-23);
  }

  /* ── Card icon variants — brighten for dark backgrounds ──── */
  .core-card-icon--primary {
    background: var(--tema-colore-arancio-vivo-50-a15);
    color: var(--tema-colore-giallo-vivo-56);
  }

  .core-card-icon--success {
    background: var(--tema-colore-petrolio-vivo-39-a15);
    color: var(--tema-colore-petrolio-52);
  }

  .core-card-icon--warning {
    background: var(--tema-colore-arancio-vivo-50-a15);
    color: var(--tema-colore-giallo-vivo-56);
  }

  .core-card-icon--info {
    background: var(--tema-colore-ciano-vivo-48-a15);
    color: var(--tema-colore-ciano-vivo-60);
  }

  .core-card-icon--accent {
    background: var(--tema-colore-arancio-vivo-50-a15);
    color: var(--tema-colore-giallo-vivo-56);
  }

  /* ── btn-accent — override hardcoded #ffffff background ──── */



  /* ── table-light — override Bootstrap hardcoded light thead ── */
  .table-light {
    --bs-table-bg: var(--tema-colore-blu-tenue-15);
    --bs-table-color: var(--tema-colore-azzurro-tenue-65);
    --bs-table-border-color: var(--tema-colore-blu-tenue-23);
    --bs-table-striped-bg: var(--tema-colore-blu-tenue-21);
    --bs-table-striped-color: var(--tema-colore-azzurro-tenue-65);
  }

  /* ── btn-outline-primary — mute for dark mode ────────────── */

  /* ── btn-outline-warning — mute for dark mode ────────────── */

  /* ── btn-outline-danger — mute for dark mode ─────────────── */

  /* ── Text utility classes — brighter in dark mode ────────── */
  .text-success {
    color: var(--tema-colore-petrolio-52) !important;
  }

  .text-warning {
    color: var(--tema-colore-giallo-vivo-56) !important;
  }

  .text-danger {
    color: var(--tema-colore-rosso-vivo-71) !important;
  }

  .text-info {
    color: var(--tema-colore-ciano-vivo-60) !important;
  }

  .text-secondary {
    color: var(--tema-colore-azzurro-tenue-65) !important;
  }

  .text-dark {
    color: var(--tema-colore-azzurro-91) !important;
  }

  /* ── btn-primary — cascade fix (light mode at line ~621 wins
     over Section A dark block; this Section J rule comes after) ─ */

  /* ── Table links — override hardcoded --tema-struttura-colore ─ */
  .core-table a {
    color: var(--tema-colore-azzurro-91);
  }

  .core-table a:hover {
    color: var(--tema-colore-azzurro-96);
    text-decoration-color: var(--tema-marchio-primario);
  }
}

/* ---------------------------------------------------------------------------
 * Widget indirizzo — la miniatura del punto confermato (CAT-GEO-3b)
 *
 * Compare dopo una conferma riuscita e mostra dove il geocoder ha messo il
 * punto: è la verifica che il tenant può fare PRIMA di pubblicare, e che una
 * frase come «Indirizzo confermato» non permette. Larghezza contenuta perché
 * è un controllo, non una figura: la mappa vera è quella della scheda.
 * ------------------------------------------------------------------------ */

.address-widget-preview {
  margin: 0;
}

.address-widget-preview-img {
  display: block;
  width: 100%;
  max-width: 22rem;
  aspect-ratio: 8 / 5;
  object-fit: cover;
  border: 1px solid var(--bs-border-color, var(--tema-colore-azzurro-tenue-89));
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-secondary-bg, var(--tema-colore-azzurro-tenue-93));
}

/* ---------------------------------------------------------------------------
 * CREATOR-RIFINITURE-1 — la pagina 404 dell'applicazione.
 * Vale per ogni tenant: col tema acceso i colori arrivano dai token rimappati,
 * senza tema è quella di sempre. Nessuna regola qui nomina un tema.
 * ------------------------------------------------------------------------- */
.core-404 {
  max-width: 34rem;
  margin: 0 auto;
  padding: var(--tema-spazio-xl, 2rem) 0;
  text-align: center;
}
.core-404-numero {
  font-size: 3.5rem;
  line-height: 1;
  font-weight: 700;
  color: var(--tema-testo-terziario);
  margin: 0 0 var(--tema-spazio-sm, .5rem);
}
.core-404 h1 { margin: 0 0 var(--tema-spazio-sm, .5rem); }
.core-404-testo {
  color: var(--tema-testo-secondario);
  margin: 0 0 var(--tema-spazio-lg, 1.5rem);
  text-wrap: pretty;
}
