/* ── Design tokens, reset e base element styles in shared/styles-base.css ── */

/* ── Override locale dei toni sidebar/topbar (solo questa app): navy più
   tenue e testo a contrasto più alto rispetto al default condiviso ── */
:root {
  --c-sidebar:        #1b2740;
  --c-sidebar-border: #3a4a6b;
  --c-sidebar-text:   #aebbd6;
  --c-sidebar-muted:  #7a8db3;
}

/* ───────────────────────────────────────────────────────────────
   BASE (app-riconciliazione specific)
─────────────────────────────────────────────────────────────── */
html { font-size: 14px; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); line-height: 1.5; }

/* ───────────────────────────────────────────────────────────────
   SHELL
─────────────────────────────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ───────────────────────────────────────────────────────────────
   LOGIN
─────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-sidebar);
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.login-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: .08em;
  margin-bottom: .75rem;
}
.login-title { font-size: 1.25rem; font-weight: 600; margin-bottom: .5rem; }
.login-subtitle { color: var(--c-text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* ───────────────────────────────────────────────────────────────
   TOPBAR
─────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--c-sidebar);
  color: var(--c-sidebar-active);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--c-sidebar-border);
}
.topbar__brand { display: flex; align-items: center; gap: .75rem; }
.topbar__logo  { font-weight: 700; font-size: 1rem; color: var(--c-accent); letter-spacing: .06em; }
.topbar__title { font-size: .9rem; color: var(--c-sidebar-text); }
.topbar__actions { display: flex; align-items: center; gap: 1rem; }
.topbar__user { font-size: .8rem; color: var(--c-sidebar-text); }

/* ───────────────────────────────────────────────────────────────
   MAIN LAYOUT — two-column on desktop
─────────────────────────────────────────────────────────────── */
.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--c-sidebar);
  border-right: 1px solid var(--c-sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem .75rem;
  flex-shrink: 0;
}
.sidebar__title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--c-sidebar-text); }
.sidebar__search { padding: 0 .75rem .75rem; flex-shrink: 0; }
.sidebar__empty { padding: 1rem .75rem; color: var(--c-sidebar-muted); font-size: .85rem; }
.sidebar__footer { padding: .75rem; flex-shrink: 0; border-top: 1px solid var(--c-sidebar-border); }
.sidebar__export-btn { width: 100%; justify-content: center; }

.cdl-list { flex: 1; overflow-y: auto; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .35rem; }
.cdl-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  text-align: left;
  background: rgb(255 255 255 / .08);
  border: 1px solid var(--c-sidebar-border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.cdl-item:hover { background: rgb(255 255 255 / .16); border-color: var(--c-sidebar-muted); }
.cdl-item--active {
  background: rgb(14 165 233 / .14);
  border-color: var(--c-accent);
}
.cdl-item__name {
  font-size: .85rem;
  color: var(--c-sidebar-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .12s;
}
.cdl-item:hover .cdl-item__name { color: var(--c-sidebar-active); }
.cdl-item--active .cdl-item__name { color: var(--c-sidebar-active); }

/* ── Indicatore di stato (pallino colorato, stesso linguaggio dell'anello) ── */
.cdl-item__indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--indicator-color, var(--c-sidebar-muted));
}
.cdl-item__indicator--home {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-sidebar-text);
  background: none;
}
/* Indicatore home-style reso come carattere invece di <svg> (es. "Σ" per
   Globale - Allocazioni): stesso box 18x18 flex-centrato, solo dimensione
   e peso del testo per bilanciarsi con le icone vettoriali accanto. */
.cdl-item__indicator--text { font-size: 1rem; font-weight: 700; line-height: 1; }
.cdl-item--home { margin-bottom: .35rem; }
.cdl-item--home.cdl-item--active .cdl-item__indicator--home,
.cdl-item--home:hover .cdl-item__indicator--home { color: var(--c-accent); }
.cdl-item--home .cdl-item__name { font-weight: 600; }

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  min-width: 0;
}

/* ── PAGE CONTENT — contenitore della pagina attiva (Home o Dettaglio) ── */
.page-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ───────────────────────────────────────────────────────────────
   HOME COCKPIT
─────────────────────────────────────────────────────────────── */
.cockpit { flex: 1; overflow-y: auto; padding: 1.75rem 2rem; min-width: 0; }

.system-summary { margin-bottom: 1.25rem; }

.cockpit-priority-filter { margin-bottom: 1.25rem; }

.cockpit-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cockpit-card {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.4rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.cockpit-card:not(.cockpit-card--static):hover { box-shadow: var(--shadow-md); border-color: var(--c-border-strong); transform: translateY(-1px); }
.cockpit-card:not(.cockpit-card--static):focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

/* ── Box Mandato FB: stesso linguaggio visivo delle card CdL, ma non
   cliccabile (entità di sistema singola, nessuna pagina di dettaglio in
   questa app) e con un accento per distinguerlo categoricamente da un CdL ── */
.cockpit-card--static { cursor: default; margin-bottom: 1.25rem; }
.cockpit-card--mandato-fb { border-left: 3px solid var(--c-accent); }
.cockpit-card__icon { display: flex; flex-shrink: 0; color: var(--c-accent); }

/* ── Indicatore "ha allocazioni Mandato FB" nelle tabelle collaboratori ── */
.mandato-fb-indicator { display: inline-flex; vertical-align: middle; margin-left: .4rem; color: var(--c-accent); }

/* ── Titolo box: nome CdL, sempre su una riga ── */
.cockpit-card__title {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}
.cockpit-card__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Corpo: anello + tile ── */
.cockpit-card__body { display: flex; align-items: center; gap: 1.25rem; }

.completion-ring {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), var(--c-border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
}
.completion-ring::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--c-surface);
}
.completion-ring__value {
  position: relative;
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-text);
}

/* ── Variante piccola, riusata nell'intestazione del Dettaglio ── */
.completion-ring--sm { width: 42px; height: 42px; }
.completion-ring--sm::before { inset: 4px; }
.completion-ring--sm .completion-ring__value { font-size: .68rem; }

/* ── Riquadri dati ── */
.cockpit-card__tiles {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .75rem;
}
.cockpit-card__tiles--mandato-fb { grid-template-columns: repeat(4, 1fr); }

.cockpit-tile {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  min-width: 0;
}
.cockpit-tile__label { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); }
.cockpit-tile__value { font-size: .95rem; font-weight: 700; color: var(--c-text); font-variant-numeric: tabular-nums; line-height: 1.3; }

.cockpit-tile--ok    { background: var(--c-success-bg); border-color: #a7f3d0; }
.cockpit-tile--ok    .cockpit-tile__value { color: var(--c-success-text); }
.cockpit-tile--error { background: var(--c-error-bg); border-color: var(--c-error-border); }
.cockpit-tile--error .cockpit-tile__value { color: var(--c-error-text); }

/* ── Skeleton di caricamento ── */
.cockpit-card--skeleton {
  height: 96px;
  cursor: default;
  background: linear-gradient(90deg, var(--c-bg) 25%, var(--c-border) 37%, var(--c-bg) 63%);
  background-size: 400% 100%;
  animation: cockpit-shimmer 1.4s ease infinite;
}
@keyframes cockpit-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ───────────────────────────────────────────────────────────────
   SECTION
─────────────────────────────────────────────────────────────── */
.section { margin-bottom: 2rem; }
.section__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 1rem;
}

/* ───────────────────────────────────────────────────────────────
   CdL HEADER
─────────────────────────────────────────────────────────────── */
.cdl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--c-border);
}
.cdl-header__identity { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.cdl-header__title { font-size: 1.25rem; font-weight: 700; }
.cdl-header__sub   { font-size: .8rem; color: var(--c-text-muted); margin-top: .2rem; }
.cdl-header__badges { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* ───────────────────────────────────────────────────────────────
   DETAIL TABS (Dettaglio CdL)
─────────────────────────────────────────────────────────────── */
.detail-tabs {
  display: flex;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
}
.detail-tab {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: .75rem .1rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.detail-tab:hover { color: var(--c-accent); }
.detail-tab--active { color: var(--c-accent-dark); border-bottom-color: var(--c-accent); }

/* ───────────────────────────────────────────────────────────────
   FILTERS BAR
─────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}
.filter-group { display: flex; align-items: center; gap: .75rem; }
.filter-group__label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); white-space: nowrap; }
.filter-chips { display: flex; gap: .4rem; flex-wrap: wrap; }

.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-input-wrap__icon { position: absolute; left: .6rem; width: 14px; height: 14px; color: var(--c-text-muted); pointer-events: none; }
.search-input {
  width: 200px;
  padding: .4rem .75rem .4rem 1.95rem;
  font-size: .8rem;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  transition: border-color .12s, box-shadow .12s;
}
.search-input::placeholder { color: var(--c-text-muted); }
.search-input:hover { border-color: var(--c-border-strong); }
.search-input:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px rgba(14, 165, 233, .15); }
.search-input-wrap__clear {
  position: absolute; right: .5rem; width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-muted); cursor: pointer; border-radius: 999px; font-size: .9rem; line-height: 1; border: none; background: none;
}
.search-input-wrap__clear:hover { color: var(--c-text); background: var(--c-bg); }

/* ───────────────────────────────────────────────────────────────
   KPI CARDS
─────────────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.kpi-card__label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); margin-bottom: .4rem; }
.kpi-card__value { font-size: 1.75rem; font-weight: 700; color: var(--c-text); }
.kpi-card__value--ok    { color: var(--c-success-text); }
.kpi-card__value--alert { color: var(--c-error-text); }

/* ───────────────────────────────────────────────────────────────
   TABLES
─────────────────────────────────────────────────────────────── */
.table-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-card--full { margin-bottom: 1.5rem; }
.table-card__scroll { overflow-x: auto; }
.table-card__scroll .table { width: 100%; }
.table-card__title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  font-weight: 600;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-accent-subtle);
  color: var(--c-accent-dark);
}
.table-wrap {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}
.table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .875rem; }
/* Tabelle con colonne di larghezza molto disomogenea (es. "Carico
   collaboratori": "Tipo contratto" accanto a "CdL"/"Ore"/"GDO"): table-layout
   fixed dividerebbe lo spazio in parti uguali, comprimendo le colonne con
   testo più lungo indipendentemente dalla larghezza totale. table-layout
   auto dimensiona ogni colonna sul proprio contenuto; il min-width forza lo
   scroll orizzontale del contenitore .table-card__scroll quando il totale
   naturale supera il viewport, invece di comprimere il testo. */
.table--wide { table-layout: auto; min-width: 900px; }
.table th {
  background: var(--c-bg);
  text-align: left;
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.table td { padding: .6rem 1rem; border-bottom: 1px solid var(--c-border); }
.table tbody tr:last-child td { border-bottom: none; }
.table--compact th, .table--compact td { padding: .5rem .875rem; }
th.th--num, td.td--num { text-align: right; font-variant-numeric: tabular-nums; }
.col-group-start { border-left: 2px solid var(--c-border-strong); }
.table--compact .col-group-start { padding-left: 1.25rem; }
.td--name { font-weight: 500; }
.tr--total td { font-weight: 600; background: var(--c-bg); border-top: 1px solid var(--c-border); }
.table-row:hover td { background: var(--c-bg); }
.table-row--active td { background: var(--c-accent-subtle); }

/* ───────────────────────────────────────────────────────────────
   ANOMALIE
─────────────────────────────────────────────────────────────── */
.anomalie-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.anomaly-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.anomaly-card__title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  font-weight: 600;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-success-bg);
  color: var(--c-success-text);
}
.anomaly-card__title--alert { background: var(--c-error-bg); color: var(--c-error-text); }
.anomaly-card__title--alert .badge--error { background: #fff; }
.anomaly-card--full { margin-bottom: 1.5rem; }
.anomaly-excess { color: var(--c-error-text); font-weight: 600; }
.anomaly-empty {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem;
  font-size: .875rem;
  color: var(--c-success);
}
.anomaly-empty--neutral { color: var(--c-text-muted); }
.anomaly-list { padding: .25rem 0; }
.anomaly-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--c-border);
  font-size: .85rem;
}
.anomaly-item:last-child { border-bottom: none; }
.anomaly-item__module { display: flex; flex-direction: column; min-width: 0; }
.anomaly-item__acronym { font-weight: 600; font-size: .78rem; color: var(--c-text-muted); }
.anomaly-item__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anomaly-item__right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.anomaly-item__detail { font-size: .78rem; color: var(--c-text-muted); }

/* ───────────────────────────────────────────────────────────────
   EMPTY / INCOMPLETE STATES
─────────────────────────────────────────────────────────────── */
.global-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--c-text-muted);
}
.global-empty svg { opacity: .35; }
.incomplete-notice {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1.25rem;
  background: var(--c-warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  color: var(--c-warning-text);
  font-size: .875rem;
  line-height: 1.6;
}
.incomplete-notice svg { flex-shrink: 0; margin-top: .1rem; }

/* ───────────────────────────────────────────────────────────────
   OVERLAYS / BANNERS
─────────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-overlay__inner {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  font-size: .95rem;
  color: var(--c-text-muted);
  box-shadow: var(--shadow-md);
}
.error-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  background: var(--c-error-bg);
  border-bottom: 1px solid var(--c-error-border);
  color: var(--c-error-text);
  font-size: .875rem;
  flex-shrink: 0;
}
.error-banner svg { flex-shrink: 0; }

/* ───────────────────────────────────────────────────────────────
   BUTTONS
─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: .45rem .9rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary {
  background: var(--c-accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--c-accent-dark); }
.btn--ghost {
  background: rgb(255 255 255 / .08);
  color: var(--c-sidebar-active);
  border: 1px solid var(--c-sidebar-border);
}
.btn--ghost:hover:not(:disabled) { background: rgb(255 255 255 / .14); }
/* .btn--ghost è pensato per sfondi scuri (sidebar, modali); nel contesto
   content-area (sfondo chiaro) serve un secondario a contrasto leggibile. */
.btn--outline {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border-strong);
}
.btn--outline:hover:not(:disabled) { background: var(--c-bg); }
.btn--sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text-muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--c-bg); color: var(--c-text); }
.btn-icon:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.btn--login-ms {
  background: var(--c-accent);
  color: #fff;
  width: 100%;
  justify-content: center;
  padding: .75rem;
  font-size: .95rem;
  border-radius: var(--radius);
}

/* ───────────────────────────────────────────────────────────────
   CHIPS (filtri)
─────────────────────────────────────────────────────────────── */
.chip {
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-muted);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: var(--c-accent); color: var(--c-accent); }
.chip--active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.chip--active:hover { color: #fff; }

/* Filtro a cardinalità variabile (es. Ruolo): stesso linguaggio dei chip
   (bordo, radius, hover accent) ma forma rettangolare a discesa, per
   distinguersi visivamente dai filtri a opzioni fisse. */
.filter-select {
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--radius-sm);
  padding: .3rem .6rem;
  font-size: .8rem;
  cursor: pointer;
}
.filter-select:hover { border-color: var(--c-accent); }
.filter-select:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 1px; }

/* ───────────────────────────────────────────────────────────────
   BADGE
─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge--success  { background: var(--c-success-bg);  color: var(--c-success-text); }
.badge--error    { background: var(--c-error-bg);    color: var(--c-error-text); }
.badge--warning  { background: var(--c-warning-bg);  color: var(--c-warning-text); }
.badge--neutral  { background: var(--c-bg);          color: var(--c-text-muted); border: 1px solid var(--c-border); }
.badge--info     { background: var(--c-accent-subtle); color: var(--c-accent-dark); }
.badge--lg { padding: .3rem .8rem; font-size: .82rem; }

/* ───────────────────────────────────────────────────────────────
   INPUT
─────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  border: 1px solid var(--c-sidebar-border);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / .06);
  color: var(--c-sidebar-active);
  padding: .45rem .75rem;
  font-size: .85rem;
  outline: none;
}
.input::placeholder { color: var(--c-sidebar-muted); }
.input:focus { border-color: var(--c-accent); }
.input--search { padding-left: .75rem; }

/* ───────────────────────────────────────────────────────────────
   UTILITIES
─────────────────────────────────────────────────────────────── */
.muted { color: var(--c-text-muted); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .7s linear infinite; }

/* ───────────────────────────────────────────────────────────────
   MODALE
─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-enter, .modal-leave { transition: opacity .18s ease; }
.modal-enter-start, .modal-leave-end { opacity: 0; }
.modal-enter-end, .modal-leave-start { opacity: 1; }
.modal-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 920px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-card-enter, .modal-card-leave { transition: opacity .18s ease, transform .18s ease; }
.modal-card-enter-start, .modal-card-leave-end { opacity: 0; transform: scale(.97); }
.modal-card-enter-end, .modal-card-leave-start { opacity: 1; transform: scale(1); }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
}
.modal-header__info { min-width: 0; flex: 1 1 auto; }
.modal-title { font-size: 1.05rem; font-weight: 600; color: var(--c-text); margin: 0; }
.modal-subtitle { font-size: .82rem; color: var(--c-text-muted); margin: .35rem 0 0; }
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
}
.modal-close:hover { background: var(--c-bg); color: var(--c-text); }
.modal-close:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.modal-body { padding: 0; overflow-y: auto; }
.modal-body .table thead th { position: sticky; top: 0; }

/* ── Barra budget GDO nell'intestazione delle modali allocazioni ── */
.gdo-meter { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; margin-top: .55rem; }
.gdo-meter__caption { font-size: .82rem; color: var(--c-text-muted); white-space: nowrap; }
.gdo-meter__caption strong { color: var(--c-text); font-weight: 600; }
.gdo-meter__track {
  display: flex;
  width: 140px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--c-border);
  overflow: hidden;
}
.gdo-meter__segment { height: 100%; background: var(--c-accent); }
.gdo-meter__segment--overflow { background: var(--c-error); }
.gdo-meter__excess { font-size: .82rem; white-space: nowrap; }

/* ── Riga gruppo CdL nella modale cross-CdL: sostituisce la cella vuota
   usata in precedenza per "raggruppare" senza ripetere il testo ── */
.modal-group-row td {
  background: var(--c-bg);
  font-weight: 600;
  color: var(--c-text);
  padding-top: .55rem;
  padding-bottom: .55rem;
}
.modal-group-row__meta { font-weight: 400; color: var(--c-text-muted); margin-left: .4rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--c-border);
}

@media (prefers-reduced-motion: reduce) {
  .modal-enter, .modal-leave, .modal-card-enter, .modal-card-leave { transition: opacity .01ms; }
  .modal-card-enter-start, .modal-card-enter-end, .modal-card-leave-start, .modal-card-leave-end { transform: none; }
}

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE — mobile / tablet
─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: 1fr; }
  .anomalie-row { grid-template-columns: 1fr; }
  .cockpit-card__tiles { grid-template-columns: repeat(3, 1fr); }
}

/* Collasso del menu condiviso allineato al breakpoint già usato in
   app-oneri-mansionari-dacd (striscia compatta in alto, identica in
   Home e nel Dettaglio). */
@media (max-width: 768px) {
  .main-layout { flex-direction: column; overflow: auto; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--c-sidebar-border);
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }
  .sidebar__header { display: none; }
  .sidebar__search { padding: .5rem .75rem; flex: 0 0 150px; }
  .sidebar__empty { display: none; }
  .cdl-list { display: flex; flex-direction: row; flex-wrap: nowrap; gap: .4rem; padding: .5rem .75rem; overflow-x: auto; }
  .cdl-item { padding: .4rem .75rem; white-space: nowrap; flex-shrink: 0; }
  .cdl-item--home { margin-bottom: 0; }
  .content { padding: 1.25rem 1rem; }
  .cockpit { padding: 1.25rem 1rem; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 1rem; }
  .topbar__title { display: none; }
  .filters-bar { padding: .75rem; gap: .75rem; }
  .filter-group { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .cockpit-card { padding: 1rem; }
  .cockpit-card__tiles { grid-template-columns: repeat(2, 1fr); }
  .cdl-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
}

/* ───────────────────────────────────────────────────────────────
   ACCESS DENIED — stessa geometria di .login-screen/.login-card:
   è lo stesso genere di schermata ("non puoi essere qui"), non un
   errore transitorio da riprovare.
─────────────────────────────────────────────────────────────── */
.access-denied-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-sidebar);
}

.access-denied-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.access-denied-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--c-error-bg);
  color: var(--c-error);
  margin-bottom: 1rem;
}

.access-denied-title { font-size: 1.25rem; font-weight: 600; margin-bottom: .5rem; }

.access-denied-subtitle {
  color: var(--c-text-muted);
  font-size: .9rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.access-denied-back {
  font-size: .85rem;
  color: var(--c-accent);
  text-decoration: none;
}
.access-denied-back:hover { text-decoration: underline; }
