/* NOWY UI 2.1 "Linear" — foglio unico consolidato (base + profondita/tema scuro + componenti 1.5 + stile Linear 2.0
   + 2.1 navigazione istantanea e identita' NOWY).
   Richiede Bootstrap 5.3 + Bootstrap Icons + font Inter. Tema: <html data-theme="light|dark">. */
/* ==========================================================================
   NOWY UI — design system (stile Apple: chiaro, arioso, grigi morbidi, un solo accento)
   Si appoggia a Bootstrap 5 ridisegnandone i componenti: le pagine esistenti ereditano lo stile
   senza modifiche. Componenti propri: .nw-seg, .nw-chips, .nw-toolbar, .nw-empty, .nw-stat,
   .nw-progress, .nw-overlay, .nw-toast. Guida: docs/UI_STYLE.md
   ========================================================================== */

:root {
  --nw-bg: #f5f5f7;
  --nw-surface: #ffffff;
  --nw-surface-2: #fbfbfd;
  --nw-label: #1d1d1f;
  --nw-label-2: #6e6e73;
  --nw-label-3: #86868b;
  --nw-sep: rgba(60, 60, 67, .12);
  --nw-sep-strong: rgba(60, 60, 67, .22);
  --nw-fill: rgba(120, 120, 128, .12);
  --nw-fill-2: rgba(120, 120, 128, .08);
  --nw-accent: #0071e3;
  --nw-accent-hover: #0077ed;
  --nw-accent-tint: rgba(0, 113, 227, .10);
  --nw-green: #248a3d;  --nw-green-tint: rgba(52, 199, 89, .14);
  --nw-orange: #c93400; --nw-orange-tint: rgba(255, 149, 0, .16);
  --nw-red: #d70015;    --nw-red-tint: rgba(255, 59, 48, .12);
  --nw-blue-tint: rgba(0, 122, 255, .12);
  --nw-gray-tint: rgba(142, 142, 147, .16);
  --nw-r-lg: 18px; --nw-r: 12px; --nw-r-sm: 9px;
  --nw-shadow: 0 0 0 1px rgba(0, 0, 0, .05);                 /* piatto: filo sottile, niente ombra */
  --nw-shadow-pop: 0 10px 40px rgba(0, 0, 0, .14), 0 2px 8px rgba(0, 0, 0, .06);
  --nw-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --nw-mono: "SF Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --nw-ease: cubic-bezier(.25, .1, .25, 1);

  --bs-primary: var(--nw-accent);
  --bs-primary-rgb: 0, 113, 227;
  --bs-body-font-family: var(--nw-font);
  --bs-body-color: var(--nw-label);
  --bs-border-color: var(--nw-sep);
  --bs-link-color: var(--nw-accent);
  --bs-link-hover-color: var(--nw-accent-hover);
}

/* --- base ----------------------------------------------------------------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { background: var(--nw-bg); font-family: var(--nw-font); font-size: 14px; color: var(--nw-label);
       letter-spacing: -.005em; }
::selection { background: rgba(0, 113, 227, .22); }
a { color: var(--nw-accent); text-decoration: none; }
a:hover { color: var(--nw-accent-hover); }
.text-muted, .small.text-muted { color: var(--nw-label-2) !important; }
.mono { font-family: var(--nw-mono); font-size: 12.5px; letter-spacing: 0; }
hr { border-color: var(--nw-sep); opacity: 1; }

/* --- layout: sidebar traslucida + topbar con blur -------------------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: 0 0 248px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: rgba(246, 246, 248, .86); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px); border-right: 1px solid var(--nw-sep);
  padding: 0 10px 28px; color: var(--nw-label); }
.brand { padding: 22px 10px 16px; margin-bottom: 4px; border-bottom: 0; }
.brand-mark { display: block; font-weight: 700; font-size: 19px; letter-spacing: .02em; color: var(--nw-label); }
.brand-mark::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6); vertical-align: 1px; }
.brand-sub { display: block; font-size: 11.5px; color: var(--nw-label-3); margin-top: 2px; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--nw-label-3); padding: 16px 10px 6px; letter-spacing: .01em;
  text-transform: none; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0; border-radius: var(--nw-r-sm);
  color: var(--nw-label); font-size: 13.5px; font-weight: 450; transition: background .15s var(--nw-ease); }
.nav-item i { width: 18px; font-size: 15px; color: var(--nw-accent); opacity: .9; text-align: center; }
.nav-item:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nav-item.active { background: var(--nw-accent-tint); color: var(--nw-accent); font-weight: 600; box-shadow: none; }

.content { flex: 1; min-width: 0; padding: 0 32px 56px; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin: 0 -32px 24px; padding: 18px 32px 14px; border-bottom: 1px solid var(--nw-sep);
  background: rgba(245, 245, 247, .80); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -.022em; margin: 0; line-height: 1.15; }
.topbar .subtitle { color: var(--nw-label-2); font-size: 13px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user { font-size: 13px; color: var(--nw-label-2); }

/* --- card ----------------------------------------------------------------- */
.card { border: 0; border-radius: var(--nw-r-lg); background: var(--nw-surface); box-shadow: var(--nw-shadow); overflow: hidden; }
.card-header { background: transparent; border-bottom: 1px solid var(--nw-sep); padding: 14px 18px; font-weight: 600;
  font-size: 15px; letter-spacing: -.01em; }
.card-body { padding: 18px; }
.card-footer { background: var(--nw-surface-2); border-top: 1px solid var(--nw-sep); }
.card.border-warning { box-shadow: var(--nw-shadow), inset 0 0 0 1px rgba(255, 149, 0, .45); }
.bg-warning-subtle { background: var(--nw-orange-tint) !important; }

/* --- pulsanti ------------------------------------------------------------- */
.btn { --bs-btn-font-weight: 500; border-radius: var(--nw-r-sm); padding: 7px 14px; font-size: 13.5px; letter-spacing: -.005em;
  border-width: 0; transition: background .15s var(--nw-ease), transform .08s var(--nw-ease), box-shadow .15s; }
.btn:active { transform: scale(.97); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 11px 22px; font-size: 16px; border-radius: var(--nw-r); }
.btn-primary { background: var(--nw-accent); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--nw-accent-hover); color: #fff; }
.btn-success { background: #28a745; background: #30b14a; color: #fff; }
.btn-success:hover { background: #2aa043; color: #fff; }
.btn-danger { background: #ff3b30; color: #fff; }
.btn-warning { background: #ff9f0a; color: #fff; }
.btn-secondary, .btn-dark { background: var(--nw-label); color: #fff; }
/* "outline" diventano pulsanti tinta (filled tinted, come iOS) */
.btn[class*="btn-outline-"] { background: var(--nw-fill-2); color: var(--nw-label); border: 0; }
.btn[class*="btn-outline-"]:hover { background: var(--nw-fill); color: var(--nw-label); }
.btn-outline-primary { background: var(--nw-accent-tint) !important; color: var(--nw-accent) !important; }
.btn-outline-primary:hover { background: rgba(0, 113, 227, .16) !important; }
.btn-outline-success { background: var(--nw-green-tint) !important; color: var(--nw-green) !important; }
.btn-outline-danger { background: var(--nw-red-tint) !important; color: var(--nw-red) !important; }
.btn-outline-warning { background: var(--nw-orange-tint) !important; color: var(--nw-orange) !important; }
.btn-link { background: transparent; color: var(--nw-accent); padding-left: 4px; padding-right: 4px; }
.btn:focus-visible { box-shadow: 0 0 0 4px rgba(0, 113, 227, .28); }
.btn-pill { border-radius: 980px !important; padding-left: 18px; padding-right: 18px; }

/* --- form ----------------------------------------------------------------- */
.form-control, .form-select { border: 1px solid var(--nw-sep-strong); border-radius: var(--nw-r-sm); background-color: var(--nw-surface);
  min-height: 36px; font-size: 14px; color: var(--nw-label); transition: border-color .15s, box-shadow .15s; }
.form-control-sm, .form-select-sm { min-height: 32px; font-size: 13px; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--nw-accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, .18); }
.form-control::placeholder { color: var(--nw-label-3); }
.form-label { font-size: 12.5px; font-weight: 500; color: var(--nw-label-2); margin-bottom: 4px; }
.form-check-input:checked { background-color: var(--nw-accent); border-color: var(--nw-accent); }
.form-switch .form-check-input { width: 2.4em; height: 1.35em; }
input[type=file].form-control { padding: 5px 8px; }
input[type=file]::file-selector-button { border: 0; border-radius: 7px; background: var(--nw-fill-2); padding: 4px 10px; margin-right: 10px; }

/* --- controllo a segmenti (filtri stile iOS/macOS) ------------------------ */
.nw-seg { display: inline-flex; padding: 2px; background: var(--nw-fill); border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.nw-seg > a, .nw-seg > button, .nw-seg > label { border: 0; background: transparent; color: var(--nw-label); font-size: 13px;
  font-weight: 500; padding: 5px 13px; border-radius: 8px; line-height: 1.35; cursor: pointer; white-space: nowrap;
  transition: background .18s var(--nw-ease), box-shadow .18s; }
.nw-seg > a:hover, .nw-seg > button:hover, .nw-seg > label:hover { color: var(--nw-label); background: rgba(255,255,255,.5); }
.nw-seg > .active, .nw-seg > input:checked + label { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); }
.nw-seg > input { display: none; }
.nw-seg .count { color: var(--nw-label-3); font-weight: 500; margin-left: 4px; }

/* chip/pillole di filtro */
.nw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nw-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 980px; font-size: 13px;
  font-weight: 500; background: var(--nw-surface); color: var(--nw-label); box-shadow: inset 0 0 0 1px var(--nw-sep-strong); }
.nw-chip:hover { color: var(--nw-label); box-shadow: inset 0 0 0 1px var(--nw-label-3); }
.nw-chip.active { background: var(--nw-label); color: #fff; box-shadow: none; }

/* barra strumenti sopra una lista: filtri a sinistra, azioni a destra */
.nw-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.nw-toolbar .left, .nw-toolbar .right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nw-search { position: relative; }
.nw-search .form-control { padding-left: 32px; border-radius: 10px; background: var(--nw-fill-2); border-color: transparent; }
.nw-search .form-control:focus { background: #fff; }
.nw-search::before { content: "\F52A"; font-family: "bootstrap-icons"; position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--nw-label-3); font-size: 13px; }

/* --- tabelle -------------------------------------------------------------- */
table.table { font-size: 13.5px; margin-bottom: 0; --bs-table-bg: transparent; --bs-table-hover-bg: var(--nw-fill-2); }
table.table thead th { position: sticky; top: 0; z-index: 1; background: var(--nw-surface-2); color: var(--nw-label-2);
  font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--nw-sep);
  white-space: nowrap; padding: 10px 12px; }
table.table td { vertical-align: middle; padding: 10px 12px; border-color: var(--nw-sep); }
table.table tbody tr { transition: background .12s; }
table.table tbody tr:hover { background: var(--nw-fill-2); }
table.table tbody tr:last-child td { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding: 8px 12px; }
.table .btn-sm { padding: 3px 10px; }
td .btn-outline-secondary { background: transparent !important; color: var(--nw-accent) !important; font-weight: 500; }
td .btn-outline-secondary:hover { background: var(--nw-accent-tint) !important; }
.table-export { border-bottom: 1px solid var(--nw-sep); background: transparent; }
.table-export .btn { color: var(--nw-label-2); font-size: 12.5px; }

/* --- badge = pillole tinta ------------------------------------------------ */
.badge { font-weight: 600; font-size: 11.5px; padding: 4px 9px; border-radius: 980px; letter-spacing: 0; }
.text-bg-success { background: var(--nw-green-tint) !important; color: var(--nw-green) !important; }
.text-bg-danger { background: var(--nw-red-tint) !important; color: var(--nw-red) !important; }
.text-bg-warning { background: var(--nw-orange-tint) !important; color: var(--nw-orange) !important; }
.text-bg-primary { background: var(--nw-blue-tint) !important; color: var(--nw-accent) !important; }
.text-bg-info { background: rgba(90, 200, 250, .18) !important; color: #0071a4 !important; }
.text-bg-secondary, .text-bg-light { background: var(--nw-gray-tint) !important; color: var(--nw-label-2) !important; }
.text-bg-dark { background: var(--nw-label) !important; color: #fff !important; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 980px; background: var(--nw-fill-2); font-size: 12.5px; margin: 2px 0; }

/* --- avvisi --------------------------------------------------------------- */
.alert { border: 0; border-radius: var(--nw-r); padding: 12px 16px; font-size: 13.5px; }
.alert-success { background: var(--nw-green-tint); color: #1d6b31; }
.alert-danger { background: var(--nw-red-tint); color: #a3000f; }
.alert-warning { background: var(--nw-orange-tint); color: #8a3a00; }
.alert-info, .alert-primary { background: var(--nw-blue-tint); color: #0051a8; }
.alert-link { color: inherit; text-decoration: underline; }

/* --- KPI / statistiche ---------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.kpi, .nw-stat { display: block; background: var(--nw-surface); border: 0; border-radius: var(--nw-r-lg); padding: 16px 18px;
  box-shadow: var(--nw-shadow); color: inherit; transition: transform .18s var(--nw-ease), box-shadow .18s; }
a.kpi:hover, a.nw-stat:hover { background: var(--nw-surface-2); box-shadow: 0 0 0 1px var(--nw-sep-strong); color: inherit; }
.kpi .label, .nw-stat .label { font-size: 12.5px; font-weight: 500; color: var(--nw-label-2); text-transform: none; letter-spacing: 0; }
.kpi .value, .nw-stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.kpi.alarm .value { color: var(--nw-red); }

/* --- stato vuoto ---------------------------------------------------------- */
.nw-empty { text-align: center; padding: 40px 20px; color: var(--nw-label-2); }
.nw-empty i { font-size: 34px; color: var(--nw-label-3); display: block; margin-bottom: 8px; }
.nw-empty .title { font-weight: 600; color: var(--nw-label); font-size: 15px; }

/* --- planning board ------------------------------------------------------- */
.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 14px; }
.board-col { background: var(--nw-surface); border: 0; border-radius: var(--nw-r-lg); box-shadow: var(--nw-shadow);
  width: 300px; flex: 0 0 300px; max-height: 76vh; display: flex; flex-direction: column; }
.board-col .head { padding: 12px 14px; border-bottom: 1px solid var(--nw-sep); }
.board-list { padding: 10px; min-height: 120px; overflow-y: auto; flex: 1; background: var(--nw-surface-2); }
.dcard { background: #fff; border: 0; border-left: 0; border-radius: var(--nw-r); padding: 10px 12px; margin-bottom: 8px;
  box-shadow: 0 0 0 1px var(--nw-sep), inset 3px 0 0 var(--nw-accent); cursor: grab; transition: box-shadow .15s, transform .15s; }
.dcard:hover { box-shadow: 0 0 0 1px var(--nw-sep-strong), inset 3px 0 0 var(--nw-accent); }
.dcard.overdue { box-shadow: 0 0 0 1px var(--nw-sep), inset 3px 0 0 #ff3b30; }
.dcard .t { font-weight: 600; font-size: 13.5px; }
.dcard .m { color: var(--nw-label-2); font-size: 12px; }
.sortable-ghost { opacity: .45; }
.capacity { font-size: 12px; color: var(--nw-label-2); }
.capacity.over { color: var(--nw-red); font-weight: 600; }

/* --- caricamento ---------------------------------------------------------- */
.nw-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 3000; opacity: 0;
  background: linear-gradient(90deg, #0a84ff, #5e5ce6, #bf5af2); box-shadow: 0 0 10px rgba(10, 132, 255, .6);
  transition: width .4s var(--nw-ease), opacity .3s; }
.nw-progress.run { opacity: 1; width: 82%; transition: width 8s cubic-bezier(.1, .7, .3, 1), opacity .2s; }
.nw-progress.done { opacity: 0; width: 100%; transition: width .2s, opacity .4s .2s; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: nw-spin .7s linear infinite; }
.btn[class*="btn-outline-"].is-loading::after, .btn-link.is-loading::after { border-color: rgba(0,113,227,.25); border-top-color: var(--nw-accent); }
.nw-overlay { position: fixed; inset: 0; z-index: 2900; display: flex; align-items: center; justify-content: center;
  background: rgba(245, 245, 247, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--nw-ease); }
.nw-overlay.show { opacity: 1; pointer-events: auto; }
.nw-overlay .box { background: rgba(255,255,255,.92); border-radius: 20px; box-shadow: var(--nw-shadow-pop); padding: 26px 34px;
  text-align: center; min-width: 280px; max-width: 420px; }
.nw-overlay .spinner { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--nw-fill);
  border-top-color: var(--nw-accent); animation: nw-spin .8s linear infinite; }
.nw-overlay .msg { font-weight: 600; font-size: 15px; }
.nw-overlay .sub { color: var(--nw-label-2); font-size: 13px; margin-top: 4px; }
.nw-overlay .steps { margin-top: 12px; text-align: left; font-size: 13px; color: var(--nw-label-3); }
.nw-overlay .steps div { transition: color .3s; } .nw-overlay .steps div.on { color: var(--nw-label); font-weight: 500; }
.nw-overlay .steps div.on::before { content: "● "; color: var(--nw-accent); }
.nw-overlay .steps div:not(.on)::before { content: "○ "; }
@keyframes nw-spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--nw-fill-2), var(--nw-fill), var(--nw-fill-2)); background-size: 200% 100%;
  animation: nw-shimmer 1.2s infinite; border-radius: 6px; color: transparent !important; }
@keyframes nw-shimmer { to { background-position: -200% 0; } }

/* --- toast (messaggi dopo un'azione) -------------------------------------- */
.nw-toasts { position: fixed; top: 18px; right: 18px; z-index: 3100; display: flex; flex-direction: column; gap: 8px; }
.nw-toast { display: flex; gap: 10px; align-items: flex-start; min-width: 280px; max-width: 440px; padding: 12px 16px;
  border-radius: 14px; background: rgba(255,255,255,.94); backdrop-filter: blur(20px); box-shadow: var(--nw-shadow-pop);
  font-size: 13.5px; animation: nw-in .35s var(--nw-ease); }
.nw-toast i { font-size: 18px; line-height: 1.1; }
.nw-toast.success i { color: #30b14a; } .nw-toast.danger i { color: #ff3b30; } .nw-toast.warning i { color: #ff9f0a; }
.nw-toast.info i { color: var(--nw-accent); }
.nw-toast .close { margin-left: auto; color: var(--nw-label-3); cursor: pointer; border: 0; background: none; font-size: 16px; }
.nw-toast.out { animation: nw-out .3s var(--nw-ease) forwards; }
@keyframes nw-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes nw-out { to { opacity: 0; transform: translateY(-8px); } }

/* --- login ---------------------------------------------------------------- */
.nw-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #e8f0ff, transparent), radial-gradient(900px 500px at 110% 110%, #f3e8ff, transparent), var(--nw-bg); }

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 992px) {
  .sidebar { position: fixed; left: -260px; z-index: 1040; transition: left .25s var(--nw-ease); box-shadow: var(--nw-shadow-pop); }
  body.nav-open .sidebar { left: 0; }
  .content { padding: 0 16px 40px; }
  .topbar { margin: 0 -16px 18px; padding: 14px 16px 12px; }
  .topbar h1 { font-size: 21px; }
  .nw-menu-btn { display: inline-flex !important; }
}
.nw-menu-btn { display: none; }
@media print { .sidebar, .topbar-right, .nw-progress, .nw-toasts, .table-export { display: none !important; } .card { box-shadow: none; } }

/* --- fluidita': transizioni tra pagine e ingresso dei contenuti ------------ */
@view-transition { navigation: auto; }                          /* Chrome/Edge: dissolvenza tra pagine */
::view-transition-old(root) { animation: nw-vt-out .14s ease-out both; }
::view-transition-new(root) { animation: nw-vt-in .22s cubic-bezier(.2, .8, .2, 1) both; }
.sidebar { view-transition-name: nw-sidebar; }                   /* la sidebar resta ferma */
::view-transition-group(nw-sidebar) { animation: none; }
@keyframes nw-vt-out { to { opacity: 0; } }
@keyframes nw-vt-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes nw-rise { from { opacity: 0; transform: translateY(8px); } }
.kpi, .nw-stat, .card, .btn, .form-control, .form-select, .nav-item, .nw-chip, .dcard { will-change: auto; }
@media (prefers-reduced-motion: reduce) { *, ::view-transition-group(*) { animation: none !important; transition: none !important; } }

/* --- grafici (palette validata: CVD e normal-vision PASS su #ffffff) ------- */
:root {
  --nw-series-1: #2a78d6; --nw-series-2: #eb6834; --nw-series-3: #1baf7a; --nw-series-4: #eda100;
  --nw-series-5: #e87ba4; --nw-series-6: #008300; --nw-series-7: #4a3aa7;
  --nw-status-good: #0ca30c; --nw-status-warning: #fab219; --nw-status-serious: #ec835a; --nw-status-critical: #d03b3b;
}
.nw-chart { position: relative; height: 260px; }
.nw-chart.sm { height: 180px; } .nw-chart.lg { height: 340px; }
.nw-chart-card .card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.nw-chart-card .card-header .hint { font-weight: 400; font-size: 12.5px; color: var(--nw-label-2); }

/* --- componenti condivisi aggiunti dopo il redesign delle pagine (v1.1) ----- */
.topbar-right .btn { white-space: nowrap; }
.kpi .sub, .nw-stat .sub { font-size: 12px; color: var(--nw-label-2); margin-top: 2px; }
.nw-chip .n { color: var(--nw-label-3); font-weight: 500; margin-left: 2px; }
.nw-chip.active .n { color: rgba(255,255,255,.7); }
.nw-noresult { display: none; text-align: center; padding: 24px; color: var(--nw-label-2); }
.nw-noresult.show { display: block; }
.nw-note { font-size: 12.5px; color: var(--nw-label-2); }
.section-title, .nw-section { font-size: 13px; font-weight: 600; color: var(--nw-label-2); text-transform: none; letter-spacing: 0; margin: 22px 0 10px; }
/* misuratore (capienza mezzo, avanzamento): verde, arancio da 85%, rosso oltre il 100% */
.nw-meter { height: 6px; border-radius: 980px; background: var(--nw-fill); overflow: hidden; }
.nw-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--nw-status-good); transition: width .4s var(--nw-ease); }
.nw-meter.warn > span { background: var(--nw-status-warning); }
.nw-meter.over > span { background: var(--nw-status-critical); }
/* cronologia (audit, storico consegna) */
.nw-timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--nw-sep); }
.nw-timeline > li { position: relative; padding: 0 0 14px 12px; }
.nw-timeline > li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--nw-surface); box-shadow: 0 0 0 2px var(--nw-accent); }
.nw-timeline .when { font-size: 12px; color: var(--nw-label-3); }


/* ===== strato 1.2-1.5 ===== */
/* ==========================================================================
   NOWY UI v1.2 - profondita' stile Linear (bianco a strati) + tema scuro + icone a tessera
   Si carica DOPO nowy-ui.css.
   ========================================================================== */
:root {
  --nw-bg: #f7f8fa;
  --nw-sidebar: #f1f2f5;
  --nw-border: rgba(15, 23, 42, .09);
  --nw-highlight: inset 0 1px 0 rgba(255, 255, 255, .9);
  --nw-elev-1: 0 0 0 1px var(--nw-border), 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px -2px rgba(15, 23, 42, .06);
  --nw-elev-2: 0 0 0 1px var(--nw-border), 0 2px 4px rgba(15, 23, 42, .05), 0 12px 28px -8px rgba(15, 23, 42, .14);
  --nw-shadow: var(--nw-elev-1);
  --nw-input-inset: inset 0 1px 2px rgba(15, 23, 42, .06);
  --nw-chart-ink: #1d1d1f; --nw-chart-ink-2: #6e6e73; --nw-chart-grid: rgba(60, 60, 67, .10);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --nw-bg: #0c0d10; --nw-sidebar: #111215; --nw-surface: #17181c; --nw-surface-2: #1c1d22;
  --nw-label: #ececef; --nw-label-2: #a1a2a9; --nw-label-3: #74757d;
  --nw-sep: rgba(255, 255, 255, .08); --nw-sep-strong: rgba(255, 255, 255, .14); --nw-border: rgba(255, 255, 255, .08);
  --nw-fill: rgba(255, 255, 255, .10); --nw-fill-2: rgba(255, 255, 255, .06);
  --nw-accent: #3b8bff; --nw-accent-hover: #5a9dff; --nw-accent-tint: rgba(59, 139, 255, .16);
  --nw-green: #4ade80; --nw-green-tint: rgba(74, 222, 128, .14);
  --nw-orange: #fbbf24; --nw-orange-tint: rgba(251, 191, 36, .14);
  --nw-red: #ff6b6b; --nw-red-tint: rgba(255, 107, 107, .15);
  --nw-blue-tint: rgba(59, 139, 255, .16); --nw-gray-tint: rgba(255, 255, 255, .10);
  --nw-highlight: inset 0 1px 0 rgba(255, 255, 255, .05);
  --nw-elev-1: 0 0 0 1px var(--nw-border), 0 1px 2px rgba(0, 0, 0, .4);
  --nw-elev-2: 0 0 0 1px var(--nw-sep-strong), 0 16px 40px -10px rgba(0, 0, 0, .7);
  --nw-shadow-pop: 0 20px 50px rgba(0, 0, 0, .6);
  --nw-input-inset: inset 0 1px 2px rgba(0, 0, 0, .35);
  /* serie grafici tema scuro: validate (CVD, normal-vision, contrasto) su #16171a */
  --nw-series-1: #3987e5; --nw-series-2: #d95926; --nw-series-3: #199e70; --nw-series-4: #c98500;
  --nw-series-5: #d55181; --nw-series-6: #008300; --nw-series-7: #9085e9;
  --nw-chart-ink: #ececef; --nw-chart-ink-2: #a1a2a9; --nw-chart-grid: rgba(255, 255, 255, .08);
  --bs-body-bg: #0c0d10; --bs-body-color: #ececef; --bs-border-color: rgba(255, 255, 255, .08);
  --bs-secondary-color: #a1a2a9; --bs-tertiary-bg: #1c1d22;
}
body { background: var(--nw-bg); color: var(--nw-label); }

/* superfici a strati: filo + ombra corta + luce sul bordo alto */
.card, .kpi, .nw-stat, .board-col { background: var(--nw-surface); box-shadow: var(--nw-elev-1), var(--nw-highlight); }
a.kpi:hover, a.nw-stat:hover { background: var(--nw-surface); box-shadow: var(--nw-elev-2), var(--nw-highlight); transform: translateY(-1px); }
.card-header { background: linear-gradient(var(--nw-surface), var(--nw-surface-2)); color: var(--nw-label); }
.card-footer { background: var(--nw-surface-2); }
.board-list { background: var(--nw-surface-2); }
.dcard { background: var(--nw-surface); box-shadow: var(--nw-elev-1), inset 3px 0 0 var(--nw-accent); }
.dcard:hover { box-shadow: var(--nw-elev-2), inset 3px 0 0 var(--nw-accent); transform: translateY(-1px); }
.dcard.overdue { box-shadow: var(--nw-elev-1), inset 3px 0 0 #ff3b30; }
table.table thead th { background: var(--nw-surface-2); }

/* sidebar su un piano diverso, voce attiva "sollevata" */
.sidebar { background: var(--nw-sidebar); border-right: 1px solid var(--nw-border); backdrop-filter: none; -webkit-backdrop-filter: none; }
.nav-item { color: var(--nw-label); }
.nav-item:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nav-item.active { background: var(--nw-surface); color: var(--nw-label); box-shadow: var(--nw-elev-1), var(--nw-highlight); font-weight: 600; }
.brand-mark { color: var(--nw-label); }
.nav-section { color: var(--nw-label-3); }
.topbar { background: color-mix(in srgb, var(--nw-bg) 82%, transparent); border-bottom-color: var(--nw-border); }

/* icone riconoscibili: tessera colorata stile Impostazioni */
.nav-item .ico { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; display: inline-flex; align-items: center;
  justify-content: center; background: var(--c, #8e8e93);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 1.5px rgba(0, 0, 0, .18); }
.nav-item .ico i { width: auto; color: #fff; opacity: 1; font-size: 12.5px; line-height: 1; }

/* pulsanti in leggero rilievo */
.btn-primary { background: linear-gradient(180deg, #1a86f5, #0a6fe0); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 0 0 1px rgba(0, 80, 180, .55), 0 1px 2px rgba(0, 60, 140, .25); }
.btn-primary:hover, .btn-primary:focus { background: linear-gradient(180deg, #2b90f7, #0b75ec); color: #fff; }
.btn-success { background: linear-gradient(180deg, #3cc35a, #2aa447); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 0 0 1px rgba(20, 110, 45, .55), 0 1px 2px rgba(0, 0, 0, .15); }
.btn-danger { background: linear-gradient(180deg, #ff5a4f, #ec3a30); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 1px rgba(160, 20, 15, .5); }
.btn-outline-secondary { background: var(--nw-surface) !important; color: var(--nw-label) !important;
  box-shadow: 0 0 0 1px var(--nw-border), 0 1px 2px rgba(15, 23, 42, .05), var(--nw-highlight); }
.btn-outline-secondary:hover { background: var(--nw-surface-2) !important; }
td .btn-outline-secondary { box-shadow: none; background: transparent !important; color: var(--nw-accent) !important; }

/* campi incassati */
.form-control, .form-select { background-color: var(--nw-surface); color: var(--nw-label); border-color: var(--nw-sep-strong);
  box-shadow: var(--nw-input-inset); }
.form-control:focus, .form-select:focus { background-color: var(--nw-surface); color: var(--nw-label);
  box-shadow: var(--nw-input-inset), 0 0 0 4px var(--nw-accent-tint); }
.nw-seg { background: var(--nw-fill); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06); }
.nw-seg > a, .nw-seg > button, .nw-seg > label { color: var(--nw-label); }
.nw-seg > .active, .nw-seg > input:checked + label { background: var(--nw-surface); box-shadow: var(--nw-elev-1), var(--nw-highlight); }
.nw-chip { background: var(--nw-surface); color: var(--nw-label); box-shadow: 0 0 0 1px var(--nw-border), 0 1px 1px rgba(15, 23, 42, .04); }
.nw-chip.active { background: var(--nw-label); color: var(--nw-bg); }

/* tema scuro: componenti Bootstrap e residui */
html[data-theme="dark"] .table { --bs-table-color: var(--nw-label); --bs-table-border-color: var(--nw-sep); --bs-table-bg: transparent; color: var(--nw-label); }
html[data-theme="dark"] .bg-white, html[data-theme="dark"] .bg-light { background: var(--nw-surface-2) !important; color: var(--nw-label); }
html[data-theme="dark"] .text-dark, html[data-theme="dark"] .text-body { color: var(--nw-label) !important; }
html[data-theme="dark"] .text-muted, html[data-theme="dark"] .text-secondary { color: var(--nw-label-2) !important; }
html[data-theme="dark"] .border, html[data-theme="dark"] .border-top, html[data-theme="dark"] .border-bottom { border-color: var(--nw-sep) !important; }
html[data-theme="dark"] .btn-close { filter: invert(1); }
html[data-theme="dark"] .nw-overlay { background: rgba(0, 0, 0, .5); }
html[data-theme="dark"] .nw-overlay .box, html[data-theme="dark"] .nw-toast { background: rgba(28, 29, 34, .96); color: var(--nw-label); }
html[data-theme="dark"] .alert-success { color: #86efac; } html[data-theme="dark"] .alert-danger { color: #fca5a5; }
html[data-theme="dark"] .alert-warning { color: #fde68a; }
html[data-theme="dark"] .alert-info, html[data-theme="dark"] .alert-primary { color: #93c5fd; }
html[data-theme="dark"] .text-bg-info { color: #7dd3fc !important; background: rgba(56, 189, 248, .15) !important; }
html[data-theme="dark"] .text-bg-dark { background: #ececef !important; color: #0c0d10 !important; }
html[data-theme="dark"] .pill { background: var(--nw-fill); }
html[data-theme="dark"] .nw-auth { background: radial-gradient(1200px 600px at 20% -10%, #14213d, transparent),
  radial-gradient(900px 500px at 110% 110%, #2a1640, transparent), var(--nw-bg); }
html[data-theme="dark"] .btn-outline-secondary { box-shadow: 0 0 0 1px var(--nw-sep-strong), var(--nw-highlight); }
html[data-theme="dark"] input[type=file]::file-selector-button { background: var(--nw-fill); color: var(--nw-label); }
html[data-theme="dark"] .dropdown-menu { background: var(--nw-surface); border-color: var(--nw-sep); }

/* interruttore tema ☀︎/☾ */
.nw-theme-toggle .bi-sun { display: none; }
html[data-theme="dark"] .nw-theme-toggle .bi-sun { display: inline; }
html[data-theme="dark"] .nw-theme-toggle .bi-moon-stars { display: none; }
html.nw-theme-anim, html.nw-theme-anim * { transition: background-color .35s ease, color .35s ease, box-shadow .35s ease, border-color .35s ease !important; }

/* profondita' anche su avvisi, toast, overlay, badge, righe e stati vuoti */
.alert { box-shadow: 0 0 0 1px var(--nw-border), var(--nw-highlight); }
.nw-toast, .nw-overlay .box { box-shadow: var(--nw-elev-2), var(--nw-highlight); }
.badge { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04); }
html[data-theme="dark"] .badge { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
table.table tbody tr:hover { background: var(--nw-fill-2); box-shadow: inset 3px 0 0 var(--nw-accent); }
.nw-empty { background: radial-gradient(420px 160px at 50% 0, var(--nw-fill-2), transparent); border-radius: var(--nw-r-lg); }
.nw-empty i { display: inline-flex; width: 52px; height: 52px; align-items: center; justify-content: center; border-radius: 14px;
  background: var(--nw-surface); box-shadow: var(--nw-elev-1), var(--nw-highlight); color: var(--nw-accent); font-size: 24px; margin-bottom: 12px; }
.nw-meter { box-shadow: inset 0 1px 2px rgba(0, 0, 0, .10); }
.kpi .value, .nw-stat .value { color: var(--nw-label); }
html[data-theme="dark"] .kpi .value, html[data-theme="dark"] .nw-stat .value { text-shadow: none; }

/* icone del menu: una sola tinta (accento), stile Linear; il colore per area resta disponibile con .nav-multicolor sulla sidebar */
.sidebar:not(.nav-multicolor) .nav-item .ico { background: linear-gradient(180deg, #2b90f7, #0a6fe0); }
html[data-theme="dark"] .sidebar:not(.nav-multicolor) .nav-item .ico { background: linear-gradient(180deg, #4a95ff, #2f76e6); }

/* --- fluidita' (v1.2.1): barra in alto e barra laterale ferme durante le transizioni, niente blur in scroll --- */
.topbar { background: var(--nw-bg); backdrop-filter: none; -webkit-backdrop-filter: none; view-transition-name: nw-topbar; }
.topbar h1, .topbar .subtitle { view-transition-name: none; }
::view-transition-group(nw-topbar) { animation-duration: .2s; }
::view-transition-old(nw-topbar), ::view-transition-new(nw-topbar) { animation-duration: .2s; }
.nw-toast { backdrop-filter: none; -webkit-backdrop-filter: none; }
.card, .kpi, .dcard, .btn, .nav-item { backface-visibility: hidden; }
.htmx-request .nw-progress { opacity: 1; }

/* --- v1.3: icone del menu SENZA sfondo, glifi in rilievo -------------------------------------------------
   Riempimento a sfumatura dentro il glifo + filo di luce sopra + ombra minima sotto: profondita' senza tessere.
   Riposo: grigio ardesia (il testo resta protagonista). Attiva: blu accento con alone. Hover: sale di 1px. */
.sidebar .nav-item .ico, .sidebar:not(.nav-multicolor) .nav-item .ico {
  width: 20px; height: 20px; flex: 0 0 20px; background: none !important; box-shadow: none !important; border-radius: 0; }
.sidebar .nav-item .ico i {
  font-size: 16px; line-height: 1; color: transparent;
  background: linear-gradient(180deg, #9a9ca8 0%, #5d606c 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)) drop-shadow(0 1px 1px rgba(15, 23, 42, .16));
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), filter .18s ease; display: inline-block; }
.sidebar .nav-item:hover .ico i { transform: translateY(-1px);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)) drop-shadow(0 2px 2px rgba(15, 23, 42, .20)); }
.sidebar .nav-item.active .ico i {
  background: linear-gradient(180deg, #4aa3ff 0%, #0a6fe0 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .85)) drop-shadow(0 1px 2px rgba(10, 111, 224, .35)) drop-shadow(0 0 6px rgba(10, 132, 255, .18)); }
html[data-theme="dark"] .sidebar .nav-item .ico i {
  background: linear-gradient(180deg, #b8bac3 0%, #6c6f7a 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .6)) drop-shadow(0 1px 0 rgba(255, 255, 255, .06)); }
html[data-theme="dark"] .sidebar .nav-item.active .ico i {
  background: linear-gradient(180deg, #7ab8ff 0%, #2f7cf0 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 8px rgba(59, 139, 255, .45)) drop-shadow(0 -1px 0 rgba(0, 0, 0, .5)); }
@media (forced-colors: active) { .sidebar .nav-item .ico i { color: CanvasText; background: none; filter: none; } }

/* ==========================================================================
   v1.4 — layout alla Linear: il contenuto e' una lastra sollevata sopra la tela del menu
   ========================================================================== */
:root { --nw-canvas: #eeeef1; --nw-panel: #ffffff; --nw-panel-bg: #fbfbfc; }
html[data-theme="dark"] { --nw-canvas: #08090a; --nw-panel: #111214; --nw-panel-bg: #111214; }
body { background: var(--nw-canvas); }
.layout { height: 100vh; overflow: hidden; }
.sidebar { background: transparent; border-right: 0; padding: 0 10px 24px 12px; height: 100vh; }
.content { background: var(--nw-panel-bg); margin: 8px 8px 8px 0; height: calc(100vh - 16px); overflow-y: auto;
  border-radius: 14px; box-shadow: 0 0 0 1px var(--nw-border), 0 1px 3px rgba(15, 23, 42, .06), 0 10px 30px -12px rgba(15, 23, 42, .14);
  scroll-behavior: auto; overscroll-behavior: contain; }
html[data-theme="dark"] .content { box-shadow: 0 0 0 1px rgba(255, 255, 255, .07), 0 20px 50px -20px rgba(0, 0, 0, .9); }
.topbar { background: var(--nw-panel-bg); border-top-left-radius: 14px; border-top-right-radius: 14px; }
.content { view-transition-name: nw-panel; }
::view-transition-group(nw-panel) { animation-duration: .22s; }

/* testata del menu: spazio di lavoro + ricerca + azione rapida in rilievo */
.nw-side-head { display: flex; align-items: center; gap: 4px; padding: 16px 2px 14px 2px; }
.nw-workspace { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; padding: 5px 6px; border-radius: 9px; color: var(--nw-label); }
.nw-workspace:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nw-logo { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #2a2b31, #111216); color: #fff; font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(0, 0, 0, .25); }
html[data-theme="dark"] .nw-logo { background: linear-gradient(180deg, #f4f4f6, #cfd0d6); color: #111; }
.nw-ws-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.nw-ws-caret { font-size: 11px; color: var(--nw-label-3); }
.nw-side-icon { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  color: var(--nw-label-2); font-size: 15px; }
.nw-side-icon:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nw-side-compose { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
  color: var(--nw-label); font-size: 16px; background: var(--nw-panel);
  box-shadow: 0 0 0 1px var(--nw-border), 0 1px 2px rgba(15, 23, 42, .08), 0 3px 8px -2px rgba(15, 23, 42, .10), inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: transform .15s ease, box-shadow .15s ease; }
.nw-side-compose:hover { transform: translateY(-1px); color: var(--nw-accent); }
html[data-theme="dark"] .nw-side-compose { background: #1d1e22; box-shadow: 0 0 0 1px rgba(255,255,255,.08), inset 0 1px 0 rgba(255,255,255,.06); }

/* voci: icona a contorno monocromatica, pastiglia contatore a destra */
.nav-item { gap: 10px; padding: 6px 8px; font-size: 13.5px; }
.sidebar .nav-item .ico i { color: var(--nw-label-2); background: none; -webkit-background-clip: border-box; background-clip: border-box;
  font-size: 16px; filter: none; }
html[data-theme="dark"] .sidebar .nav-item .ico i { background: none; -webkit-background-clip: border-box; background-clip: border-box; filter: none; color: var(--nw-label-2); }
.sidebar .nav-item:hover .ico i { color: var(--nw-label); transform: none; filter: none; }
.sidebar .nav-item.active .ico i, html[data-theme="dark"] .sidebar .nav-item.active .ico i { color: var(--nw-label); background: none; filter: none; }
.nav-item.active { background: var(--nw-panel); }
html[data-theme="dark"] .nav-item.active { background: #1c1d21; box-shadow: 0 0 0 1px rgba(255,255,255,.06), inset 0 1px 0 rgba(255,255,255,.04); }
.nw-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600; color: var(--nw-label-2); background: var(--nw-fill);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .03); font-variant-numeric: tabular-nums; }

/* sezioni richiudibili */
.nw-nav-toggle { display: flex; align-items: center; gap: 5px; width: 100%; border: 0; background: none; text-align: left;
  padding: 16px 8px 6px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--nw-label-3); }
.nw-nav-toggle:hover { color: var(--nw-label-2); }
.nw-nav-toggle i { font-size: 8px; transition: transform .2s ease; }
.nw-nav-group.closed .nw-nav-toggle i { transform: rotate(-90deg); }
.nw-nav-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .25s cubic-bezier(.2, .8, .2, 1), opacity .2s; }
.nw-nav-items > * { min-height: 0; }
.nw-nav-items { overflow: hidden; }
.nw-nav-group.closed .nw-nav-items { grid-template-rows: 0fr; opacity: 0; }
.nw-nav-group .nw-nav-items { display: flex; flex-direction: column; }
.nw-nav-group.closed .nw-nav-items { display: none; }

@media (max-width: 992px) {
  .layout { height: auto; overflow: visible; }
  .content { margin: 0; height: auto; min-height: 100vh; border-radius: 0; overflow: visible; box-shadow: none; }
  .sidebar { background: var(--nw-canvas); }
}

/* ==========================================================================
   v1.5 — componenti dai riferimenti (Linear / Stripe / Vercel)
   ========================================================================== */
/* icone di stato alla Linear: la forma racconta lo stato, il colore lo rinforza */
.nw-st { display: inline-flex; align-items: center; gap: 6px; color: var(--nw-label-3); white-space: nowrap; font-size: 13px; }
.nw-st svg { flex: 0 0 auto; }
.nw-st-label { color: var(--nw-label-2); }
/* palette stati: vivace e non standard (alla Linear), distinta per forma E colore */
:root { --st-wait: #9ca3af; --st-ready: #14b8a6; --st-planned: #a855f7; --st-progress: #eab308; --st-partial: #f97316;
        --st-done: #5e6ad2; --st-error: #f43f5e; --st-cancel: #9ca3af; }
html[data-theme="dark"] { --st-wait: #7b8190; --st-ready: #2dd4bf; --st-planned: #c084fc; --st-progress: #facc15; --st-partial: #fb923c;
        --st-done: #818cf8; --st-error: #fb7185; --st-cancel: #6b7280; }
.nw-st-dashed { color: var(--st-wait); }
.nw-st-ring { color: var(--st-ready); }
.nw-st-quarter { color: var(--st-planned); }
.nw-st-half, .nw-st-three { color: var(--st-progress); }
.nw-st-partial { color: var(--st-partial); }
.nw-st-done { color: var(--st-done); }
.nw-st-error, .nw-st-alert { color: var(--st-error); }
.nw-st-warn { color: var(--st-partial); }
.nw-st-cancel { color: var(--st-cancel); }
.nw-st-spin svg { animation: nw-spin 1s linear infinite; }

/* variazione rispetto al periodo precedente */
.nw-delta { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.nw-delta.up { color: #1a7f37; background: rgba(46, 160, 67, .14); }
.nw-delta.down { color: #b35900; background: rgba(245, 159, 0, .16); }
.nw-delta.new { color: var(--nw-label-2); background: var(--nw-fill); }
html[data-theme="dark"] .nw-delta.up { color: #4ade80; } html[data-theme="dark"] .nw-delta.down { color: #fbbf24; }

/* griglia di metriche alla Stripe: celle divise da fili, niente card per metrica */
.nw-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); background: var(--nw-surface);
  border-radius: var(--nw-r-lg); box-shadow: var(--nw-elev-1), var(--nw-highlight); overflow: hidden; }
.nw-metric { display: block; padding: 16px 18px 12px; color: inherit; border-right: 1px solid var(--nw-sep); border-bottom: 1px solid var(--nw-sep);
  transition: background .15s ease; }
a.nw-metric:hover { background: var(--nw-surface-2); color: inherit; }
.nw-metric-head { display: flex; align-items: center; gap: 8px; }
.nw-metric-head .label { font-size: 13px; font-weight: 500; color: var(--nw-label-2); }
.nw-metric-values { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 4px; }
.nw-metric .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--nw-label); }
.nw-metric .prev { font-size: 14px; color: var(--nw-label-3); font-variant-numeric: tabular-nums; }
.nw-metric .sub { font-size: 12px; color: var(--nw-label-3); margin-top: 4px; }
.nw-spark { height: 46px; margin-top: 8px; position: relative; }

/* titoli di sezione grandi alla Stripe */
.nw-h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 28px 0 12px; color: var(--nw-label); }
.nw-h2 .hint { font-size: 13px; font-weight: 400; color: var(--nw-label-3); margin-left: 8px; letter-spacing: 0; }

/* lista raggruppata alla Linear */
.nw-list { background: var(--nw-surface); border-radius: var(--nw-r-lg); box-shadow: var(--nw-elev-1), var(--nw-highlight); overflow: hidden; }
.nw-group-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--nw-surface-2); border-bottom: 1px solid var(--nw-sep); border-top: 1px solid var(--nw-sep);
  font-size: 13px; font-weight: 600; color: var(--nw-label); cursor: pointer; user-select: none; }
.nw-group-head:first-child { border-top: 0; }
.nw-group-head .n { color: var(--nw-label-3); font-weight: 500; }
.nw-group-head .caret { margin-left: auto; color: var(--nw-label-3); font-size: 10px; transition: transform .2s ease; }
.nw-group.closed .nw-group-head .caret { transform: rotate(-90deg); }
.nw-group.closed .nw-row { display: none; }
.nw-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; min-height: 42px; border-bottom: 1px solid var(--nw-sep);
  color: var(--nw-label); font-size: 13.5px; transition: background .12s ease; }
a.nw-row:hover, .nw-row.clickable:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nw-row .id { color: var(--nw-label-3); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 64px; }
.nw-row .title { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-row .title .muted { color: var(--nw-label-3); font-weight: 400; margin-left: 6px; }
.nw-row .meta { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; color: var(--nw-label-2); font-size: 12.5px; }
.nw-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--nw-label-2);
  box-shadow: inset 0 0 0 1px var(--nw-sep-strong); background: var(--nw-surface); white-space: nowrap; }
.nw-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--nw-label-3)); }
.nw-row .date { color: var(--nw-label-3); font-size: 12.5px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

/* striscia di statistiche alla Vercel */
.nw-statstrip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.nw-statbox { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--nw-r);
  background: var(--nw-surface-2); box-shadow: inset 0 0 0 1px var(--nw-sep); }
.nw-statbox .t { font-size: 13px; color: var(--nw-label); font-weight: 500; }
.nw-statbox .s { font-size: 12px; color: var(--nw-label-3); }
.nw-statbox .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }

/* barra filtri a tendine alla Vercel */
.nw-filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 0 16px; }
.nw-filterbar .form-select, .nw-filterbar .form-control { width: auto; min-width: 150px; }
.nw-filterbar .nw-search { flex: 1 1 260px; }


/* ===== strato 2.0 Linear ===== */
/* ==========================================================================
   NOWY UI 2.0 — "Linear": denso, preciso, premium. Si carica per ULTIMO.
   13px, righe 34-36px, pulsanti 28px, accento indaco, fili al posto delle ombre,
   percorso piccolo al posto del titolone, tema scuro curato come principale.
   ========================================================================== */
:root {
  --nw-accent: #5e6ad2; --nw-accent-hover: #6c78e6; --nw-accent-tint: rgba(94, 106, 210, .12);
  --bs-primary: #5e6ad2; --bs-primary-rgb: 94, 106, 210; --bs-link-color: #5e6ad2;
  --nw-canvas: #f4f5f8; --nw-panel-bg: #ffffff; --nw-surface: #ffffff; --nw-surface-2: #f8f9fb; --nw-band: #f4f5f7;
  --nw-label: #1b1c1f; --nw-label-2: #5f636b; --nw-label-3: #8b8f97;
  --nw-border: #e6e7eb; --nw-sep: #eceef1; --nw-sep-strong: #dfe1e6;
  --nw-fill: rgba(27, 28, 31, .06); --nw-fill-2: rgba(27, 28, 31, .035);
  --nw-r-lg: 8px; --nw-r: 7px; --nw-r-sm: 6px;
  --nw-elev-1: 0 0 0 1px var(--nw-border); --nw-elev-2: 0 0 0 1px var(--nw-sep-strong), 0 8px 24px -8px rgba(16, 18, 27, .18);
  --nw-highlight: 0 0 #0000; --nw-shadow: var(--nw-elev-1);
  --nw-font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
html[data-theme="dark"] {
  --nw-accent: #7079e0; --nw-accent-hover: #828af0; --nw-accent-tint: rgba(112, 121, 224, .16);
  --bs-primary: #7079e0; --bs-link-color: #8c93f0;
  --nw-canvas: #0f1011; --nw-panel-bg: #151618; --nw-surface: #18191c; --nw-surface-2: #1c1d21; --nw-band: #1b1c20;
  --nw-label: #eeeff1; --nw-label-2: #9a9ea6; --nw-label-3: #6c7078;
  --nw-border: rgba(255, 255, 255, .07); --nw-sep: rgba(255, 255, 255, .055); --nw-sep-strong: rgba(255, 255, 255, .10);
  --nw-fill: rgba(255, 255, 255, .07); --nw-fill-2: rgba(255, 255, 255, .04);
  --nw-elev-1: 0 0 0 1px var(--nw-border); --nw-elev-2: 0 0 0 1px var(--nw-sep-strong), 0 16px 40px -12px rgba(0, 0, 0, .8);
  --nw-sidebar: #0f1011;
}

/* --- tipografia -------------------------------------------------------------------------------------- */
body { font-family: var(--nw-font); font-size: 13px; letter-spacing: -.003em; font-feature-settings: "cv11", "ss01", "ss03";
  background: var(--nw-canvas); color: var(--nw-label); }
.small, small { font-size: 12px; }
.text-muted, .nw-note { color: var(--nw-label-2) !important; }

/* --- struttura: tela + finestra ------------------------------------------------------------------------ */
.sidebar { width: 232px; flex-basis: 232px; padding: 0 8px 20px 10px; }
.content { margin: 6px 6px 6px 0; height: calc(100vh - 12px); border-radius: 10px; background: var(--nw-panel-bg);
  box-shadow: 0 0 0 1px var(--nw-border), 0 1px 2px rgba(16, 18, 27, .04); padding: 0 24px 40px; }
html[data-theme="dark"] .content { box-shadow: 0 0 0 1px var(--nw-border); }

/* barra in alto: percorso piccolo al posto del titolone */
.topbar { margin: 0 -24px 16px; padding: 10px 20px; min-height: 46px; background: var(--nw-panel-bg);
  border-bottom: 1px solid var(--nw-sep); border-radius: 10px 10px 0 0; align-items: center; }
.topbar h1 { font-size: 13.5px; font-weight: 500; letter-spacing: -.01em; display: flex; align-items: center; gap: 6px; }
.nw-crumb { color: var(--nw-label-2); font-weight: 500; }
.nw-crumb-sep { color: var(--nw-label-3); font-weight: 400; margin: 0 6px; }
.topbar .subtitle { font-size: 12px; color: var(--nw-label-3); margin-top: 0; }
.topbar .d-flex > div > .subtitle { display: none; }   /* il contesto va nella pagina, non sotto il percorso */
.topbar-right { gap: 6px; }
.topbar-right .badge.text-bg-warning-subtle { font-size: 11px; font-weight: 500; }
.user { font-size: 12px; }

/* --- pulsanti 28px ------------------------------------------------------------------------------------ */
.btn { height: 28px; padding: 0 10px; font-size: 12.5px; font-weight: 500; border-radius: 6px; display: inline-flex; align-items: center;
  gap: 6px; letter-spacing: -.005em; line-height: 1; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 34px; font-size: 13.5px; }
.btn:active { transform: none; }
.btn-primary { background: var(--nw-accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 0 0 1px rgba(0, 0, 0, .06); }
.btn-primary:hover, .btn-primary:focus { background: var(--nw-accent-hover); color: #fff; }
.btn-success { background: #4cb782; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-danger { background: #eb5757; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-outline-secondary, .btn[class*="btn-outline-"] { background: transparent !important; color: var(--nw-label) !important;
  box-shadow: inset 0 0 0 1px var(--nw-sep-strong) !important; }
.btn-outline-secondary:hover, .btn[class*="btn-outline-"]:hover { background: var(--nw-fill-2) !important; }
.btn-outline-primary { color: var(--nw-accent) !important; }
.btn-outline-danger { color: #eb5757 !important; } .btn-outline-success { color: #4cb782 !important; }
td .btn-outline-secondary { box-shadow: none !important; color: var(--nw-label-2) !important; }
td .btn-outline-secondary:hover { color: var(--nw-label) !important; }
.btn-pill { border-radius: 6px !important; }

/* --- campi 30px -------------------------------------------------------------------------------------- */
.form-control, .form-select { min-height: 30px; font-size: 13px; border-radius: 6px; box-shadow: none; border-color: var(--nw-sep-strong);
  background-color: transparent; padding-top: 4px; padding-bottom: 4px; }
.form-control-sm, .form-select-sm { min-height: 28px; font-size: 12.5px; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 3px var(--nw-accent-tint); border-color: var(--nw-accent); background-color: transparent; }
html[data-theme="dark"] .form-select { background-color: var(--nw-surface); }
.form-label { font-size: 12px; font-weight: 500; }
.nw-search .form-control { background: var(--nw-fill-2); border-color: transparent; }

/* --- card, pannelli: fili, niente ombre ------------------------------------------------------------- */
.card, .kpi, .nw-stat, .board-col, .nw-list, .nw-metrics { border-radius: 8px; box-shadow: 0 0 0 1px var(--nw-border) !important; background: var(--nw-surface); }
.card-header { background: transparent !important; font-size: 13px; font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--nw-sep); }
.card-body { padding: 14px; }
a.kpi:hover, a.nw-stat:hover { transform: none; background: var(--nw-surface-2); }
.kpi, .nw-stat { padding: 12px 14px; }
.kpi .label, .nw-stat .label { font-size: 12px; }
.kpi .value, .nw-stat .value { font-size: 22px; font-weight: 600; }
.nw-metric { padding: 12px 14px 10px; }
.nw-metric .value { font-size: 20px; font-weight: 600; }
.nw-h2 { font-size: 14px; font-weight: 600; margin: 22px 0 10px; letter-spacing: -.01em; }
.nw-h2 .hint { font-size: 12px; }
.alert { border-radius: 8px; font-size: 13px; padding: 10px 14px; box-shadow: none; }

/* --- tabelle: righe 36px ------------------------------------------------------------------------------ */
table.table { font-size: 13px; }
table.table thead th { font-size: 12px; font-weight: 500; color: var(--nw-label-3); padding: 8px 12px; background: var(--nw-band) !important; }
table.table td { padding: 7px 12px; border-color: var(--nw-sep); }
table.table tbody tr:hover { box-shadow: none; background: var(--nw-fill-2); }

/* --- segmenti, chip, pillole alla Linear -------------------------------------------------------------- */
.nw-seg { padding: 2px; border-radius: 7px; background: var(--nw-fill-2); box-shadow: inset 0 0 0 1px var(--nw-sep); gap: 0; }
.nw-seg > a, .nw-seg > button, .nw-seg > label { font-size: 12.5px; padding: 3px 10px; border-radius: 5px; font-weight: 500; color: var(--nw-label-2); }
.nw-seg > .active, .nw-seg > input:checked + label { background: var(--nw-surface); color: var(--nw-label);
  box-shadow: 0 0 0 1px var(--nw-sep-strong), 0 1px 1px rgba(0, 0, 0, .04); }
html[data-theme="dark"] .nw-seg > .active { background: #26272c; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
.nw-chip { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1px var(--nw-sep-strong); font-weight: 500; }
.nw-chip.active { background: var(--nw-fill); color: var(--nw-label); box-shadow: inset 0 0 0 1px var(--nw-sep-strong); }
html[data-theme="dark"] .nw-chip.active { background: rgba(255, 255, 255, .09) !important; color: var(--nw-label) !important; }
.nw-chip.suggested, .nw-tag.suggested { box-shadow: none; border: 1px dashed var(--nw-sep-strong); }
.nw-tag { border-radius: 999px; font-size: 12px; padding: 2px 9px; background: transparent; box-shadow: inset 0 0 0 1px var(--nw-sep-strong); color: var(--nw-label-2); }
.badge { font-size: 11px; font-weight: 500; padding: 3px 8px; box-shadow: none; }
.pill { font-size: 12px; padding: 2px 8px; background: transparent; box-shadow: inset 0 0 0 1px var(--nw-sep-strong); color: var(--nw-label-2); }

/* codici: tabellari, grigi, spaziati (ENG-2459) */
.mono, .nw-row .id, .nw-code { font-family: var(--nw-font); font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--nw-label-3); font-size: 12.5px; font-weight: 500; }
.nw-row .title .mono { color: var(--nw-label-3); }

/* avatar a sfumatura (persone) */
.nw-avatar { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--a1, #8ec5fc), var(--a2, #a78bfa));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); flex: 0 0 auto; }

/* --- liste raggruppate: fascia di gruppo + righe 36px ------------------------------------------------- */
.nw-group-head { background: var(--nw-band); font-size: 13px; font-weight: 500; padding: 7px 16px; border-color: var(--nw-sep); }
.nw-group-head .n { color: var(--nw-label-3); }
.nw-row { min-height: 36px; padding: 6px 16px; font-size: 13px; border-color: var(--nw-sep); gap: 10px; }
.nw-row .title { font-weight: 500; color: var(--nw-label); }
.nw-row .title .muted { font-weight: 400; color: var(--nw-label-3); }
.nw-row .date { font-size: 12px; }
.nw-statbox { border-radius: 8px; background: transparent; box-shadow: inset 0 0 0 1px var(--nw-sep); padding: 10px 14px; }
.nw-statbox .v { font-size: 18px; font-weight: 600; }

/* --- righe proprietà alla Linear (etichetta grigia a sinistra, valore a destra) --------------------- */
.nw-props { display: grid; grid-template-columns: 120px 1fr; row-gap: 4px; column-gap: 12px; align-items: center; font-size: 13px; }
.nw-props > dt { font-weight: 400; color: var(--nw-label-3); margin: 0; padding: 4px 0; }
.nw-props > dd { margin: 0; padding: 3px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; color: var(--nw-label); }

/* --- barra laterale alla Linear ----------------------------------------------------------------------- */
.nw-side-head { padding: 12px 2px 8px; }
.nw-logo { width: 22px; height: 22px; border-radius: 6px; font-size: 12px; }
.nw-ws-name { font-size: 13.5px; font-weight: 600; }
.nw-side-new { display: flex; gap: 6px; margin: 0 2px 10px; }
.nw-side-new a { height: 28px; border-radius: 6px; display: inline-flex; align-items: center; color: var(--nw-label); font-size: 13px; font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--nw-sep-strong); background: var(--nw-surface); }
html[data-theme="dark"] .nw-side-new a { background: #18191c; }
.nw-side-new a:hover { background: var(--nw-surface-2); color: var(--nw-label); }
.nw-side-new .new { flex: 1; gap: 8px; padding: 0 9px; }
.nw-side-new .new i { color: var(--nw-label-2); }
.nw-side-new .find { width: 28px; justify-content: center; color: var(--nw-label-2); }
.nw-side-compose, .nw-side-icon { display: none; }
.nav-item { padding: 4px 8px; margin: 1px 0; font-size: 13px; font-weight: 450; border-radius: 6px; min-height: 28px; gap: 9px; }
.nav-item.active, html[data-theme="dark"] .nav-item.active { background: var(--nw-fill); box-shadow: none; font-weight: 500; }
.sidebar .nav-item .ico { width: 16px; height: 16px; flex-basis: 16px; }
.sidebar .nav-item .ico i { font-size: 14.5px; }
.nw-nav-toggle { padding: 14px 8px 4px; font-size: 11.5px; }
.nw-count { height: 18px; min-width: 20px; font-size: 11px; border-radius: 5px; font-weight: 500; }

/* planning */
.board-list { background: transparent; }
.dcard { border-radius: 7px; padding: 8px 10px; box-shadow: 0 0 0 1px var(--nw-sep-strong), inset 2px 0 0 var(--nw-accent); }
.dcard:hover { transform: none; box-shadow: 0 0 0 1px var(--nw-label-3), inset 2px 0 0 var(--nw-accent); }
.dcard .t { font-size: 13px; font-weight: 500; }

@media (max-width: 992px) { .content { margin: 0; border-radius: 0; height: auto; padding: 0 14px 30px; } .topbar { margin: 0 -14px 14px; border-radius: 0; } }

/* filtri in barra: i campi non vanno a tutta larghezza (date, select) */
.nw-toolbar .form-control, .nw-toolbar .form-select, .nw-filterbar .form-control, .nw-filterbar .form-select { width: auto; flex: 0 0 auto; }
.nw-toolbar .nw-search .form-control { width: 100%; }
.nw-toolbar form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* ==========================================================================
   NOWY UI 2.1 — navigazione istantanea + identita' NOWY. Ultimo strato del foglio unico v2.
   1. Fluidita': solo il pannello #nw-main cambia e si dissolve (<=140ms); menu fermo, niente strati
      di composizione inutili, niente filtri/sfocature su aree grandi.
   2. Identita': marchio "N a tracciato", segno d'accento a tracciato (voce attiva, barra di caricamento,
      fuoco), stati vuoti illustrati, numeri tabellari ovunque.
   Solo token --nw-* / --st-*.
   ========================================================================== */
:root {
  --nw-brand: #5e6ad2;            /* indaco NOWY */
  --nw-brand-2: #8b7cf6;          /* viola del tracciato (solo nei segni d'identita') */
  --nw-on-brand: #ffffff;
  --nw-route: linear-gradient(90deg, var(--nw-brand), var(--nw-brand-2));
  --nw-focus-ring: 0 0 0 2px var(--nw-panel-bg), 0 0 0 3.5px var(--nw-accent);
  --nw-hint-bg: rgba(94, 106, 210, .06);
  --nw-dur-fast: 90ms; --nw-dur: 140ms;
  --nw-ease-out: cubic-bezier(.2, .8, .2, 1);
}
html[data-theme="dark"] {
  --nw-brand: #7079e0; --nw-brand-2: #a193ff; --nw-on-brand: #ffffff;
  --nw-hint-bg: rgba(112, 121, 224, .09);
}

/* --- 1. fluidita' ------------------------------------------------------------------------------------- */
/* niente livelli di composizione forzati su centinaia di elementi (memoria GPU e scatti durante lo scroll) */
.card, .kpi, .dcard, .btn, .nav-item { backface-visibility: visible; }
.sidebar, .sidebar * { will-change: auto; }
.sidebar { backdrop-filter: none; -webkit-backdrop-filter: none; overscroll-behavior: contain; }

/* transizione di pagina SOLO sul pannello del contenuto: la radice non viene catturata, menu e barra restano vivi */
:root { view-transition-name: none; }
.sidebar, .topbar { view-transition-name: none; }
.content { view-transition-name: nw-main; }
::view-transition-group(nw-main) { animation: none; }
::view-transition-old(nw-main) { animation: nw-vt-fade-out var(--nw-dur-fast) ease-out both; }
::view-transition-new(nw-main) { animation: nw-vt-fade-in var(--nw-dur) var(--nw-ease-out) both; }
@keyframes nw-vt-fade-out { to { opacity: 0; } }
@keyframes nw-vt-fade-in { from { opacity: 0; } }

/* richiesta lenta (>300 ms): il pannello si attenua, senza spostare nulla */
#nw-main.nw-stale { opacity: .6; transition: opacity .2s ease .05s; }
#nw-main { transition: opacity var(--nw-dur-fast) ease; }

/* barra di caricamento: segno a tracciato, 2px, parte subito */
.nw-progress { height: 2px; background: var(--nw-route); box-shadow: none; }
.nw-progress.run { transition: width 6s cubic-bezier(.08, .8, .2, 1), opacity 60ms; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(nw-main), ::view-transition-new(nw-main) { animation: none !important; }
  #nw-main.nw-stale { transition: none; }
}

/* --- 2. menu laterale ------------------------------------------------------------------------------- */
.sidebar { display: flex; flex-direction: column; }
.nw-nav { flex: 1 1 auto; }
.nav-item { position: relative; transition: background-color var(--nw-dur-fast) ease, color var(--nw-dur-fast) ease; }
.sidebar .nav-item .ico i { transition: none; }
.nav-item:active { background: var(--nw-fill); }
/* voce attiva: fondo leggero + segno a tracciato a sinistra (firma NOWY) */
.nav-item.active::before, .nav-item.is-pending::before { content: ""; position: absolute; left: -6px; top: 7px; bottom: 7px; width: 2.5px;
  border-radius: 2px; background: linear-gradient(180deg, var(--nw-brand), var(--nw-brand-2)); }
.nav-item.is-pending { background: var(--nw-fill); font-weight: 500; }
.sidebar .nav-item.active .ico i, .sidebar .nav-item.is-pending .ico i { color: var(--nw-accent); }
.nw-count[hidden] { display: none !important; }
.nav-item .nw-count { font-variant-numeric: tabular-nums; }
.nav-item[data-nav="/anomalies"] .nw-count:not([hidden]) { color: var(--st-error); background: color-mix(in srgb, var(--st-error) 12%, transparent); }
.nav-item[data-nav="/bordereaux"] .nw-count:not([hidden]) { color: var(--st-partial); background: color-mix(in srgb, var(--st-partial) 13%, transparent); }

/* marchio: loghi NOWY ufficiali (brand/*.svg) usati come maschera -> prendono il colore del tema */
.nw-logo { width: 22px; height: 22px; background: none !important; box-shadow: none !important; border-radius: 0; color: var(--nw-label); }
.nw-mark, .nw-wordmark, .nw-brand-logo { display: inline-block; flex: none; background-color: currentColor;
  -webkit-mask: var(--nw-mask) center / contain no-repeat; mask: var(--nw-mask) center / contain no-repeat; }
.nw-mark { --nw-mask: url("brand/nowy-mark.svg"); width: 22px; height: 22px; }
.nw-wordmark { --nw-mask: url("brand/nowy-wordmark.svg"); height: 11px; aspect-ratio: 235.25 / 61.5; }
.nw-brand-logo { --nw-mask: url("brand/nowy-logo.svg"); width: 120px; aspect-ratio: 235.25 / 306.17; }
.nw-logo .nw-mark { width: 100%; height: 100%; }
html[data-theme] .nw-logo { color: var(--nw-label); }
.nw-ws-name { font-weight: 650; letter-spacing: .02em; display: inline-flex; align-items: center; color: var(--nw-label); }
.nw-ws-name .nw-wordmark { height: 11px; }
.nw-ws-sub { font-size: 12px; color: var(--nw-label-3); font-weight: 500; margin-left: -3px; }
.nw-side-new .new i { color: var(--nw-accent); }

/* piede del menu: utente, tema, esci */
.nw-side-foot { display: flex; align-items: center; gap: 2px; margin: 10px 2px 0; padding-top: 8px; border-top: 1px solid var(--nw-sep); }
.nw-side-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px 6px; font-size: 12.5px; color: var(--nw-label-2); }
.nw-side-btn { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--nw-label-2); font-size: 14px; }
.nw-side-btn:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.sidebar { padding-bottom: 12px; }

/* barra in alto: piu' pulita (utente ed esci vanno nel menu) */
.nw-demo-tag { font-size: 11px; color: var(--nw-label-3); padding: 1px 7px; }

/* --- 3. identita' ----------------------------------------------------------------------------------- */
/* fuoco: doppio anello (stacco + indaco), uguale su pulsanti, campi, righe e voci di menu */
:focus:not(:focus-visible) { outline: none; }
button:focus-visible, .btn:focus-visible, .nav-item:focus-visible, .nw-row:focus-visible, .nw-chip:focus-visible,
.nw-seg > :focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: none; box-shadow: var(--nw-focus-ring) !important; }
a:focus-visible { outline: 2px solid var(--nw-accent); outline-offset: 2px; border-radius: 4px; }
.nav-item:focus-visible, .nw-row:focus-visible, .nw-chip:focus-visible { outline: none; }
.form-control:focus, .form-select:focus, .form-check-input:focus { box-shadow: var(--nw-focus-ring) !important; border-color: var(--nw-accent); }

/* numeri tabellari: colonne allineate come in un foglio */
table.table td, table.table th, .nw-row .date, .nw-row .meta, .kpi .value, .nw-metric .value, .nw-statbox .v, .nw-count,
.badge, .nw-code, .lv-num { font-variant-numeric: tabular-nums; }
body { font-feature-settings: "cv11", "ss01", "ss03", "tnum" 0; }

/* stato vuoto illustrato NOWY: la tessera dell'icona sta su un tracciato tratteggiato
   (partenza = punto indaco, arrivo = anello). Vale per OGNI .nw-empty, senza cambiare il markup. */
.nw-empty { background: none; }
.nw-empty > i.bi:first-child { position: relative; overflow: visible; width: 44px; height: 44px; border-radius: 11px;
  font-size: 19px; margin-bottom: 10px; color: var(--nw-accent); background: var(--nw-surface);
  box-shadow: 0 0 0 1px var(--nw-border), 0 2px 6px -2px rgba(16, 18, 27, .10); }
.nw-empty > i.bi:first-child::after { content: ""; position: absolute; left: 50%; top: 50%; width: 176px; height: 10px;
  transform: translate(-50%, -50%); pointer-events: none;
  background:
    radial-gradient(circle at 5px 5px, var(--nw-brand) 3.2px, transparent 3.8px),
    radial-gradient(circle at calc(100% - 5px) 5px, transparent 2.6px, var(--nw-label-3) 3px, transparent 4.2px),
    repeating-linear-gradient(90deg, var(--nw-sep-strong) 0 4px, transparent 4px 8px) center / calc(100% - 20px) 1.5px no-repeat;
  -webkit-mask: linear-gradient(90deg, #000 calc(50% - 30px), transparent calc(50% - 30px) calc(50% + 30px), #000 calc(50% + 30px));
          mask: linear-gradient(90deg, #000 calc(50% - 30px), transparent calc(50% - 30px) calc(50% + 30px), #000 calc(50% + 30px)); }
.nw-empty .title { font-size: 13.5px; font-weight: 600; color: var(--nw-label); }
.nw-empty .hint { font-size: 12.5px; color: var(--nw-label-2); margin-top: 2px; }
.nw-empty-actions { margin-top: 12px; display: inline-flex; gap: 6px; }
@media (forced-colors: active) { .nw-empty > i.bi:first-child::after { display: none; } }

/* riga di aiuto: una frase che dice cosa fare */
.nw-hint { display: flex; align-items: flex-start; gap: 8px; padding: 7px 12px; margin: 0 0 14px; border-radius: 7px;
  background: var(--nw-hint-bg); color: var(--nw-label-2); font-size: 12.5px; line-height: 1.45; }
.nw-hint i { color: var(--nw-accent); font-size: 13px; margin-top: 1px; }
.nw-hint b, .nw-hint strong { color: var(--nw-label); font-weight: 600; }

/* menu "…" per le azioni secondarie (una sola azione primaria a vista) */
.dropdown-menu { font-size: 13px; padding: 4px; border: 0; border-radius: 8px; background: var(--nw-surface);
  box-shadow: var(--nw-elev-2); min-width: 210px; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; color: var(--nw-label);
  font-size: 13px; width: 100%; border: 0; background: none; text-align: left; }
.dropdown-item i { color: var(--nw-label-3); font-size: 14px; width: 16px; text-align: center; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--nw-fill-2); color: var(--nw-label); }
.dropdown-item.text-danger i, .dropdown-item.danger, .dropdown-item.danger i { color: var(--st-error) !important; }
.dropdown-divider { margin: 4px 0; border-color: var(--nw-sep); }
.dropdown-header { font-size: 11.5px; color: var(--nw-label-3); padding: 6px 8px 4px; }
.nw-more-btn { width: 28px; padding: 0; justify-content: center; }
.nw-more-btn::after { display: none; }

/* --- campanella (era uno stile in base.html) --------------------------------------------------------- */
.nw-bell-btn { position: relative; }
.nw-bell-count { position: absolute; top: -6px; right: -7px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--nw-on-brand); background: var(--nw-accent); box-shadow: 0 0 0 2px var(--nw-panel-bg); }
.nw-bell-count.urgent { background: var(--st-error); }
.nw-bell-panel { width: min(380px, calc(100vw - 32px)); padding: 0; overflow: hidden; border: 0; border-radius: var(--nw-r);
  background: var(--nw-surface); box-shadow: var(--nw-elev-2); }
.nw-bell-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 8px; font-size: 13px; font-weight: 600;
  color: var(--nw-label); border-bottom: 1px solid var(--nw-sep); }
.nw-bell-panel .nw-rem-list { max-height: 60vh; overflow-y: auto; }
.nw-bell-empty { padding: 24px 16px; text-align: center; font-size: 12.5px; color: var(--nw-label-2); }
.nw-bell-empty i { font-size: 22px; color: var(--st-ready); }
.nw-bell-empty .title { font-weight: 600; color: var(--nw-label); margin-top: 4px; }
.nw-rem { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; text-decoration: none; color: var(--nw-label);
  border-bottom: 1px solid var(--nw-sep); transition: background-color var(--nw-dur-fast) ease; }
.nw-rem:last-child { border-bottom: 0; }
.nw-rem:hover { background: var(--nw-fill-2); color: var(--nw-label); }
.nw-rem-ico { flex: none; width: 26px; height: 26px; border-radius: var(--nw-r-sm); display: inline-flex; align-items: center;
  justify-content: center; font-size: 13px; color: var(--nw-accent); background: var(--nw-accent-tint); }
.nw-rem-warning .nw-rem-ico { color: var(--st-partial); background: color-mix(in srgb, var(--st-partial) 13%, transparent); }
.nw-rem-danger .nw-rem-ico { color: var(--st-error); background: color-mix(in srgb, var(--st-error) 12%, transparent); }
.nw-rem-body { display: flex; flex-direction: column; min-width: 0; }
.nw-rem-title { font-size: 13px; font-weight: 500; }
.nw-rem-detail { font-size: 12px; color: var(--nw-label-2); }
.nw-rem-go { margin-left: auto; align-self: center; font-size: 12px; color: var(--nw-label-3); }

/* --- piccoli aggiustamenti di gerarchia --------------------------------------------------------------- */
.card-header .hint { font-weight: 400; font-size: 12px; color: var(--nw-label-3); margin-left: 6px; }
.topbar-right .btn-primary { font-weight: 550; }
.nw-step { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; font-weight: 600; color: var(--nw-accent); background: var(--nw-accent-tint); margin-right: 6px; flex: none; }
.card-header .nw-step { margin-right: 8px; }

@media (max-width: 640px) {
  /* telefono: la barra in alto va a capo invece di uscire dallo schermo */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar-right { flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
  .nw-crumb-section { display: none; }
}
@media (max-width: 992px) {
  .nav-item.active::before, .nav-item.is-pending::before { left: -4px; }
}
