:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --primary-soft: #ede9fe;
  --primary-glow: rgba(124, 58, 237, 0.26);

  --accent-cyan: #22d3ee;
  --accent-pink: #f472b6;
  --accent-amber: #fbbf24;
  --accent-emerald: #34d399;
  --accent-blue: #60a5fa;

  --bg: #f3f0ff;
  --panel: #ffffff;
  --panel-soft: #faf8ff;
  --line: #e4dcff;
  --line-strong: #c4b5fd;
  --sidebar: #120f24;
  --sidebar-2: #1c1638;
  --sidebar-border: #2e2452;
  --text: #1e1b4b;
  --muted: #7c3aad;

  --petrol: var(--primary);
  --violet: var(--primary-light);
  --magenta: var(--accent-pink);
  --orange: #fb923c;
}

body {
  background:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(167, 139, 250, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse 90% 60% at -10% 100%, rgba(244, 114, 182, 0.1) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 1px 0 rgba(124, 58, 237, 0.04),
    0 12px 32px -24px rgba(91, 33, 182, 0.18);
}
.panel-soft {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover {
  border-color: var(--primary-light);
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.kpi {
  background: linear-gradient(145deg, #fff 0%, #faf8ff 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-pink) 50%, var(--accent-cyan) 100%);
  opacity: 0.8;
}
.kpi .label { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.kpi .value { font-size: 23px; font-weight: 700; line-height: 1.2; margin-top: 4px; letter-spacing: -0.01em; color: var(--text); }

.erp-table { width: 100%; font-size: 13px; border-collapse: separate; border-spacing: 0; }
.erp-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  color: var(--primary-dark);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-strong);
}
.erp-table tbody td { padding: 8px 10px; border-bottom: 1px solid #ebe6ff; white-space: nowrap; }
.erp-table tbody tr:hover { background: #f5f3ff; }

.app-sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0d0a1a 100%);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 4px 0 24px rgba(91, 33, 182, 0.14);
}
.app-sidebar.is-ready { display: flex; flex-direction: column; }
.sidebar-brand {
  border-bottom: 1px solid var(--sidebar-border);
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.14) 0%, transparent 70%);
}
.sidebar-brand-kicker {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary-light);
  margin: 0;
}
.sidebar-brand-title {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.sidebar-section { margin-bottom: 14px; }
.sidebar-section-label {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a78bfa;
}
.sidebar-section-items { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-items:has(.sidebar-link-child) {
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(167, 139, 250, 0.35);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c4b5fd;
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.sidebar-link-child {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 0 8px 8px 0;
}
.sidebar-section.is-open .sidebar-link-child.active { border-left-color: var(--accent-pink); }
.sidebar-link-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.sidebar-link-icon svg { width: 18px; height: 18px; display: block; }
.sidebar-link:hover {
  background: rgba(124, 58, 237, 0.22);
  color: #fff;
  transform: translateX(2px);
}
.sidebar-link:hover .sidebar-link-icon { opacity: 1; color: var(--accent-cyan); }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.42) 0%, rgba(244, 114, 182, 0.18) 100%);
  color: #fff;
  border: 1px solid rgba(167, 139, 250, 0.45);
  box-shadow: inset 3px 0 0 var(--accent-pink), 0 4px 14px var(--primary-glow);
}
.sidebar-link.active .sidebar-link-icon { opacity: 1; color: #f9a8d4; }

.badge { border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge-ok { background: #d1fae5; color: #047857; border: 1px solid #6ee7b7; }
.badge-warn { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }
.badge-bad { background: #ffe4e6; color: #be123c; border: 1px solid #fda4af; }

.metric-up { color: #059669; font-weight: 600; }
.metric-down { color: #e11d48; font-weight: 600; }
.link-accent { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.link-accent:hover { color: var(--primary-dark); }

.focus-btn {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 50%, var(--accent-pink) 100%);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.focus-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}
.accent-btn {
  background: linear-gradient(135deg, var(--accent-amber) 0%, #fb923c 100%);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(251, 146, 60, 0.32);
}
.accent-btn:hover { filter: brightness(1.05); }

.glass-topbar,
.page-topbar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line) !important;
  box-shadow: 0 4px 20px -12px rgba(124, 58, 237, 0.14);
}
.search-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.32);
}

.nested {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fdfcff 0%, #f5f3ff 100%);
  border-radius: 10px;
}
.metric-ring {
  width: 132px;
  height: 132px;
  border-radius: 999px;
  background:
    radial-gradient(closest-side, #fff 72%, transparent 73% 100%),
    conic-gradient(var(--accent-pink) 0 78%, #ede9fe 0 100%);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
}
.metric-ring span { font-size: 39px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; color: var(--primary-dark); }
.metric-ring small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.progress-track { height: 16px; border-radius: 999px; background: #ede9fe; overflow: hidden; }
.progress-bar-violet {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--primary) 45%, var(--accent-pink) 100%);
}
.spark-bar { height: 64px; border-radius: 10px 10px 0 0; background: linear-gradient(180deg, #4c1d95 0%, #312e81 100%); }
.spark-bar.active {
  background: linear-gradient(180deg, var(--accent-pink) 0%, var(--primary) 100%);
  box-shadow: inset 0 0 0 2px #f9a8d4;
}
.kpi-trend { font-size: 11px; margin-top: 3px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kpi-trend strong.up { color: #059669; }
.kpi-trend strong.down { color: #e11d48; }
.kpi-spark { display: inline-flex; align-items: end; gap: 2px; height: 14px; }
.kpi-spark i { width: 3px; background: #c4b5fd; border-radius: 2px; display: block; }
.kpi-spark i:last-child { background: linear-gradient(180deg, var(--primary-light), var(--primary)); }

.alert-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-bottom: 1px solid #ebe6ff;
  font-size: 12px;
}
.alert-dot { width: 8px; height: 8px; border-radius: 999px; }
.alert-high .alert-dot { background: #f43f5e; box-shadow: 0 0 6px rgba(244, 63, 94, 0.45); }
.alert-mid .alert-dot { background: var(--accent-amber); box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
.alert-low .alert-dot { background: var(--accent-cyan); box-shadow: 0 0 6px rgba(34, 211, 238, 0.4); }
.quick-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  font-size: 12px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.quick-link:hover { background: var(--primary-soft); border-color: var(--primary-light); }

.chip-active { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); color: #fff; border-color: transparent; }
.tint-violet { background: var(--primary-soft); color: var(--primary-dark); }
.tint-pink { background: #fce7f3; color: #be185d; }
.tint-cyan { background: #cffafe; color: #0e7490; }
.tint-amber { background: #fef3c7; color: #b45309; }

.chart-card { padding: 12px; }
.chart-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend .dot-cost { background: linear-gradient(135deg, #c4b5fd, #a78bfa); }
.chart-legend .dot-rev { background: linear-gradient(135deg, var(--primary), var(--accent-pink)); }
.chart-wrap { display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: stretch; }
.chart-y-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 10px; color: #8b5cf6; text-align: right; padding: 4px 0 18px; }
.chart-plot {
  position: relative;
  height: 200px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #faf8ff 100%);
  border-radius: 0 0 8px 0;
}
.chart-grid { position: absolute; inset: 0 18px 0 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid span { border-top: 1px dashed #e9d5ff; width: 100%; }
.chart-bars { position: absolute; inset: 0 0 18px 0; display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; padding: 0 4px; }
.chart-group { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.chart-bar { width: 10px; border-radius: 3px 3px 0 0; min-height: 4px; position: relative; cursor: default; transition: opacity 0.15s, transform 0.15s; }
.chart-bar:hover { opacity: 0.9; transform: scaleY(1.02); transform-origin: bottom; }
.chart-bar.cost { background: linear-gradient(180deg, #ddd6fe 0%, #a78bfa 100%); }
.chart-bar.rev { background: linear-gradient(180deg, #f9a8d4 0%, var(--primary) 55%, #5b21b6 100%); }
.chart-bar::after {
  content: attr(data-value);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--primary-dark);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.chart-bar:hover::after { opacity: 1; }
.chart-x-axis { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; margin-top: 6px; padding: 0 4px; font-size: 10px; color: #7c3aed; text-align: center; }
.chart-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.chart-summary-item {
  background: linear-gradient(145deg, #faf8ff, #fff);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.chart-summary-item p { font-size: 10px; color: var(--muted); margin: 0; }
.chart-summary-item strong { display: block; font-size: 14px; margin-top: 2px; color: var(--text); }
.chart-summary-item strong.up { color: #059669; }
.chart-summary-item strong.down { color: #e11d48; }

.breakdown-bars { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.breakdown-row { display: grid; grid-template-columns: 88px 1fr 36px; gap: 8px; align-items: center; font-size: 11px; }
.breakdown-track { height: 8px; border-radius: 999px; background: #ede9fe; overflow: hidden; }
.breakdown-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #9333ea); }
.breakdown-fill.alt { background: linear-gradient(90deg, var(--accent-pink), #ec4899); }
.breakdown-fill.warn { background: linear-gradient(90deg, var(--accent-amber), #f97316); }

.bar-chart-violet { background: linear-gradient(180deg, var(--primary-light), var(--primary)) !important; }
.bar-chart-muted { background: linear-gradient(180deg, #e9d5ff, #c4b5fd) !important; }

/* —— Commesse hero (focus dashboard) —— */
.commesse-hero {
  border: 1px solid var(--line-strong);
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.06),
    0 16px 48px -28px rgba(91, 33, 182, 0.28);
  overflow: hidden;
}
.commesse-hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(244, 114, 182, 0.05) 50%, #fff 100%);
  border-bottom: 1px solid var(--line);
}
.commesse-hero-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}
.commesse-hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}
.commesse-hero-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.45;
}
.commesse-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.focus-btn.accent-warroom {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.commesse-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 20px;
  background: #faf8ff;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 640px) {
  .commesse-summary { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .commesse-summary { grid-template-columns: repeat(6, 1fr); }
}
.commesse-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.commesse-stat .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}
.commesse-stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--text);
  line-height: 1.1;
}
.commesse-stat .hint {
  font-size: 10px;
  color: #8b7cb8;
  margin: 2px 0 0;
}
.commesse-stat.stat-ok { border-left: 3px solid #34d399; }
.commesse-stat.stat-warn { border-left: 3px solid var(--accent-amber); }
.commesse-stat.stat-bad { border-left: 3px solid #f43f5e; }

.commesse-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.commesse-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.commesse-filter-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.commesse-search {
  min-width: 220px;
  max-width: 320px;
  flex: 1;
  padding: 7px 12px;
  font-size: 12px;
}

.commesse-table-wrap {
  overflow: auto;
  min-height: 320px;
  max-height: min(58vh, 520px);
}
.commesse-table thead th {
  background: linear-gradient(180deg, #ede9fe 0%, #e4dcff 100%);
  color: var(--primary-dark);
  font-size: 10px;
  padding: 11px 12px;
  white-space: nowrap;
}
.commesse-table tbody td {
  padding: 12px;
  vertical-align: middle;
  white-space: nowrap;
}
.commesse-table tbody tr {
  transition: background 0.12s;
}
.commesse-table tbody tr:hover {
  background: #f5f3ff;
}
.commesse-table tbody tr.row-warn {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.08) 0%, transparent 40%);
}
.commesse-table tbody tr.row-bad {
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.08) 0%, transparent 40%);
}
.commesse-name {
  display: block;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}
.commesse-site {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 400;
}
.cell-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}
.cell-progress .progress-track {
  flex: 1;
  height: 8px;
  min-width: 56px;
}
.cell-progress span {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-dark);
  min-width: 32px;
}
.cell-progress-warn .progress-bar-violet {
  background: linear-gradient(90deg, var(--accent-amber), #f97316);
}
.cell-progress-bad .progress-bar-violet {
  background: linear-gradient(90deg, #f43f5e, #be123c);
}
.alert-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.alert-pill.low { background: #ede9fe; color: var(--primary-dark); }
.alert-pill.mid { background: #fef3c7; color: #b45309; }
.alert-pill.high { background: #ffe4e6; color: #be123c; }
.doc-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.chip-sm {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

.commesse-hero-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  background: #faf8ff;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.commesse-hero-foot strong { color: var(--text); }

/* —— Contabilità commessa (matrice Excel) —— */
.commessa-anagrafica {
  display: grid;
  gap: 10px 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 768px) {
  .commessa-anagrafica { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.commessa-anagrafica dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.commessa-anagrafica dd {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.contabilita-matrix-wrap {
  overflow: auto;
  max-height: min(72vh, 680px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.contabilita-matrix {
  width: max-content;
  min-width: 100%;
  font-size: 11px;
  border-collapse: separate;
  border-spacing: 0;
}
.contabilita-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(180deg, #ede9fe 0%, #ddd6fe 100%);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  text-align: right;
}
.contabilita-matrix thead th.col-voce {
  left: 0;
  z-index: 5;
  text-align: left;
  min-width: 240px;
}
.contabilita-matrix thead th.col-year {
  text-align: center;
  background: linear-gradient(180deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #3730a3;
}
.contabilita-matrix thead th.col-total {
  background: linear-gradient(180deg, #fce7f3 0%, #fbcfe8 100%);
  color: #9d174d;
}
.contabilita-matrix tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #ebe6ff;
  border-right: 1px solid #f3f0ff;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.contabilita-matrix tbody td.col-voce {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: #fff;
  font-weight: 500;
  color: var(--text);
  border-right: 1px solid var(--line-strong);
  max-width: 280px;
}
.contabilita-matrix tbody tr:hover td { background: #f5f3ff; }
.contabilita-matrix tbody tr:hover td.col-voce { background: #f5f3ff; }
.contabilita-matrix tbody tr.row-section td {
  background: linear-gradient(90deg, #ede9fe 0%, #faf8ff 100%);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-dark);
  padding: 8px 10px;
}
.contabilita-matrix tbody tr.row-section td.col-voce {
  background: linear-gradient(90deg, #ddd6fe 0%, #ede9fe 100%);
}
.contabilita-matrix tbody tr.row-total td {
  background: #faf8ff;
  font-weight: 700;
  color: var(--primary-dark);
}
.contabilita-matrix tbody tr.row-total td.col-voce {
  background: #f5f3ff;
}
.contabilita-matrix tbody tr.row-highlight td {
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.12) 0%, transparent 100%);
}
.contabilita-matrix tbody tr.row-highlight td.col-voce {
  background: #ecfdf5;
}
.contabilita-matrix tbody tr.row-indent td.col-voce {
  padding-left: 22px;
  font-weight: 400;
  font-size: 11px;
  color: #4c1d95;
}
.contabilita-matrix .cell-pct {
  color: #059669;
  font-weight: 700;
}
.contabilita-matrix .cell-empty {
  color: #c4b5fd;
}
.contabilita-matrix .cell-month-active {
  background: rgba(167, 139, 250, 0.14) !important;
  box-shadow: inset 0 0 0 1px var(--primary-light);
}

.contabilita-matrix tr.row-child {
  display: none;
}
.contabilita-matrix tr.row-child.is-visible {
  display: table-row;
}
.contabilita-matrix tr.row-expandable .col-voce {
  cursor: pointer;
  user-select: none;
}
.contabilita-matrix tr.row-expandable:hover .col-voce {
  color: var(--primary-dark);
}
.contabilita-matrix .matrix-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}
.contabilita-matrix tr.is-expanded .matrix-toggle {
  background: var(--primary-soft);
  transform: rotate(0deg);
}
.contabilita-matrix tr.row-expandable:not(.is-expanded) .matrix-toggle {
  transform: rotate(-90deg);
}
.contabilita-matrix .voce-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.contabilita-matrix tr.row-child td.col-voce {
  padding-left: 34px;
  font-size: 11px;
  font-weight: 400;
  color: #4c1d95;
}
.contabilita-matrix tr.row-child.depth-2 td.col-voce {
  padding-left: 48px;
  font-size: 10px;
  color: #6b21a8;
}
.contabilita-matrix tr.row-expandable.is-expanded td.col-voce {
  font-weight: 700;
  color: var(--primary-dark);
}
.contabilita-matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--muted);
}

.contabilita-kpi-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 1024px) {
  .contabilita-kpi-row { grid-template-columns: repeat(5, 1fr); }
}
.contabilita-kpi {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(145deg, #fff 0%, #faf8ff 100%);
}
.contabilita-kpi .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.contabilita-kpi .value {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}
.contabilita-kpi .sub {
  font-size: 10px;
  color: #8b7cb8;
  margin-top: 2px;
}

.excel-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
}

/* —— Hub cantiere (dettaglio commessa) —— */
.cantiere-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, #faf8ff 0%, #fff 60%);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.cantiere-flow-step {
  flex: 1 1 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 10px;
  position: relative;
}
.cantiere-flow-step:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-light);
  font-size: 14px;
  font-weight: 700;
  z-index: 1;
}
.cantiere-flow-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.cantiere-flow-step.is-done .cantiere-flow-icon {
  background: #ecfdf5;
  border-color: #6ee7b7;
}
.cantiere-flow-step.is-active .cantiere-flow-icon {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}
.cantiere-flow-step.is-output .cantiere-flow-icon {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  border-color: transparent;
  color: #fff;
}
.cantiere-flow-step strong {
  font-size: 11px;
  color: var(--text);
  display: block;
}
.cantiere-flow-step span {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.cantiere-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) {
  .cantiere-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
  .cantiere-actions { grid-template-columns: repeat(6, 1fr); }
}
.cantiere-action-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.cantiere-action-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 8px 24px -16px var(--primary-glow);
  transform: translateY(-1px);
}
.cantiere-action-card .action-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 8px;
}
.cantiere-action-card h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0;
}
.cantiere-action-card p {
  font-size: 10px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.35;
}
.cantiere-action-card .action-meta {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
}

.commessa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.commessa-tab-panel { display: none; }
.commessa-tabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
#tab-panoramica:checked ~ .commessa-tab-panels #panel-panoramica,
#tab-ddt:checked ~ .commessa-tab-panels #panel-ddt,
#tab-fatture:checked ~ .commessa-tab-panels #panel-fatture,
#tab-ore:checked ~ .commessa-tab-panels #panel-ore,
#tab-altri:checked ~ .commessa-tab-panels #panel-altri,
#tab-ricavi:checked ~ .commessa-tab-panels #panel-ricavi,
#tab-contabilita:checked ~ .commessa-tab-panels #panel-contabilita {
  display: block;
}
.commessa-tabs label {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: -1px;
}
#tab-panoramica:checked ~ .commessa-tabs label[for="tab-panoramica"],
#tab-ddt:checked ~ .commessa-tabs label[for="tab-ddt"],
#tab-fatture:checked ~ .commessa-tabs label[for="tab-fatture"],
#tab-ore:checked ~ .commessa-tabs label[for="tab-ore"],
#tab-altri:checked ~ .commessa-tabs label[for="tab-altri"],
#tab-ricavi:checked ~ .commessa-tabs label[for="tab-ricavi"],
#tab-contabilita:checked ~ .commessa-tabs label[for="tab-contabilita"] {
  background: #fff;
  border-color: var(--line);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 -2px 0 var(--primary) inset;
}

.movimento-row td:first-child { font-weight: 600; color: var(--primary-dark); }
.movimento-fonte {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.movimento-fonte.fonte-ddt { background: #cffafe; color: #0e7490; }
.movimento-fonte.fonte-fattura { background: #fce7f3; color: #9d174d; }
.movimento-fonte.fonte-ore { background: #d1fae5; color: #047857; }
.movimento-fonte.fonte-manuale { background: #fef3c7; color: #b45309; }

.contabilita-auto-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.08) 0%, rgba(52, 211, 153, 0.08) 100%);
  border: 1px solid var(--line-strong);
  margin-bottom: 12px;
}
.contabilita-auto-banner p {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 200px;
}
.contabilita-auto-banner strong { color: var(--primary-dark); }

/* —— Contesto pagina / flusso moduli —— */
.page-commessa-bar {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary-soft) 0%, #fff 55%);
  padding: 10px 14px;
}
.page-commessa-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.page-commessa-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.page-commessa-link {
  font-size: 13px;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.page-commessa-link:hover { text-decoration: underline; }
.page-commessa-select { font-size: 11px; }

.module-flow-banner {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 8px 28px -22px rgba(91, 33, 182, 0.2);
}
.module-flow-banner--compact {
  padding: 10px 14px;
}
.module-flow-banner--compact .module-flow-title {
  font-size: 1rem;
  margin: 0;
}
.module-flow-banner--compact .module-flow-desc {
  font-size: 12px;
  margin: 2px 0 0;
}
.module-flow-next--compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 0;
  border-top: none;
}
.module-flow-next--compact span {
  display: none;
}
.module-flow-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.module-flow-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin: 0;
}
.module-flow-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--text);
}
.module-flow-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: #64748b;
  max-width: 62ch;
  line-height: 1.45;
}
.module-pending {
  font-size: 11px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 6px 10px;
  white-space: nowrap;
}
.module-flow-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #faf8ff;
  color: var(--muted);
  text-decoration: none;
}
.pipeline-step.is-done {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.pipeline-step.is-active {
  background: var(--primary-soft);
  border-color: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}
.pipeline-step.is-output,
a.pipeline-step.is-output {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  border-color: transparent;
  color: #fff;
}
.pipeline-icon { font-size: 12px; line-height: 1; }
.module-flow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  align-items: flex-end;
}
.module-meta-item span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.module-meta-item strong {
  display: block;
  margin-top: 2px;
  color: var(--primary-dark);
  font-size: 12px;
}
.module-flow-next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.module-flow-next > span {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.ecosystem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin-top: 12px;
  align-items: stretch;
}
.ecosystem-map .ecosystem-grid {
  margin-top: 12px;
}
.ecosystem-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  min-width: 0;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s;
}
.ecosystem-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-1px);
}
.ecosystem-card strong {
  display: block;
  font-size: 11px;
  color: var(--primary-dark);
}
.ecosystem-card span {
  font-size: 9px;
  color: var(--muted);
}
.ecosystem-card-output {
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fce7f3 100%);
  border-color: var(--line-strong);
  font-weight: 700;
}
.ecosystem-card-output::after {
  content: " ←";
  color: var(--primary);
}

/* Intestazione pagina modulo (senza banner fasi) */
.page-lead-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.page-lead-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
}
.page-lead-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 2px 0 0;
}
.page-lead-desc {
  margin: 6px 0 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  max-width: 72ch;
}

/* Listini: due tipi (documenti vs interno cantiere) */
.listini-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.listini-type-tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.listini-type-tab strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.listini-type-tab span {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  font-size: 10px;
}
.listini-type-tab.is-active {
  border-color: var(--primary-light);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.12);
}
.listini-type-tab.is-active strong {
  color: var(--primary-dark);
}
.listini-panel[hidden] {
  display: none !important;
}
.badge-listino-doc {
  background: #ede9fe;
  color: #5b21b6;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}
.badge-listino-int {
  background: #ecfdf5;
  color: #047857;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

/* —— Generatore preventivi —— */
.prev-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 0;
  min-height: calc(100vh - 52px);
  padding: 0;
}
@media (max-width: 1024px) {
  .prev-workspace {
    grid-template-columns: 1fr;
  }
  .prev-picker {
    max-height: 220px;
    border-right: none !important;
    border-bottom: 1px solid var(--line);
  }
}
.prev-picker {
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-right: 1px solid var(--line);
  border-top: none;
  border-left: none;
  border-bottom: none;
  min-height: 0;
}
.prev-picker-head {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
}
.prev-picker-actions {
  padding: 8px 12px;
}
.prev-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.prev-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.prev-picker-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-soft);
}
.prev-picker-item strong {
  display: block;
  font-size: 11px;
  color: var(--primary-dark);
}
.prev-picker-item > span {
  display: block;
  font-size: 11px;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.3;
}
.prev-picker-meta {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
}
.prev-picker-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 8px;
}
.prev-picker-foot {
  font-size: 11px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.prev-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 16px 16px;
  gap: 10px;
  overflow: hidden;
}
.prev-inp {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  width: 100%;
  background: #fff;
  color: var(--text);
}
.prev-inp:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}
.prev-inp-title {
  font-weight: 700;
  font-size: 14px;
  min-width: 200px;
  max-width: 420px;
  flex: 1;
  color: var(--primary-dark);
}
.prev-meta {
  padding: 10px 12px;
}
.prev-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 12px;
}
@media (min-width: 900px) {
  .prev-meta-grid {
    grid-template-columns: 1fr 140px 140px 1fr;
  }
  .prev-meta-field-wide {
    grid-column: span 2;
  }
}
.prev-meta-field span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 3px;
}
.prev-sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.prev-sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.prev-sheet-scroll {
  flex: 1;
  overflow: auto;
  min-height: 200px;
}
.prev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.prev-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #faf8ff;
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.prev-table .col-code { width: 88px; }
.prev-table .col-desc { min-width: 200px; }
.prev-table .col-cat { width: 120px; }
.prev-table .col-qty { width: 72px; }
.prev-table .col-um { width: 64px; }
.prev-table .col-price { width: 100px; }
.prev-table .col-total { width: 110px; text-align: right; }
.prev-table .col-act { width: 64px; }
.prev-row td {
  padding: 4px 4px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.prev-row:hover td {
  background: #faf8ff;
}
.prev-line-total {
  text-align: right;
  font-weight: 700;
  color: var(--primary-dark);
  padding-right: 8px !important;
  white-space: nowrap;
}
.prev-row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}
.prev-icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.prev-icon-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary-dark);
}
.prev-icon-del:hover {
  border-color: #fca5a5;
  color: #b91c1c;
  background: #fef2f2;
}
.prev-totals {
  padding: 12px 16px;
  flex-shrink: 0;
}
.prev-totals-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.prev-totals-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
}
.prev-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}
.prev-total-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.prev-total-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.prev-inp-pct {
  width: 52px;
  text-align: right;
}
.prev-grand {
  text-align: right;
}
.prev-grand span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}
.prev-grand strong {
  font-size: 1.5rem;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.prev-totals-note {
  margin: 10px 0 0;
  font-size: 10px;
  color: var(--muted);
}
kbd {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

/* —— Dashboard semplificata —— */
.dash-intro {
  padding: 20px 22px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.09) 0%, #fff 55%, rgba(244, 114, 182, 0.05) 100%);
  border-radius: 12px;
}
.dash-intro h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.dash-intro-lead {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: #64748b;
  max-width: 52ch;
}
.dash-intro-lead strong {
  color: var(--primary-dark);
  font-weight: 600;
}
.dash-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.dash-flow-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
}
a.dash-flow-step:hover {
  border-color: var(--primary-light);
  color: var(--primary-dark);
}
.dash-flow-step.is-end {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  border-color: transparent;
  color: #fff;
}
.dash-flow-arrow {
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}
.dash-kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 768px) {
  .dash-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .dash-kpis { grid-template-columns: repeat(6, 1fr); }
}
.dash-kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.dash-kpi .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0;
}
.dash-kpi .value {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--text);
  line-height: 1.1;
}
.dash-kpi .hint {
  font-size: 11px;
  color: #8b7cb8;
  margin: 4px 0 0;
}
.dash-kpi.is-action {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #fff 100%);
}
.dash-kpi.is-action .value {
  color: #b45309;
}

.dash-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 10px;
}
.dash-cantieri-table .erp-table tbody td {
  padding: 12px 10px;
}
.dash-cantieri-table .erp-table thead th {
  font-size: 10px;
}

.dash-todo {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-todo li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-size: 12px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.dash-todo li a:hover {
  border-color: var(--primary-light);
  background: var(--primary-soft);
}
.dash-todo li a strong {
  font-weight: 600;
  color: var(--primary-dark);
}
.dash-todo-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fef3c7;
  color: #b45309;
  flex-shrink: 0;
}
.dash-todo-count.ok {
  background: #d1fae5;
  color: #047857;
}

.dash-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.dash-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-quick-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 20px -12px var(--primary-glow);
}
.dash-quick-btn span {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}

.dash-featured {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(145deg, #faf8ff 0%, #fff 100%);
}
.dash-featured-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dash-featured h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.dash-featured-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.dash-featured-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.dash-featured-stats div span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.dash-featured-stats div strong {
  font-size: 15px;
  color: var(--text);
  margin-top: 2px;
  display: block;
}

.dash-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dash-module-link {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary-dark);
  text-decoration: none;
}
.dash-module-link:hover {
  background: var(--primary-soft);
  border-color: var(--primary-light);
}
.dash-module-link.is-result {
  background: var(--primary-soft);
  border-color: var(--line-strong);
}

.dash-activity {
  margin: 0;
  padding: 0;
  list-style: none;
}
.dash-activity li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f0ff;
  font-size: 12px;
}
.dash-activity li:last-child { border-bottom: none; }
.dash-activity time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  min-width: 38px;
}

.dash-layout {
  width: 100%;
  max-width: 1780px;
  margin-left: auto;
  margin-right: auto;
}

.dash-grid-main {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
  .dash-grid-main {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  }
}
@media (min-width: 1400px) {
  .dash-grid-main {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.95fr) minmax(300px, 0.75fr);
  }
}

/* Calendario dashboard */
.dash-calendar {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.dash-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f5f3ff 0%, #fff 100%);
  border-bottom: 1px solid var(--line);
}
.dash-calendar-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
}
.dash-calendar-nav {
  display: flex;
  gap: 4px;
}
.dash-calendar-nav button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  color: var(--primary-dark);
}
.dash-calendar-nav button:hover {
  background: var(--primary-soft);
}
.dash-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}
.dash-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 4px 10px 12px;
}
.dash-cal-day {
  aspect-ratio: 1;
  min-height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  cursor: default;
  padding: 2px;
}
.dash-cal-day.is-other {
  color: #c4b5fd;
  font-weight: 500;
}
.dash-cal-day.is-today {
  background: var(--primary-soft);
  border-color: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}
.dash-cal-day.is-selected {
  background: linear-gradient(135deg, var(--primary) 0%, #9333ea 100%);
  color: #fff;
  border-color: transparent;
}
.dash-cal-day.has-event:not(.is-selected) {
  background: #faf8ff;
  border-color: var(--line);
}
.dash-cal-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}
.dash-cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--primary);
}
.dash-cal-dot.warn { background: var(--accent-amber); }
.dash-cal-dot.cyan { background: var(--accent-cyan); }

.dash-appointments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-appointment {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
}
.dash-appointment.is-today {
  border-color: var(--primary-light);
  background: linear-gradient(90deg, var(--primary-soft) 0%, #fff 70%);
}
.dash-appointment.is-soon {
  border-left: 3px solid var(--accent-amber);
}
.dash-appointment-date {
  text-align: center;
  line-height: 1.1;
}
.dash-appointment-date strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}
.dash-appointment-date span {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.dash-appointment-body strong {
  display: block;
  color: var(--text);
  font-weight: 600;
}
.dash-appointment-body span {
  color: var(--muted);
  font-size: 11px;
}
.dash-appointment-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
}

/* Todo list dashboard */
.dash-todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}
.dash-todo-item:hover {
  border-color: var(--primary-light);
  background: #faf8ff;
}
.dash-todo-item.is-done {
  opacity: 0.65;
  background: #f8fafc;
}
.dash-todo-item.is-done .dash-todo-text {
  text-decoration: line-through;
  color: var(--muted);
}
.dash-todo-item.is-high {
  border-left: 3px solid #f43f5e;
}
.dash-todo-check {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}
.dash-todo-text {
  flex: 1;
  min-width: 0;
}
.dash-todo-text strong {
  display: block;
  font-weight: 600;
  color: var(--primary-dark);
}
.dash-todo-text span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.dash-todo-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex-shrink: 0;
}
.dash-todo-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.dash-todo-add input {
  flex: 1;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.dash-todo-add input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.32);
}

.dash-col-sticky {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
