/* ---------------------------------------------------------
   17. Fase 2 components: info-card, filter-bar, fascicolo
   (pure CSS, reuses the existing design tokens)
   --------------------------------------------------------- */

/* Generic content panel (used by formazione riepilogo, sorveglianza
   idoneità card, dettaglio sections). */
.info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-5);
}

.info-card h2 {
  font-size: var(--text-lg);
  margin: 0 0 var(--sp-3);
}

.info-card p { margin: 0 0 var(--sp-2); }
.info-card p:last-child { margin-bottom: 0; }

/* Small action groups inside existing form/filter surfaces. */
.filter-bar__actions {
  display: flex;
  align-items: end;
  gap: var(--sp-2);
}
.form-card__details {
  margin-top: var(--sp-3);
}

.qr-label {
  max-width: 26rem;
  text-align: center;
}
.qr-label svg {
  display: block;
  width: min(100%, 18rem);
  height: auto;
  margin: var(--sp-3) auto var(--sp-4);
  image-rendering: pixelated;
}
.qr-label .hint {
  overflow-wrap: anywhere;
  text-align: left;
}

/* Area landings: the section nav owns navigation. This compact overview
   communicates current context without reproducing it as a second card menu. */
.area-overview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  margin: var(--sp-5) 0;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.area-overview__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.area-overview__facts strong {
  font-size: var(--text-sm);
}
.area-overview__facts span,
.area-overview > p:last-child {
  color: var(--color-text-muted);
}

.workspace-context { margin: 0 0 var(--sp-4); }
.workspace-attention { margin: 0 0 var(--sp-5); padding: var(--sp-4) 0 0; border-top: 2px solid var(--color-border-strong); border-bottom: 1px solid var(--color-border); }
.workspace-attention h2 { margin: 0 0 var(--sp-3); font-size: var(--text-lg); }
.workspace-attention ul { display: grid; grid-template-columns: 1fr; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--color-border); }
.workspace-attention li + li { border-top: 1px solid var(--color-border); }
.workspace-signal { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) 1rem; gap: var(--sp-3); align-items: start; min-height: 5.5rem; padding: var(--sp-4); color: var(--color-text); text-decoration: none; }
.workspace-signal:hover { color: var(--accent-ink); }
.workspace-signal:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: -2px; }
.workspace-signal::after { content: ""; width: 0.45rem; height: 0.45rem; margin-top: 0.55rem; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); }
.workspace-signal__count { min-width: 2.75rem; padding-top: 0.1rem; color: var(--accent-ink); font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-xl); font-weight: 650; line-height: 1.25; text-align: right; }
.workspace-signal--warn .workspace-signal__count { color: var(--st-warn); }
.workspace-signal--bad .workspace-signal__count { color: var(--st-bad); }
.workspace-signal__content { display: grid; gap: 2px; min-width: 0; }
.workspace-signal__content strong { line-height: 1.35; }
.workspace-signal small { color: var(--color-text-muted); font-size: var(--text-xs); }
@media (min-width: 640px) {
  .workspace-attention ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-attention li { border-top: 0; }
  .workspace-attention li:nth-child(even) { border-left: 1px solid var(--color-border); }
  .workspace-attention li:nth-child(n + 3) { border-top: 1px solid var(--color-border); }
}
@media (min-width: 1000px) {
  .workspace-attention ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace-attention li:nth-child(n) { border-top: 0; border-left: 1px solid var(--color-border); }
  .workspace-attention li:first-child { border-left: 0; }
  .workspace-attention li:nth-child(n + 4) { border-top: 1px solid var(--color-border); }
}
.area-overview > p:last-child {
  max-width: 38rem;
  margin: 0;
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------
   UI v3 Fase 0 — shared page-anatomy primitives (docs/ui/UI_V3_PLAN.md L3-L6).
   Consumers migrate in Fase 2; these ship the CSS contract now.
   --------------------------------------------------------- */

/* Filter/search toolbar (web/components.py filter_toolbar(), L5) — one
   compact, transparent row (NOT a card, unlike the older .filter-bar
   below): inline small labels, low 2rem fields, hairline bottom rule. */
.toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border);
  background: transparent;
}
.toolbar label {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.66rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.toolbar input,
.toolbar select {
  min-height: 2rem;
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}
.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--accent-fill);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toolbar__submit {
  align-self: flex-end;
}

/* Compact stat strip (web/components.py kpi_strip(), §6-ter) — a headline
   row of counts with hairline separators, no card boxes. Lighter-weight
   than .kpi-cards for area-landing summaries. */
.stat-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
  margin: 0 0 var(--sp-4);
}
.stat-strip__item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  border-left: 1px solid var(--color-border);
  color: inherit;
  text-decoration: none;
}
.stat-strip__item:first-child {
  padding-left: 0;
  border-left: none;
}
a.stat-strip__item:focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.stat-strip__label {
  font-size: 0.66rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.stat-strip__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-lg);
  font-weight: 650;
  color: var(--color-text);
}
a.stat-strip__item:hover .stat-strip__value,
a.stat-strip__item:focus-visible .stat-strip__value {
  color: var(--accent-ink);
}
.stat-strip__item--ok .stat-strip__value   { color: var(--st-ok); }
.stat-strip__item--warn .stat-strip__value { color: var(--st-warn); }
.stat-strip__item--bad .stat-strip__value  { color: var(--st-bad); }

/* Callout (web/components.py callout()) — compact inline "next step" hint,
   not a status chip: surface-2 fill, no border, optional right-aligned
   action. */
.callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--color-surface-2);
  border-radius: var(--radius);
  font-size: var(--text-sm);
}
.callout__text {
  margin: 0;
  color: var(--color-text);
}
.callout__action {
  flex-shrink: 0;
}
.callout--ok .callout__text   { color: var(--st-ok); }
.callout--warn .callout__text { color: var(--st-warn); }
.callout--bad .callout__text  { color: var(--st-bad); }

/* Compact module-settings row (Fase 2/L10 consumer: app/impostazioni.py).
   Name + short description on the left, controls on the right, hairline
   separators between rows instead of a per-module card box. No consumer
   yet in Fase 0 — CSS contract only. */
.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.module-row:last-child {
  border-bottom: none;
}
.module-row__main {
  /* Cap the text block so long descriptions don't push the controls onto a
     left-aligned wrap line: the controls keep right alignment either way. */
  flex: 1 1 30rem;
  min-width: 16rem;
  max-width: 46rem;
}
.module-row__name {
  font-weight: 650;
  color: var(--color-text);
}
.module-row__desc {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.module-row__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  margin-left: auto;
}

/* Active-filter indicator bar (formazione/scadenzario overviews). */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.export-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
}

.filter-bar-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  width: 100%;
}

.filter-select,
.filter-search {
  min-width: 11rem;
  max-width: 100%;
  min-height: 2.5rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.filter-select:hover:not(:focus),
.filter-search:hover:not(:focus) {
  border-color: color-mix(in srgb, var(--color-border) 60%, var(--color-text));
}

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1rem;
}

.filter-search {
  min-width: min(100%, 18rem);
}

.filter-search:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent-fill);
  box-shadow: var(--shadow-focus);
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(14rem, 18rem) auto;
  gap: var(--sp-3);
  align-items: end;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.list-toolbar__field {
  display: grid;
  gap: var(--sp-1);
}

.list-toolbar__field label {
  color: var(--color-text-muted);
  font-size: 0.66rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.list-toolbar__field input,
.list-toolbar__field select {
  width: 100%;
  min-height: 2.5rem;
  font-size: var(--text-sm);
}

.list-toolbar__field input:hover:not(:focus),
.list-toolbar__field select:hover:not(:focus) {
  border-color: color-mix(in srgb, var(--color-border) 60%, var(--color-text));
}

.list-toolbar__field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1rem;
}

.list-toolbar__actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.split-workbench {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
  align-items: start;
  margin-bottom: var(--sp-6);
}

.split-workbench__pane {
  min-width: 0;
}

.split-workbench__pane--surface {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.split-workbench__pane--sticky {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-3));
}

.split-workbench__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.split-workbench__title {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.25;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(10rem, 1fr));
  gap: var(--sp-3);
  align-items: start;
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}

.calendar-day {
  min-height: 12rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-3);
}

.calendar-day h3 {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: 0 0 var(--sp-3);
  font-size: var(--text-sm);
}

.calendar-day h3 span {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

/* Row actions menu — progressive enhancement keeps the inline actions usable
   without JS; JS only moves secondary actions into this floating menu. */
.row-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.row-actions__primary,
.row-actions__secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.row-actions__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 var(--sp-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.row-actions__toggle:hover,
.row-actions__toggle:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.row-actions__toggle:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.row-actions__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + var(--sp-1));
  right: 0;
  min-width: 10rem;
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-pop);
}

.row-actions__menu.is-fixed {
  position: fixed;
  top: auto;
  right: auto;
  left: auto;
  z-index: 1000;
}

.row-actions__menu[hidden] {
  display: none;
}

.row-actions__menu a,
.row-actions__menu button {
  width: 100%;
  justify-content: flex-start;
}

.row-actions__menu a:hover,
.row-actions__menu button:hover,
.row-actions__menu a:focus-visible,
.row-actions__menu button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.row-actions__menu .btn-danger {
  color: var(--color-danger);
  border-color: var(--color-border-strong);
}

.calendar-event {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  font-size: var(--text-sm);
}

.calendar-event + .calendar-event {
  margin-top: var(--sp-2);
}

.calendar-event span {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.choice-grid,
.choice-list,
.info-grid {
  display: grid;
  gap: var(--sp-3);
}

.choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

.info-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.choice-card,
.choice-row,
.preview-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.choice-card,
.choice-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}

.choice-card:hover,
.choice-row:hover,
.choice-card:focus-within,
.choice-row:focus-within {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
}

.choice-card input,
.choice-row input {
  margin-top: 0.2rem;
}

.choice-card span,
.choice-row span {
  display: grid;
  gap: var(--sp-1);
  min-width: 0;
}

.choice-card small,
.choice-row small {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.choice-row {
  align-items: center;
  justify-content: space-between;
}

.choice-row span {
  margin-right: auto;
}

.preview-block {
  padding: var(--sp-3);
}

.preview-block h2 {
  margin: 0 0 var(--sp-2);
  font-size: var(--text-base);
}

.preview-block ul {
  margin: 0;
  padding-left: var(--sp-4);
}

/* Wrap the whole li, not just the <code> key: the plain-text value after the
   arrow is a comma-joined list with no spaces and overflows 390px otherwise. */
.palestra-config-preview li {
  overflow-wrap: anywhere;
}

.vertical-config-preview li {
  display: grid;
  gap: var(--sp-1);
  overflow-wrap: anywhere;
}

.vertical-config-preview li + li {
  margin-top: var(--sp-2);
}

.vertical-config-preview li span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.vertical-config-preview__module {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.is-density-compact .calendar-week {
  gap: var(--sp-2);
}

.is-density-compact .calendar-day {
  padding: var(--sp-2);
}

.is-density-compact .calendar-event {
  padding: var(--sp-1) var(--sp-2);
}

@media (max-width: 760px) {
  .list-toolbar {
    grid-template-columns: 1fr;
  }

  .list-toolbar__actions {
    justify-content: stretch;
  }

  .list-toolbar__actions .btn {
    flex: 1 1 10rem;
  }
}

@media (min-width: 1024px) {
  .split-workbench {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem);
  }

  .split-workbench--balanced {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.import-summary__item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  display: grid;
  gap: var(--sp-1);
}
.import-summary__item span {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.import-summary__item strong {
  font-size: var(--text-2xl);
  line-height: 1;
}
.import-summary__item--ok strong { color: var(--st-ok); }
.import-summary__item--error strong { color: var(--st-bad); }

.import-mapping-summary,
.import-issues {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.import-mapping-summary summary {
  cursor: pointer;
  font-weight: 600;
}
.import-mapping-summary ul,
.import-issues ul {
  display: grid;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
  margin: var(--sp-3) 0 0;
}
.import-mapping-summary li,
.import-issues li {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--sp-2);
}
.import-mapping-summary li:last-child,
.import-issues li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.import-issues h2 {
  font-size: var(--text-base);
  margin-bottom: var(--sp-2);
}
.import-issues .btn {
  margin-top: var(--sp-3);
}

/* Fascicolo del dipendente: hub panel on the worker page. */
.fascicolo h2 {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.fascicolo__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.fascicolo-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.fascicolo-links__primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  position: relative;
}

.fascicolo-links__info {
  margin-left: 0;
  position: relative;
}

.fascicolo-links__info > summary {
  width: 1.35rem;
  height: 1.35rem;
  font-size: var(--text-xs);
}

.fascicolo-links__info .info__body {
  position: absolute;
  z-index: 30;
  left: 0;
  top: calc(100% + var(--sp-2));
  width: min(20rem, calc(100vw - 2rem));
  margin-top: 0;
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* Fascicolo section heading row: title + inline "?" help marker on one line. */
.fascicolo-section { margin-top: var(--sp-5); }
.fascicolo-section__head {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: var(--sp-3);
}
.fascicolo-section__head h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}

/* The fascicolo blocco banner reuses .flash--error/--warning; tighten its
   list so motivi read as a compact bullet list. */
.fascicolo .flash ul {
  margin: var(--sp-2) 0 0;
  padding-left: var(--sp-5);
}
.fascicolo .flash li { margin: 0; }

.fascicolo-summary,
.fascicolo-modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.fascicolo-card,
.fascicolo-module {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: var(--sp-3);
}

.fascicolo-card {
  display: grid;
  gap: var(--sp-1);
}

.fascicolo-card__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.fascicolo-card span:not(.badge) {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.fascicolo-card__link {
  font-size: var(--text-sm);
  justify-self: start;
}

.fascicolo-module {
  display: grid;
  gap: var(--sp-1);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--ease),
              background var(--motion-fast) var(--ease),
              box-shadow var(--motion-fast) var(--ease),
              transform var(--motion-fast) var(--ease);
}
.fascicolo-module:hover {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.fascicolo-module:focus-visible {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
  box-shadow: var(--shadow-focus), var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}
.fascicolo-module strong {
  font-size: var(--text-2xl);
  line-height: 1;
}
.fascicolo-module span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.fascicolo-deadlines {
  border-top: 1px solid var(--color-border);
  padding-top: var(--sp-4);
}
.fascicolo-deadlines h3 {
  font-size: var(--text-base);
  margin-bottom: var(--sp-2);
}
.fascicolo-deadlines ul {
  display: grid;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
  margin: 0;
}
.fascicolo-deadlines li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.fascicolo-deadlines li:last-child { border-bottom: none; }

/* Small inline hint inside a KPI card (e.g. "+N parziali"). */
.kpi-card__hint {
  display: inline-block;
  margin-left: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Portafoglio compliance: one priority workspace, not a second navigation
   menu. The section nav owns navigation; this component only surfaces work
   that exists now and sends the user directly to its source queue. */
.portfolio-priorities {
  display: block;
  margin: var(--sp-5) 0 var(--sp-4);
  padding: var(--sp-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.portfolio-priorities--clear {
  display: block;
}
.portfolio-priorities__heading h2 {
  margin: 0 0 var(--sp-1);
  font-size: var(--text-lg);
}
.portfolio-priorities__heading {
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--color-border);
}
.portfolio-priorities__heading p,
.portfolio-workspace__intro {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.portfolio-priorities ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-3) 0 0;
  padding: 0;
  list-style: none;
}
.portfolio-priorities li {
  min-width: 0;
  padding: 0;
}
.portfolio-priorities li:first-child {
  padding-left: 0;
}
.portfolio-priority {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-2);
  align-items: center;
  min-height: 4.25rem;
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--motion-fast) var(--ease);
}
.portfolio-priority:hover {
  color: var(--accent-ink);
}
.portfolio-priority:focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
}
.portfolio-priority__count {
  min-width: 1.75rem;
  color: var(--st-bad);
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.portfolio-priority__content {
  display: grid;
  gap: 2px;
}
.portfolio-priority__content strong {
  font-size: var(--text-sm);
}
.portfolio-priority__content small {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.3;
}
.portfolio-priority__arrow {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
}
.portfolio-workspace__intro {
  margin-bottom: var(--sp-3);
}
.portfolio-evidence {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.portfolio-evidence a {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.portfolio-evidence a:hover,
.portfolio-evidence a:focus-visible {
  text-decoration: underline;
}
.portfolio-utilities {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.portfolio-utility {
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.portfolio-utility summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 650;
}
.portfolio-utility summary:focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
}
.portfolio-utility__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-3);
}
.portfolio-utility__links a {
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 600;
}
.portfolio-utility .table-wrapper {
  margin-top: var(--sp-4);
}
@media (max-width: 639px) {
  .portfolio-priorities ul {
    grid-template-columns: 1fr;
  }
  .portfolio-priorities li,
  .portfolio-priorities li:first-child {
    padding: 0;
  }
}

/* Struttura organizzativa tree (azienda > sede > reparto). */
.org-tree { list-style: none; padding-left: 0; margin: 0; }
.org-tree ul { list-style: none; margin: var(--sp-1) 0 var(--sp-3) var(--sp-5); padding-left: var(--sp-4); border-left: 2px solid var(--color-border); }
.org-tree li { margin: var(--sp-1) 0; }
.org-tree .org-node__name { font-weight: 600; }
.org-tree .org-node__meta { color: var(--color-text-muted); font-size: var(--text-sm); }

.struttura-azienda {
  display: block;
}
.struttura-azienda__header,
.struttura-azienda__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.struttura-azienda__summary,
.struttura-sede__summary {
  cursor: pointer;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  padding: var(--sp-3);
}
.struttura-azienda__summary:hover,
.struttura-azienda__summary:focus-visible,
.struttura-sede__summary:hover,
.struttura-sede__summary:focus-visible {
  background: var(--color-surface);
}
.struttura-azienda__summary:focus-visible,
.struttura-sede__summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.struttura-azienda__title {
  font-size: var(--text-lg);
  font-weight: 700;
}
.struttura-azienda__body {
  display: grid;
  gap: var(--sp-3);
}
.struttura-azienda__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.struttura-azienda__header h2 { margin: 0; }

.struttura-sede {
  border-top: 1px solid var(--color-border);
  padding: var(--sp-4) 0;
}
.struttura-sede:first-child { border-top: none; padding-top: 0; }
.struttura-sede__header,
.struttura-sede__body,
.struttura-reparto {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
}
.struttura-sede__summary {
  display: block;
  margin-bottom: var(--sp-3);
}
.struttura-sede__body {
  padding-left: var(--sp-3);
}
.struttura-sede__main,
.struttura-reparto__name {
  min-width: 0;
}
.reparto-list {
  display: grid;
  gap: var(--sp-2);
  list-style: none;
  margin: var(--sp-3) 0 0 var(--sp-4);
  padding: 0 0 0 var(--sp-4);
  border-left: 2px solid var(--color-border);
}
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-wrap: nowrap;
}
.row-actions form {
  display: inline-flex;
  margin: 0;
}
.inline-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

@media (max-width: 639px) {
  .struttura-sede__header,
  .struttura-sede__body,
  .struttura-reparto {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .struttura-azienda__actions {
    justify-content: flex-start;
  }
  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------
   Confirm dialog — native <dialog> built by static/app.js
   initConfirmDialog() (docs/ui/DESIGN_CONTRACT.md §4). Replaces
   window.confirm() for destructive submits ("/elimina" forms and
   form[data-confirm]); no-JS forms just submit directly.
   --------------------------------------------------------- */
.confirm-dialog {
  /* The global `* { margin: 0 }` reset (base.css) wipes the UA's
     `margin: auto` that centers a native <dialog> — restore it. */
  margin: auto;
  padding: var(--sp-5);
  width: min(26rem, calc(100vw - var(--sp-6)));
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.confirm-dialog::backdrop {
  background: var(--overlay-backdrop);
}

.confirm-dialog__title {
  margin-bottom: var(--sp-3);
  font-size: 1.15rem;
}

.confirm-dialog__body {
  color: var(--color-text-muted);
  line-height: 1.5;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

/* ---------------------------------------------------------
   Toast — bottom-center, theme-inverted (docs/ui/DESIGN_CONTRACT.md §2/§4).
   Progressive enhancement of the server-rendered .flash-region (static/app.js
   initToast()); the flash markup itself stays the no-JS fallback.
   --------------------------------------------------------- */
/* When initToast() promotes the flash messages to toasts it hides the
   source region via [hidden]; the author `display: flex` on .flash-region
   (layout.css) would otherwise beat the UA's [hidden] { display: none }. */
.flash-region[hidden] {
  display: none;
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  transform: translateX(-50%);
  width: min(28rem, calc(100vw - var(--sp-6)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(.5rem);
  transition: opacity var(--motion-slow) var(--ease),
    transform var(--motion-slow) var(--ease);
  /* Theme-inverted per §2: light theme -> ink surface; dark theme -> paper
     surface. Both defined in tokens.css as --toast-bg / --toast-text /
     --toast-link so this partial stays literal-color-free. */
  background: var(--toast-bg);
  color: var(--toast-text);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-leaving {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

.toast__text {
  flex: 1;
  font-size: var(--text-sm);
}

/* The embedded "Annulla" undo form (web/components.py undo_action()) reads
   as a bold inline link inside the toast, not a full-width form control. */
.toast__action,
.toast .flash__undo {
  display: inline-flex;
  margin: 0;
}

.toast .flash__undo-btn {
  padding: 0;
  min-height: 0;
  background: none;
  border: none;
  color: var(--toast-link);
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;
}

.toast__dismiss {
  padding: 0;
  min-height: 1.5rem;
  min-width: 1.5rem;
  background: none;
  border: none;
  color: inherit;
  opacity: .7;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.toast__dismiss:hover {
  opacity: 1;
}

/* Touch-target floor (contract §0.8, ≥40px) for the toast controls. */
@media (pointer: coarse) {
  .toast__dismiss,
  .toast .flash__undo-btn {
    min-height: 2.5rem;
    min-width: 2.5rem;
  }
}

@media (max-width: 480px) {
  .toast-region {
    width: calc(100vw - var(--sp-4));
    bottom: var(--sp-4);
  }
}

/* ---------------------------------------------------------
   flash__undo — inline "Annulla" restore control embedded in a flash
   message by web/components.py undo_action() (posts to the existing
   /cestino/ripristina route). Styled here for the no-JS flash-region
   rendering; .toast .flash__undo above restyles it once initToast() moves
   the same form into a toast.
   --------------------------------------------------------- */
.flash__undo {
  display: inline-flex;
  margin: 0 0 0 auto;
}

.flash__undo-btn {
  padding: 0;
  min-height: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;
}

.flash__undo-btn:hover {
  opacity: .8;
}

/* ---------------------------------------------------------
   OCR intake progress — shown immediately after a multi-file OCR submit.
   It is a page-level state, deliberately not a small spinner hidden inside
   the upload card, so operators know the request is still being processed.
   --------------------------------------------------------- */
.ocr-intake-progress {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--overlay-backdrop);
}

.ocr-intake-progress__card {
  width: min(32rem, 100%);
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.ocr-intake-progress__card h2 { font-size: 1.35rem; }
.ocr-intake-progress__card p { color: var(--color-text-muted); }

.ocr-intake-progress__bar {
  height: .45rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-surface-2);
}

.ocr-intake-progress__bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-fill);
  animation: ocr-intake-loading 1.15s ease-in-out infinite alternate;
}

@keyframes ocr-intake-loading {
  from { transform: translateX(-15%); }
  to { transform: translateX(155%); }
}

.ocr-intake-progress__steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
}

.ocr-intake-progress__step {
  width: 2.25rem;
  aspect-ratio: 1;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  transition: background-color var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease),
    opacity var(--motion-fast) var(--ease);
  opacity: .45;
}

.ocr-intake-progress__step.is-active {
  background: var(--color-surface);
  border-color: var(--accent-fill);
  box-shadow: inset 0 0 0 1px var(--accent-fill);
  transform: translateY(-2px);
  opacity: 1;
}

.ocr-intake-progress__step.is-complete {
  background: var(--accent-soft);
  border-color: var(--accent-fill);
  opacity: 1;
}

/* Reusable, server-rendered progress for sequential workflows. Unlike the
   full-page OCR analysis overlay this remains visible inside each queue form
   and therefore works without JavaScript in Firefox and other browsers. */
.step-progress {
  display: grid;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: var(--sp-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.step-progress__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.step-progress__head span,
.step-progress__detail {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.step-progress__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(1.75rem, 1fr));
  gap: var(--sp-2);
}
.step-progress__step {
  min-height: 2.25rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.step-progress__step.is-complete {
  border-color: var(--st-ok-border);
  background: var(--st-ok-bg);
}
.step-progress__step.is-current {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-fill);
}
.step-progress__detail { margin: 0; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .ocr-intake-progress__step { transition: none; }
  .ocr-intake-progress__bar span { animation: none; width: 100%; opacity: .7; }
}

/* ---------------------------------------------------------
   pagination-bar — riepilogo "Pagina X di Y" + link Precedente/
   Successiva, usato da web/components.py pagination_bar() sotto le
   tabelle paginate (clienti, scadenzario).
   --------------------------------------------------------- */
.pagination-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin: var(--sp-4) 0;
}

.pagination-bar__summary {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-right: auto;
}

.pagination-nav--disabled {
  opacity: .5;
  cursor: default;
  pointer-events: none;
}
