:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --ink: #1a1a2e;
  --ink-2: #4a4a5c;
  --muted: #8a8a9e;
  --border: #e4e4ea;
  --brand: #76092d;
  --brand-dark: #5a071f;
  --brand-soft: #fbf2f4;
  --accent: #4a5b78;
  --accent-dark: #364660;
  --accent-soft: #eef1f6;
  --ok: #2ba26a;
  --ok-soft: #e7f6ee;
  --err: #e53e3e;
  --err-soft: #fdecec;
  --warn: #e89000;
  --warn-soft: #fdf4e3;
  --info: #2c6ecb;
  --info-soft: #e8eff9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--err); font-size: 13px; margin-top: 6px; }

/* ======== Topbar ======== */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-link { display: inline-flex; align-items: center; }
.brand img { height: 48px; width: auto; filter: brightness(0) invert(1); }
.brand .subtitle {
  color: rgba(255,255,255,.85);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
}
.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topnav-link {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.topnav-link:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.topnav-link--btn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
  font-family: inherit;
}
.topnav-link--btn:hover { background: rgba(255,255,255,.22); }
.topnav-user { color: rgba(255,255,255,.8); font-size: 13px; }
.topnav-logout { margin: 0; }

/* ======== Container ======== */
.container {
  width: 100%;
  max-width: none;
  margin: 24px auto 32px;
  padding: 0 28px;
}
.container--wide { max-width: none; }
.container--full { max-width: none; padding: 0 14px; }

/* ======== Day-kind colour-coded headers (sat/fest/norm) ======== */
.data-table thead th.day-sat { background: #fff7d6; color: #6f5300; }
.data-table thead th.day-fest { background: #fbe3e6; color: #8a1c2b; }
.data-table thead th.day-norm { background: #e3f5ea; color: #155724; }
.data-table .day-num { font-size: 12px; font-weight: 700; }

/* ======== Diff badges ======== */
.diff { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; vertical-align: middle; margin-left: 6px; }
.diff--pos { background: var(--ok-soft); color: #166c43; }
.diff--neg { background: var(--err-soft); color: #962525; }
.diff--zero { background: #eef0f4; color: #4a4a5c; }

/* ======== Consultant grid (3 colonne side-by-side) ======== */
.consultant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.consultant-grid .card { margin: 0; }
.consultant-grid .card h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.consultant-grid .card h2 .muted { font-size: 13px; font-weight: 500; }
@media (max-width: 768px) {
  .consultant-grid { grid-template-columns: 1fr; }
}

/* Tabella vendite per consulente: importo pieno (decimali inclusi) sempre visibile,
   cliente con larghezza fissa moderata (ellipsis se serve).
   Tabella width:auto cosi' non si gonfia su card larghe. */
.consultant-sales-table { table-layout: fixed; width: auto; }
.consultant-sales-table thead th,
.consultant-sales-table tbody td { padding: 8px 9px; font-size: 12.5px; }
/* Gg / Tip / Dur: contenuto piccolo, centrato e padding orizzontale ridotto */
.consultant-sales-table thead th:nth-child(1),
.consultant-sales-table thead th:nth-child(3),
.consultant-sales-table thead th:nth-child(4),
.consultant-sales-table tbody td:nth-child(1),
.consultant-sales-table tbody td:nth-child(3),
.consultant-sales-table tbody td:nth-child(4) {
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}
.consultant-sales-table .col-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.consultant-sales-table .col-num { white-space: nowrap; }
/* col venduto con breakdown disponibile: underline tratteggiato sottile come hint hover */
td.col-num[data-tip] { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
/* Header sortable: cursor pointer, hover, indicatore freccia via aria-sort */
.consultant-sales-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.consultant-sales-table th[data-sort]:hover { background: var(--accent-soft); }
.consultant-sales-table th[data-sort]::after {
  content: ' ⇅';
  opacity: 0.35;
  font-size: 10px;
}
.consultant-sales-table th[aria-sort='asc']::after  { content: ' ↑'; opacity: 1; }
.consultant-sales-table th[aria-sort='desc']::after { content: ' ↓'; opacity: 1; }

/* ======== Pagina Rinnovi (Jack) ======== */
.rinnovi-recap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0 22px;
}
.rinnovi-recap--business { grid-template-columns: repeat(3, 1fr); margin: 0; }
@media (max-width: 768px) {
  .rinnovi-recap,
  .rinnovi-recap--business { grid-template-columns: 1fr; }
}
.rinnovi-card--inset {
  box-shadow: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.rinnovi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent);
}
.rinnovi-card:nth-child(2) { border-top-color: var(--info); }
.rinnovi-card:nth-child(3) { border-top-color: var(--muted); }
.rinnovi-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.rinnovi-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-2);
}
.rinnovi-card-count {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.rinnovi-card-total {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}
.rinnovi-card-breakdown {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}
.rinnovi-bd {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  border-radius: 6px;
  background: var(--surface-2);
}
.rinnovi-bd-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.rinnovi-bd-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.rinnovi-card-breakdown--note { display: block; }
.rinnovi-card--inset .rinnovi-bd { background: var(--surface); }

/* Tabella vendite Jack: layout auto, larghezza naturale, no ellipsis */
.rinnovi-sales-table { table-layout: auto; width: 100%; }
.rinnovi-sales-table thead th,
.rinnovi-sales-table tbody td { padding: 8px 12px; font-size: 13px; }
.rinnovi-sales-table .col-name { white-space: normal; overflow: visible; text-overflow: clip; }
.rinnovi-sales-table th[data-sort] { cursor: pointer; user-select: none; position: relative; }
.rinnovi-sales-table th[data-sort]:hover { background: var(--accent-soft); }
.rinnovi-sales-table th[data-sort]::after { content: ' ⇅'; opacity: 0.35; font-size: 10px; }
.rinnovi-sales-table th[aria-sort='asc']::after  { content: ' ↑'; opacity: 1; }
.rinnovi-sales-table th[aria-sort='desc']::after { content: ' ↓'; opacity: 1; }

/* ======== Strategy table compatta (full-month grid) ========
 * table-layout: fixed → tutti i giorni hanno EXACT same width.
 * La col label e' fissata via <colgroup>; le altre 28-31 si dividono
 * equamente lo spazio rimanente. Padding/font ridotti per evitare scroll
 * orizzontale fino a ~1100px di viewport. */
.strategy-table { table-layout: fixed; width: 100%; }
.strategy-table th, .strategy-table td { padding: 4px 2px; font-size: 11.5px; overflow: hidden; }
.strategy-table thead th { text-align: center; padding: 5px 2px; vertical-align: middle; }
/* Override: i th con .col-num devono restare centrati (vincere su .data-table .col-num right) */
.strategy-table thead th.col-num { text-align: center; }
.strategy-table td.col-num { text-align: center; min-width: 0; vertical-align: middle; }
.strategy-table .row-label { text-align: left; font-weight: 600; white-space: nowrap; padding-left: 8px; padding-right: 8px; vertical-align: middle; }
.strategy-table .day-num { font-size: 11px; font-weight: 700; display: inline-block; line-height: 1; }
.strategy-table tr.row-divider td { border-top: 2px solid var(--border); }
.strategy-table tbody tr:hover { background: transparent; }
/* Bordi verticali sottili tra le colonne giorno */
.strategy-table th + th, .strategy-table td + td { border-left: 1px solid #f0f0f4; }
/* Diff badge dentro la tabella: ancora piu' piccolo per stare in cella */
.strategy-table .diff { padding: 1px 4px; font-size: 10px; margin: 0; line-height: 1.4; }
/* Promo rows */
.strategy-table .promo-row td.row-label { font-weight: 600; }
.strategy-table .promo-cell { background: rgba(44, 110, 203, 0.22); }
/* Promo "inattiva" (cade su giorno festivo, staff non in servizio): pattern
 * diagonale + opacita' ridotta per indicare che la promo c'e' ma non e'
 * "vendibile" quel giorno. */
.strategy-table .promo-cell--inactive {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.55) 0px,
    rgba(255, 255, 255, 0.55) 2px,
    transparent 2px,
    transparent 5px
  );
  opacity: 0.55;
}
/* Palette promozioni — fino a 8 promo distinte sovrapposte */
.strategy-table .promo-cell--0 { background: rgba(44, 110, 203, 0.28); }    /* blu */
.strategy-table .promo-cell--1 { background: rgba(232, 144, 0, 0.30); }     /* arancio */
.strategy-table .promo-cell--2 { background: rgba(43, 162, 106, 0.30); }    /* verde */
.strategy-table .promo-cell--3 { background: rgba(201, 91, 139, 0.30); }    /* rosa */
.strategy-table .promo-cell--4 { background: rgba(118, 9, 45, 0.22); }      /* burgundy */
.strategy-table .promo-cell--5 { background: rgba(140, 90, 200, 0.30); }    /* viola */
.strategy-table .promo-cell--6 { background: rgba(74, 91, 120, 0.30); }     /* blu-grigio */
.strategy-table .promo-cell--7 { background: rgba(74, 74, 92, 0.30); }      /* grigio scuro */
/* Legenda swatch */
.promo-legend { display: inline-flex; align-items: center; gap: 5px; margin-right: 14px; font-size: 12px; }
.promo-legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.promo-legend-swatch--0 { background: rgba(44, 110, 203, 0.6); }
.promo-legend-swatch--1 { background: rgba(232, 144, 0, 0.6); }
.promo-legend-swatch--2 { background: rgba(43, 162, 106, 0.6); }
.promo-legend-swatch--3 { background: rgba(201, 91, 139, 0.6); }
.promo-legend-swatch--4 { background: rgba(118, 9, 45, 0.55); }
.promo-legend-swatch--5 { background: rgba(140, 90, 200, 0.6); }
.promo-legend-swatch--6 { background: rgba(74, 91, 120, 0.6); }
.promo-legend-swatch--7 { background: rgba(74, 74, 92, 0.6); }

/* ======== KPI tables (Business + per-consultant) ======== */
.kpi-block { margin: 16px 0; }
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-top: 4px solid var(--brand);
  overflow: hidden;
}
.kpi-card--consultant { border-top-color: var(--accent); }
.kpi-title-bar {
  text-align: center;
  padding: 16px 14px 18px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--brand);
  font-size: 26px;
}
.kpi-title-bar .kpi-period {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--muted);
  margin-top: 4px;
}
.kpi-card--consultant .kpi-title-bar {
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 1.5px;
  padding: 12px 12px 14px;
}
.kpi-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.kpi-table th, .kpi-table td {
  text-align: center;
  padding: 6px 8px;
  border-left: 1px solid var(--border);
}
.kpi-table th:first-child, .kpi-table td:first-child { border-left: none; }
.kpi-table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.kpi-table tbody td {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 6px 14px;
}
.kpi-card:not(.kpi-card--consultant) .kpi-table tbody td { font-size: 32px; padding: 10px 6px 12px; }
.kpi-card:not(.kpi-card--consultant) .kpi-table thead th { font-size: 13px; padding: 10px 6px 6px; }
.kpi-card--consultant .kpi-table tbody td { font-size: 22px; padding: 14px 6px 16px; }
.kpi-card:not(.kpi-card--consultant) .kpi-table .kpi-cell--primary { color: var(--brand); }
.kpi-card--consultant .kpi-table .kpi-cell--primary { color: var(--accent); }
/* Diff badge dentro KPI: line-height aumentata + display flex per centratura verticale perfetta */
.kpi-table td:has(.diff) { line-height: 1; }
.kpi-table .diff { font-size: 18px; padding: 4px 12px; vertical-align: middle; line-height: 1.2; }
.kpi-card--consultant .kpi-table .diff { font-size: 14px; padding: 3px 10px; }

.kpi-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
@media (max-width: 768px) {
  .kpi-grid-3 { grid-template-columns: 1fr; }
  .kpi-card:not(.kpi-card--consultant) .kpi-table tbody td { font-size: 19px; padding: 12px 4px; }
}

/* ======== Drill-down giorno: registro ospiti ======== */
.guest-table .col-consultant { font-weight: 700; color: var(--accent); }
.guest-table .col-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.guest-table .col-name { font-weight: 600; }
.guest-table a { color: var(--accent); }
.guest-table a:hover { color: var(--accent-dark); }
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-style: italic;
  font-weight: 700;
  font-size: 11px;
  text-decoration: none;
  user-select: none;
}
.info-icon:hover { background: var(--accent); color: #fff; }

/* ======== Tooltip popup (instant, JS-positioned, position:fixed) ======== */
.tooltip-pop {
  position: fixed;
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  white-space: pre-wrap;
  max-width: 320px;
  word-wrap: break-word;
}

/* ======== Promo form (per-duration sub-cards) ======== */
.promo-duration-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--surface-2);
}
.promo-duration-card--enabled { background: var(--accent-soft); border-color: var(--accent); }
.promo-duration-card .form-row { margin-bottom: 10px; }
.promo-duration-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 600; }

.page-head { margin: 8px 0 20px; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; }

/* ======== Month nav ======== */
.month-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.month-title { margin: 0; font-size: 22px; min-width: 220px; text-align: center; }
.month-today { margin-left: auto; }

/* Frecce prev/next: solo simbolo, niente label adiacente. */
.month-nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}
.month-nav-arrow:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }
.month-nav-arrow.is-disabled { opacity: 0.25; pointer-events: none; }

/* Selettore mese (HTML5 details): titolo cliccabile -> popup lista mesi. */
.month-picker {
  position: relative;
}
.month-picker > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.month-picker > summary:hover { background: var(--accent-soft); }
.month-picker > summary::-webkit-details-marker { display: none; }
.month-picker[open] > summary { background: var(--accent-soft); }
.month-picker-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.month-picker-list a {
  display: block;
  padding: 7px 12px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.month-picker-list a:hover { background: var(--accent-soft); text-decoration: none; }
.month-picker-list a.is-current { background: var(--accent); color: #fff; font-weight: 600; }
.month-picker-list a.is-current:hover { background: var(--accent-dark); }

/* ======== Cards ======== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.card--table { padding: 0; overflow: hidden; }
.card h2 { font-size: 17px; margin: 0 0 14px; }
.card h3.cat-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 18px 0 8px;
}

/* ======== Forms ======== */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.form-inline .form-row { margin-bottom: 0; }
.form-inline .form-row--narrow { flex: 0 0 180px; }
.form-inline .form-row--grow { flex: 1 1 320px; }

.input,
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,91,120,.18);
}

/* ======== Buttons ======== */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background .15s, border-color .15s, transform .05s;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; font-weight: 600; }
.btn-block { display: block; width: 100%; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; }

.btn-secondary { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); text-decoration: none; }

.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-danger:hover { background: #c92929; border-color: #c92929; text-decoration: none; }

.inline-form { display: inline-block; margin: 0; }

/* ======== Icon buttons (32×32 chip-style) ======== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  vertical-align: middle;
}
.icon-btn:hover { text-decoration: none; }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn--primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.icon-btn--primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.icon-btn--secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.icon-btn--secondary:hover {
  background: var(--accent);
  color: #fff;
}

.icon-btn--danger {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err);
  font-size: 14px;
}
.icon-btn--danger:hover {
  background: var(--err);
  color: #fff;
}

.col-actions-inline { white-space: nowrap; text-align: right; }
.col-actions-inline .icon-btn + .inline-form { margin-left: 4px; }
.col-actions-inline .inline-form + .icon-btn { margin-left: 4px; }

/* "In pari" status (importo da incassare = 0) */
.status--neutral { background: #eef0f4; color: #4a4a5c; }
/* "A credito" status (importo da incassare < 0) */
.status--credit { background: var(--ok-soft); color: #166c43; }

/* ======== Auth card ======== */
.auth-card {
  max-width: 380px;
  margin: 60px auto;
  padding: 32px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-title { font-size: 22px; margin: 0 0 6px; }

/* ======== Data table ======== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f0f4;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .col-num { text-align: right; white-space: nowrap; }
.data-table .col-total { background: var(--accent-soft); }
.data-table .col-total strong { color: var(--accent); font-size: 15px; }
.data-table .col-status { white-space: nowrap; }
.data-table .col-actions { white-space: nowrap; text-align: right; }
.data-table .col-actions .btn-sm + .inline-form { margin-left: 6px; }
.data-table .col-name a { font-weight: 600; color: var(--ink); }
.data-table .col-name a:hover { color: var(--accent); }

.data-table tr.is-collected td { opacity: .85; }
.data-table tr.is-collected .col-total { background: var(--ok-soft); }
.data-table tr.is-collected .col-total strong { color: #166c43; }

.muted-num { color: var(--ink-2); }

/* ======== Status pills ======== */
.status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status--ok { background: var(--ok-soft); color: #166c43; }
.status--pending { background: var(--warn-soft); color: #8a5a07; }

/* ======== Summary card (pt_detail) ======== */
.summary-card { padding: 18px 22px; }
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}
.summary-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 0;
  min-width: 110px;
}
.summary-cell--total {
  padding: 10px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  flex: 1.3 1 130px;
}
.summary-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.summary-val { font-size: 20px; }
.summary-cell--total .summary-val strong { color: var(--accent); font-size: 24px; }

/* ======== Flash messages ======== */
.flashes { margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid transparent;
}
.flash--success { background: var(--ok-soft); color: #166c43; border-color: #c4e9d4; }
.flash--info { background: var(--info-soft); color: #234d8a; border-color: #c4d8f3; }
.flash--warning { background: var(--warn-soft); color: #8a5a07; border-color: #f4d9a3; }
.flash--danger { background: var(--err-soft); color: #962525; border-color: #f4caca; }
.flash--message { background: var(--info-soft); color: #234d8a; border-color: #c4d8f3; }

.link-muted { font-size: 13px; color: var(--muted); }
.link-muted:hover { color: var(--accent); }

/* ======== Footer ======== */
.footer {
  text-align: center;
  padding: 22px 16px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
  display: flex;
  justify-content: center;
  gap: 14px;
}

/* ======== Mobile accordion (deductions) ======== */
.entries-mobile { display: none; }
.entries-mobile__group { padding: 12px 14px 4px; }
.entries-mobile__group + .entries-mobile__group { border-top: 1px solid var(--border); }
.entries-mobile .cat-heading { margin: 6px 0 10px; }

.entry-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.entry-row > summary { list-style: none; cursor: pointer; }
.entry-row > summary::-webkit-details-marker { display: none; }

.entry-row__summary {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 0;
}
.entry-row__bar {
  display: block;
  width: 4px;
  align-self: stretch;
  background: var(--accent);
}
.entry-row--lezioni .entry-row__bar { background: #c97a3b; }
.entry-row--commissioni .entry-row__bar { background: #2c6ecb; }
.entry-row--altro .entry-row__bar { background: var(--accent); }
.entry-row--riporto .entry-row__bar { background: #2ba26a; }
.entry-row--recensioni .entry-row__bar { background: #c95b8b; }

.entry-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entry-row__top {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-row__period {
  font-size: 12px;
  color: var(--muted);
}
.entry-row__right {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.entry-row__amount {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-2);
}
.entry-row__chev {
  color: var(--muted);
  transition: transform .2s;
}
details[open] > summary .entry-row__chev { transform: rotate(180deg); }

.entry-row__expanded {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.entry-row__expanded__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-pill--edit {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-pill--edit:hover { background: var(--accent); color: #fff; text-decoration: none; }
.btn-pill--delete {
  background: var(--err-soft);
  color: var(--err);
  border-color: var(--err);
}
.btn-pill--delete:hover { background: var(--err); color: #fff; }

/* ======== Mobile dashboard cards ======== */
.dashboard-mobile { display: none; }

.pt-card {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.pt-card:last-child { border-bottom: none; }
.pt-card.is-collected { background: var(--ok-soft); }
.pt-card__main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.pt-card__main:hover { text-decoration: none; }
.pt-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.pt-card__name {
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-card__amount {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  white-space: nowrap;
}
.pt-card.is-collected .pt-card__amount { color: #166c43; }
.pt-card__row--meta { font-size: 13px; }
.pt-card__pay {
  flex: 0 0 auto;
  align-self: center;
}

/* ======== Mobile breakpoint ======== */
@media (max-width: 768px) {
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .brand img { height: 32px; }
  .brand .subtitle { font-size: 10px; letter-spacing: 1px; }
  .topnav { gap: 6px; }
  .topnav-link { padding: 6px 10px; font-size: 13px; }
  .topnav-user { display: none; }

  .container { padding: 0 10px; margin: 14px auto 20px; }
  .container--wide { max-width: 100%; }
  .page-head h1 { font-size: 17px; }

  .month-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .month-title { font-size: 17px; min-width: 0; flex: 1 1 100%; order: -2; text-align: center; margin: 0 0 4px; }
  .month-bar > .btn-secondary { flex: 1 1 0; }
  .month-today { margin-left: 0; flex: 1 1 100%; order: 10; }
  .month-bar form { flex: 1 1 100%; order: 11; margin: 0; }
  .month-bar form .btn { width: 100%; }

  .card { padding: 14px; margin: 12px 0; border-radius: 8px; }
  .card--table { padding: 0; }
  .summary-card { padding: 12px; }

  .summary-row { flex-direction: row; flex-wrap: wrap; gap: 10px; align-items: stretch; }
  /* 2 colonne in griglia compatta: Fee base e Da incassare in alto, Stato e Pagamento in basso. Nascondo i 5 dettagli detrazioni (gia' visibili sotto nella tabella). */
  .summary-row > .summary-cell { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .summary-cell--detr { display: none; }
  .summary-cell--total { padding: 10px 12px; flex: 1 1 calc(50% - 5px); }
  .summary-cell--total .summary-val strong { font-size: 20px; }
  .summary-val { font-size: 17px; }

  .form-inline { flex-direction: column; align-items: stretch; gap: 10px; }
  .form-inline .form-row--narrow,
  .form-inline .form-row--grow { flex: 1 1 auto; }
  .form-inline .btn { width: 100%; }

  .data-table { display: none; }
  .entries-mobile { display: block; }
  .dashboard-mobile { display: block; }

  .icon-btn { width: 40px; height: 40px; font-size: 18px; }

  /* Login card: full width */
  .auth-card { margin: 24px 12px; padding: 24px; max-width: none; }

  /* Pagine generiche: page-head allineato sx senza margini */
  .page-head { margin: 4px 0 14px; }

  .wzp-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .wzp-toolbar__actions { display: flex; gap: 6px; }
  .wzp-toolbar__actions .btn { flex: 1 1 0; }
  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions .btn { width: 100%; }
}

/* ======== WZP selezione destinatari ======== */
.wzp-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.wzp-toolbar__actions { display: flex; gap: 6px; }

.wzp-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  border-top: 1px solid var(--border);
}
.wzp-list__item {
  border-bottom: 1px solid var(--border);
}
.wzp-list__item label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  cursor: pointer;
  user-select: none;
}
.wzp-list__item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.wzp-list__name { flex: 1 1 auto; font-weight: 600; }
.wzp-list__phone { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ Commissions ============ */
.commissions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (max-width: 900px) {
  .commissions-grid { grid-template-columns: 1fr; }
}
.commissions-card { padding-bottom: 12px; }
.commissions-form {
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--border, #e2e2e2);
  margin-bottom: 8px;
}
.scaglione-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 13px;
}
.scaglione-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
}
.scaglione-save svg {
  display: block;
}
.scaglione-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted, #6a7280);
  font-weight: 600;
}
.scaglione-row .input {
  width: 80px;
  padding: 6px 8px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.scaglione-row--readonly .scaglione-label {
  gap: 4px;
  font-weight: 600;
}
.scaglione-row--readonly .scaglione-label strong {
  color: var(--text, #111);
  font-variant-numeric: tabular-nums;
}
/* Override del font-size enorme di .kpi-table tbody td (32px di default,
   pensato per la card Business della pagina rinnovi). Qui le righe sono
   3-4 e devono restare compatte. */
.commissions-table tbody td {
  font-size: 14px !important;
  padding: 7px 10px !important;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.commissions-table thead th {
  font-size: 12px !important;
  padding: 8px 10px 6px !important;
}
.commissions-table tfoot td {
  border-top: 1px solid var(--border, #e2e2e2);
  font-weight: 700;
  padding: 9px 10px !important;
  font-variant-numeric: tabular-nums;
}
.commissions-table .card-total-label {
  text-align: right;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted, #6a7280);
  font-weight: 600;
}
.commissions-table .card-total {
  font-size: 15px;
  color: var(--brand, #76092d);
}
.target-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 16px 10px;
  font-size: 13px;
  gap: 8px;
}
.target-row .target-label {
  color: var(--muted, #6a7280);
  font-weight: 600;
}
.target-row .target-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.target-row .target-pct {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}
.target-row .target-pct.is-pos {
  background: #e6f4ea;
  color: #14532d;
}
.target-row .target-pct.is-neg {
  background: #fde8e8;
  color: #7f1d1d;
}
.target-row--spacer {
  visibility: hidden;
  /* mantiene la stessa altezza della riga obiettivo nelle altre card */
}

/* ─────────────────────────────────────────────────────────────────
   ANALYTICS-EVOLUTION — overrides
   ───────────────────────────────────────────────────────────────── */

.container--wide {
  max-width: none;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  margin: 16px 0 4px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.subtle-h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 24px 0 10px;
  font-weight: 700;
}

.dash-section {
  margin: 28px 0 36px;
}

/* ── Filters bar ─────────────────────────────────── */

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 12px 0 18px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.filter-group label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.filter-group--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.filter-group--checkbox label {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink-2);
  font-size: 14px;
}

/* ── KPI row ─────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 16px 0 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  margin-top: 6px;
  line-height: 1.05;
}

/* ── Heatmaps ────────────────────────────────────── */

.heatmap-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.heatmap-row--quad {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

@media (max-width: 900px) {
  .heatmap-row,
  .heatmap-row--quad {
    grid-template-columns: 1fr;
  }
}

.heatmap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.heatmap-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--brand);
  margin-bottom: 8px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  gap: 2px;
  font-size: 10px;
}

.heatmap-cell {
  padding: 4px 0;
  text-align: center;
  border-radius: 3px;
  min-height: 18px;
  line-height: 1.1;
}

.heatmap-corner {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.heatmap-header {
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
}

.heatmap-rowhead {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}

.heatmap-val {
  background: rgba(0,0,0,0);
  font-weight: 600;
  color: var(--ink);
}

/* Palette per i 3 tipi di heatmap.
   --ratio = 0..1 → intensita' del colore (alpha sul base). */
.heatmap--arrivals .heatmap-val {
  background: rgba(43, 162, 106, calc(var(--ratio) * 0.85));
  color: var(--ink);
}
.heatmap--arrivals .heatmap-val[data-count="0"] { background: rgba(43, 162, 106, 0); }

.heatmap--classes .heatmap-val {
  background: rgba(118, 9, 45, calc(var(--ratio) * 0.78));
  color: var(--ink);
}
.heatmap--classes .heatmap-val[style*="--ratio: 0.6"],
.heatmap--classes .heatmap-val[style*="--ratio: 0.7"],
.heatmap--classes .heatmap-val[style*="--ratio: 0.8"],
.heatmap--classes .heatmap-val[style*="--ratio: 0.9"],
.heatmap--classes .heatmap-val[style*="--ratio: 1.0"] {
  color: #fff;
}

.heatmap--bracket .heatmap-val {
  background: rgba(43, 162, 106, calc(var(--ratio) * 0.78));
  color: var(--ink);
}

/* ── Power matrix istruttori ─────────────────────── */

.data-table--power .cell--matrix {
  background: rgba(118, 9, 45, calc(var(--ratio) * 0.4));
  font-weight: 600;
}

/* ── Fill bar (classes index) ────────────────────── */

.fill-bar {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  background: linear-gradient(
    to right,
    var(--brand-soft) calc(var(--fill) * 100%),
    var(--surface-2) calc(var(--fill) * 100%)
  );
  border: 1px solid var(--border);
}

/* ── Horizontal bar (class distribution) ─────────── */

.hbar {
  height: 8px;
  background: var(--brand);
  border-radius: 4px;
  width: calc(var(--pct) * 100%);
  min-width: 2px;
}

.hbar-multi {
  display: flex;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 220px;
}

.hbar-seg {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--pct) * 100%);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.hbar-seg--18-29   { background: #5e60ce; }
.hbar-seg--30-44   { background: #d65d8a; }
.hbar-seg--45-59   { background: #e89000; }
.hbar-seg--over60  { background: #64748b; }

.hbar--18-29   { background: #5e60ce; }
.hbar--30-44   { background: #d65d8a; }
.hbar--45-59   { background: #e89000; }
.hbar--over60  { background: #64748b; }
.hbar--unknown { background: var(--surface-2); }

/* ── Badges ───────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
  margin: 2px 4px 2px 0;
  white-space: nowrap;
}

.badge--ghost {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.badge--warn {
  background: var(--warn-soft);
  color: #8a5400;
}

.badge--top {
  background: var(--ok-soft);
  color: #166c43;
}

.badge--flop {
  background: var(--err-soft);
  color: #962525;
}

.badge--ok {
  background: var(--info-soft);
  color: #234a85;
}

.badge--unknown {
  background: var(--surface-2);
  color: var(--muted);
}

.slot-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin: 2px 0;
}

.slot-classes .muted.small {
  font-size: 11px;
  margin-right: 4px;
}

/* ── Row verdetto coloring (classes index) ────────── */

.row-verdict-top    { background: rgba(43, 162, 106, 0.06); }
.row-verdict-flop   { background: rgba(229, 62, 62, 0.06); }
.row-verdict-unknown td:first-child { color: var(--muted); }

/* ── Data tables generic ─────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table--mapping td:nth-child(n+3) {
  text-align: center;
}

/* ── Forms aux ───────────────────────────────────── */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 640px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.inline { display: inline; }

.btn-mini--danger {
  border-color: var(--err);
  color: var(--err);
}
.btn-mini--danger:hover { background: var(--err-soft); }


/* ─────────────────────────────────────────────────────────────────
   ANALYTICS-EVOLUTION — Iteration 2 additions
   ───────────────────────────────────────────────────────────────── */

/* Layout dashboard 2 colonne quando c'e' slot focus */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}
.dash-grid:has(.dash-grid__side) {
  grid-template-columns: minmax(0, 1fr) 360px;
}
@media (max-width: 1100px) {
  .dash-grid:has(.dash-grid__side) {
    grid-template-columns: 1fr;
  }
}

/* Heatmap clickable */
.heatmap--clickable .heatmap-val { cursor: pointer; }
.heatmap-cell--link {
  text-decoration: none;
  color: inherit;
}
.heatmap-cell--link:hover {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  filter: brightness(1.05);
}
.heatmap-cell--focus {
  outline: 3px solid var(--brand-dark) !important;
  outline-offset: -1px;
  z-index: 1;
}

/* Side panel (slot detail) */
.side-panel {
  position: sticky;
  top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}
.side-panel__title {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 18px;
  font-weight: 800;
}
.side-panel__close {
  float: right;
  text-decoration: none;
}
.side-panel__close:hover { color: var(--err); }
.side-panel__kpi {
  margin: 14px 0 18px;
  padding: 10px 12px;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--brand);
}
.side-panel__kpi .kpi-value {
  font-size: 26px;
  color: var(--brand);
}

/* Bracket bars (slot panel) */
.bracket-bars { list-style: none; padding: 0; margin: 0 0 16px; }
.bracket-bars__item {
  display: grid;
  grid-template-columns: 64px 1fr 96px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
}
.bracket-bars__label { font-weight: 700; }
.bracket-bars__track {
  height: 12px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bracket-bars__fill {
  height: 100%;
  width: calc(var(--pct) * 100%);
}
.bracket-bars__fill--18-29   { background: #5e60ce; }
.bracket-bars__fill--30-44   { background: #d65d8a; }
.bracket-bars__fill--45-59   { background: #e89000; }
.bracket-bars__fill--over60  { background: #64748b; }
.bracket-bars__val { text-align: right; }

/* Slot classes list */
.slot-classes-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 12px;
}
.slot-classes-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.slot-classes-list li:last-child { border-bottom: none; }

/* Top corsi per fascia (4 mini-card) */
.bracket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.bracket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.bracket-card__title {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--brand);
  font-weight: 800;
}
.bracket-card__list {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
}
.bracket-card__list li { padding: 3px 0; }

/* KPI foot description */
.kpi-foot { margin-top: 4px; line-height: 1.2; }

/* Generic .small */
.small { font-size: 11px; }


/* ─────────────────────────────────────────────────────────────────
   ANALYTICS-EVOLUTION — Iteration 3 additions
   ───────────────────────────────────────────────────────────────── */

/* Tabella ore × fasce (overview Iter 3) */
.data-table--hxb th,
.data-table--hxb td {
  font-size: 12.5px;
  padding: 6px 10px;
}
.data-table--hxb td:first-child { font-weight: 700; }
.data-table--hxb .hxb-bar-col { min-width: 240px; width: 30%; }
.data-table--hxb .hxb-bar-cell { padding: 6px 8px; }
.data-table--hxb .hxb-bar-cell .hbar-multi {
  min-width: 0;
  width: 100%;
  height: 16px;
}

/* Tabella slot del corso (drill-down /classes/<name>) */
.data-table--slots .hbar-multi,
.data-table--slot-coaches .hbar-multi {
  min-width: 200px;
  width: 100%;
  height: 18px;
}
.data-table--slots tr.row--focus,
.data-table--slot-coaches tr.row--focus {
  background: var(--brand-soft);
}
.data-table--slots tr.row--focus td:first-child {
  border-left: 3px solid var(--brand);
}

/* Box "Spostamento suggerito" istruttore */
.move-suggestion {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: linear-gradient(180deg, var(--brand-soft), var(--surface));
  border: 1px solid var(--brand);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0 22px;
}
.move-suggestion__icon {
  font-size: 26px;
  color: var(--brand);
}
.move-suggestion__title {
  font-weight: 800;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 13px;
  margin-bottom: 4px;
}
.move-suggestion p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* Pagina alignment */
.alignment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.alignment-card--good       { border-left-color: var(--ok); }
.alignment-card--partial    { border-left-color: var(--warn); }
.alignment-card--misaligned { border-left-color: var(--err); }
.alignment-card--no_class   { border-left-color: var(--muted); }

.alignment-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.alignment-card__head h2 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alignment-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 18px;
}
@media (max-width: 1000px) {
  .alignment-card__body { grid-template-columns: 1fr; }
}
.bullet-list { margin: 4px 0; padding-left: 20px; font-size: 13px; }
.bullet-list li { padding: 2px 0; }

/* badge verdetti */
.badge--good       { background: var(--ok-soft);  color: #166c43; }
.badge--partial    { background: var(--warn-soft); color: #8a5400; }
.badge--misaligned { background: var(--err-soft); color: #962525; }
.badge--no_class   { background: var(--surface-2); color: var(--muted); }


/* Bracket legend (proposals/class-targets) */
.bracket-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 12px 0 18px;
  align-items: center;
  font-size: 13px;
}
.bracket-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bracket-legend__swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08);
}
.bracket-legend__swatch--18-29   { background: #5e60ce; }
.bracket-legend__swatch--30-44   { background: #d65d8a; }
.bracket-legend__swatch--45-59   { background: #e89000; }
.bracket-legend__swatch--over60  { background: #64748b; }

/* Badge per fasce d'eta' — colori coerenti con legenda + bracket-bars */
.badge--bracket-18-29  { background: rgba(94, 96, 206, 0.16);  color: #3a3c8a; }
.badge--bracket-30-44  { background: rgba(214, 93, 138, 0.18); color: #8e2c5b; }
.badge--bracket-45-59  { background: rgba(232, 144, 0, 0.18);  color: #8a5400; }
.badge--bracket-over60 { background: rgba(100, 116, 139, 0.16); color: #334155; }

/* Filtri sticky allineati a destra + dropdown range (Iter 3) */
.filters-bar--right {
  justify-content: flex-end;
}
.filter-group select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  min-width: 160px;
}
.filter-custom-dates {
  display: flex;
  gap: 14px;
  align-items: end;
}
