:root {
  --bg: #f4f6f8;
  --bg-accent: #e7ebf0;
  --ink: #1a1f2b;
  --muted: #4f5f73;
  --primary: #224a7a;
  --primary-contrast: #f5f7fb;
  --border: #cbd3de;
  --card: #ffffff;
  --card-elev: #fbfdff;
  --focus-ring: #2f6fb6;
  --selection-bg: rgba(47, 111, 182, 0.22);
  --elev-1: 0 8px 18px rgba(16, 28, 43, 0.06);
  --elev-2: 0 14px 34px rgba(16, 28, 43, 0.1);
  --danger: #b4515d;
  --section-toolbar-gap: 0px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

body.theme-dark {
  --bg: #090909;
  --bg-accent: #121315;
  --ink: #e8ebef;
  --muted: #b6bbc3;
  --primary: #79a6ff;
  --primary-contrast: #0b1220;
  --border: #2f343c;
  --card: #17191d;
  --card-elev: #1d2025;
  --focus-ring: #8db8ff;
  --selection-bg: rgba(141, 184, 255, 0.3);
  --elev-1: 0 10px 24px rgba(0, 0, 0, 0.34);
  --elev-2: 0 18px 42px rgba(0, 0, 0, 0.52);
  --danger: #d07a85;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(circle at top left, #fdfefe 0%, var(--bg) 45%, var(--bg-accent) 100%);
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow-x: hidden;
}

::selection {
  background: var(--selection-bg);
}

body.theme-dark {
  background: radial-gradient(circle at top left, #1b1c1f 0%, var(--bg) 46%, var(--bg-accent) 100%);
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 1;
  transition: opacity 260ms ease;
}

.app-loader.is-fadeout {
  opacity: 0;
  pointer-events: none;
}

.app-loader.hidden {
  display: none;
}

.app-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  min-width: 220px;
}

.app-loader-flake {
  font-size: 28px;
  line-height: 1;
  color: var(--primary);
  animation: loader-flake-pulse 1.4s ease-in-out infinite;
}

.app-loader-text {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-loader-progress {
  width: 180px;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.app-loader-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 180ms ease;
}

.app-loader-percent {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
}

@keyframes loader-flake-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

body.theme-dark .app-loader {
  background: rgba(8, 12, 18, 0.72);
}

body.theme-dark .app-loader-card {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.theme-dark .app-loader-progress {
  background: #1f2937;
}

body.theme-dark .app-loader-percent {
  color: #e2e8f0;
}

.app {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  background: transparent;
  border: none;
  border-radius: 14px;
  box-shadow: none;
  font-weight: 500;
  font-size: 16px;
  color: var(--ink);
}

.panel,
#todoSection,
#calendarPanel,
#matrixPanel,
#reportPanel,
#commessePanel {
  scroll-margin-top: calc(var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
}

.topbar .ghost,
.topbar button.ghost,
.topbar a.ghost {
  border: none;
  box-shadow: none;
  font-family: inherit;
  color: inherit;
  padding: 0 6px;
  border-radius: 8px;
  font-weight: 400;
}

.topbar-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
  width: auto;
  min-width: 36px;
  height: 28px;
}

.topbar-menu-toggle {
  width: 36px;
  height: 28px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 36px;
}

.topbar-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.topbar-menu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}

.topbar-menu.is-open {
  max-width: 720px;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
}

.topbar-menu-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  max-width: 34px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  overflow: visible;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.topbar-menu-item .menu-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform 180ms ease;
}

.topbar-menu-item .menu-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-menu-item .menu-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 999px;
  background: #1f2937;
  color: #f8fafc;
  font-size: 11px;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
  transition: opacity 160ms ease, transform 160ms ease;
}

.topbar-menu-item:hover .menu-label,
.topbar-menu-item:focus-visible .menu-label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.topbar-menu-item:hover .menu-icon,
.topbar-menu-item:focus-visible .menu-icon {
  transform: scale(1.08);
}

body.theme-dark .topbar-menu-item .menu-label {
  background: #f8fafc;
  color: #1f2937;
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.35);
}

.topbar .title,
.topbar .subtitle,
.topbar .auth-status,
.topbar .badge,
.topbar .status-msg {
  font-family: inherit;
}

.topbar .title {
  font-size: inherit;
  letter-spacing: 0.01em;
}

.topbar .subtitle {
  font-size: inherit;
}

.theme-toggle-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions .status-msg {
  max-width: 360px;
  text-align: right;
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2b5d92 0%, #1e3e68 100%);
  color: var(--primary-contrast);
  display: grid;
  place-items: center;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.title {
  font-size: 20px;
  font-weight: 600;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-actions.is-authenticated #emailInput,
.auth-actions.is-authenticated #passwordInput,
.auth-actions.is-authenticated #loginBtn,
.auth-actions.is-authenticated #resetPasswordBtn {
  display: none;
}

.auth-actions .link-btn {
  border: none;
  background: transparent;
  padding: 0 2px;
  color: var(--primary);
}

.auth-actions .link-btn:hover {
  text-decoration: underline;
}

.auth-feedback {
  font-size: 11px;
  color: #1f5c4a;
  width: 100%;
  text-align: right;
}

.auth-feedback.error {
  color: #a33d3d;
}

.auth-status {
  font-size: 13px;
  color: var(--muted);
}

.auth-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-status-line .link-btn {
  border: none;
  background: transparent;
  padding: 0 2px;
  color: var(--primary);
}

.auth-status-line .link-btn:hover {
  text-decoration: underline;
}

.key-btn {
  border: none;
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
}

.key-btn:hover {
  filter: brightness(0.95);
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4bb3ff;
  box-shadow: 0 0 0 2px rgba(75, 179, 255, 0.2);
}

.status-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin: 18px 0 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

body.theme-dark .status-bar {
  background: rgba(20, 27, 38, 0.85);
}

.status-bar-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.status-bar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a63333;
}

.status-bar-title-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.status-bar-title-btn:hover {
  text-decoration: underline;
}

.status-bar-filters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-bar:not(.is-expanded) .status-bar-filters,
.status-bar:not(.is-expanded) .status-bar-list {
  display: none;
}

.status-filter-btn {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.1;
  border: 1px solid var(--border);
  background: var(--card);
}

.status-filter-btn.is-active {
  border-color: #d14a4a;
  color: #9e2424;
  background: rgba(209, 74, 74, 0.12);
}

.status-filter-input-wrap {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}

.status-filter-input {
  width: 58px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.1;
}

.status-bar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-alarm-item {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(178, 59, 59, 0.14);
  color: #7d2020;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.status-alarm-item:hover {
  background: rgba(178, 59, 59, 0.2);
}

.status-alarm-item.is-warn {
  background: rgba(234, 133, 29, 0.16);
  color: #8a4a00;
}

.status-alarm-item.is-warn:hover {
  background: rgba(234, 133, 29, 0.24);
}

.status-alarm-item.is-missing-planned {
  background: rgba(234, 133, 29, 0.16);
  color: #8a4a00;
}

.status-alarm-item.is-missing-planned:hover {
  background: rgba(234, 133, 29, 0.24);
}

.status-alarm-item.is-missing-target {
  background: rgba(175, 145, 232, 0.2);
  color: #5f3b95;
}

.status-alarm-item.is-missing-target:hover {
  background: rgba(175, 145, 232, 0.3);
}

.status-alarm-item.is-missing-both {
  background: linear-gradient(90deg, rgba(175, 145, 232, 0.22), rgba(234, 133, 29, 0.2));
  color: #5f3f6a;
}

.status-alarm-item.is-missing-both:hover {
  background: linear-gradient(90deg, rgba(175, 145, 232, 0.32), rgba(234, 133, 29, 0.3));
}

.status-alarm-more {
  display: inline-flex;
  align-items: center;
  padding: 6px 4px;
  color: var(--muted);
  font-size: 12px;
}

body.theme-dark .status-bar-title {
  color: #f08f8f;
}

body.theme-dark .status-filter-btn {
  background: rgba(20, 27, 38, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
  color: #d7e3ff;
}

body.theme-dark .status-filter-btn.is-active {
  border-color: #ff8a8a;
  color: #ffd2d2;
  background: rgba(226, 90, 90, 0.24);
}

body.theme-dark .status-filter-input {
  background: rgba(20, 27, 38, 0.9);
  border-color: rgba(255, 255, 255, 0.16);
  color: #d7e3ff;
}

body.theme-dark .status-alarm-item {
  background: rgba(226, 90, 90, 0.22);
  color: #ffd2d2;
}

body.theme-dark .status-alarm-item:hover {
  background: rgba(226, 90, 90, 0.3);
}

body.theme-dark .status-alarm-item.is-warn {
  background: rgba(249, 115, 22, 0.24);
  color: #ffd9b3;
}

body.theme-dark .status-alarm-item.is-warn:hover {
  background: rgba(249, 115, 22, 0.34);
}

body.theme-dark .status-alarm-item.is-missing-planned {
  background: rgba(249, 115, 22, 0.24);
  color: #ffd9b3;
}

body.theme-dark .status-alarm-item.is-missing-planned:hover {
  background: rgba(249, 115, 22, 0.34);
}

body.theme-dark .status-alarm-item.is-missing-target {
  background: rgba(176, 137, 255, 0.28);
  color: #ecd9ff;
}

body.theme-dark .status-alarm-item.is-missing-target:hover {
  background: rgba(176, 137, 255, 0.38);
}

body.theme-dark .status-alarm-item.is-missing-both {
  background: linear-gradient(90deg, rgba(176, 137, 255, 0.3), rgba(249, 115, 22, 0.24));
  color: #f5e6ff;
}

body.theme-dark .status-alarm-item.is-missing-both:hover {
  background: linear-gradient(90deg, rgba(176, 137, 255, 0.4), rgba(249, 115, 22, 0.34));
}

.section-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px 0;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--card);
  border-bottom: none;
  width: 100vw;
  margin: 0 0 0 calc(50% - 50vw);
  box-sizing: border-box;
}

.section-toolbar-date {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.01em;
  user-select: none;
}

.section-link {
  font-size: 13px;
  padding: 4px 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  text-decoration: none;
  transition: color 120ms ease, border-color 120ms ease, text-decoration-color 120ms ease;
}

.section-link:hover {
  color: var(--ink);
  border-bottom-color: rgba(105, 122, 146, 0.55);
}

.section-link.is-active {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
  text-decoration-color: currentColor;
}

body.theme-dark .section-link {
  background: transparent;
  color: #b9c0cb;
}

body.theme-dark .section-link:hover {
  color: #edf1f7;
  border-bottom-color: rgba(178, 195, 218, 0.5);
}

body.theme-dark .section-link.is-active {
  color: #f3f7ff;
}

body.theme-dark .section-toolbar {
  background: var(--card);
}

body.theme-dark .section-toolbar-date {
  color: #c5ccd6;
}

@media (max-width: 1320px) {
  .section-toolbar-date {
    display: none;
  }
}

body.theme-dark .panel,
body.theme-dark .modal-card,
body.theme-dark .backup-card,
body.theme-dark .workload-group,
body.theme-dark .calendar-card,
body.theme-dark .matrix-commessa-item,
body.theme-dark .report-gantt-row,
body.theme-dark .report-gantt-header {
  background: var(--card);
}

body.theme-dark .topbar {
  background: transparent;
  color: #e3e7ee;
  border-color: rgba(255, 255, 255, 0.08);
}

body.theme-dark .topbar .ghost,
body.theme-dark .topbar button.ghost,
body.theme-dark .topbar a.ghost {
  color: #e3e7ee;
}

body.theme-dark .topbar-menu-toggle span {
  background: #e3e7ee;
}

body.theme-dark .item {
  background: var(--card);
}

body.theme-dark .matrix-header-row {
  background: rgba(20, 28, 38, 0.92);
}

body.theme-dark .report-gantt-week-band {
  background: rgba(121, 102, 175, 0.12);
}

body.theme-dark .report-gantt-label-resize {
  background: linear-gradient(
    to bottom,
    rgba(168, 180, 199, 0.2) 0%,
    rgba(168, 180, 199, 0.42) 50%,
    rgba(168, 180, 199, 0.2) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(168, 180, 199, 0.12);
}

body.theme-dark .report-gantt-label-resize:hover,
body.theme-dark .report-gantt-label-resize:focus-visible,
body.theme-dark .report-gantt-label-resize.is-dragging {
  box-shadow:
    inset 0 0 0 1px rgba(168, 180, 199, 0.22),
    0 0 0 1px rgba(168, 180, 199, 0.3);
}

body.theme-dark .report-gantt-week-band.is-alt {
  background: rgba(121, 102, 175, 0.2);
}

body.theme-dark .report-gantt-week-boundary {
  background: rgba(148, 163, 184, 0.25);
}

body.theme-dark .report-gantt-day-number {
  color: var(--muted);
}

body.theme-dark .report-gantt-today-band {
  background: rgba(90, 110, 130, 0.25);
  border-left: 1px solid rgba(90, 110, 130, 0.7);
  border-right: 1px solid rgba(90, 110, 130, 0.7);
}

body.theme-dark .matrix-wrap {
  background: var(--card);
  border-color: var(--border);
}

body.theme-dark .matrix-commesse-header,
body.theme-dark .matrix-commesse-footer {
  background: #1a2432;
}

body.theme-dark .matrix-commesse-header-filters {
  background: #1a2432;
}

body.theme-dark .matrix-cell {
  background: #151e2a;
  border-right-color: var(--border);
}

body.theme-dark .matrix-cell.week-sep {
  border-right-color: #37475f;
}

body.theme-dark .matrix-cell.today-col {
  background: #1f3429;
}

body.theme-dark .matrix-row {
  border-bottom-color: var(--border);
}

body.theme-dark .matrix-header-row {
  background: rgba(20, 28, 38, 0.95);
  border-top-color: #1a2432;
}

body.theme-dark .matrix-header-row::before {
  background: #121a26;
}

body.theme-dark .matrix-section-cell {
  background: #1d2b3f;
  border-bottom-color: #2d415f;
  color: #cfe2ff;
}

body.theme-dark .matrix-resource {
  background: #1a2432;
  color: var(--ink);
}

body.theme-dark .matrix-resource .resource-dept {
  color: #a9b8cc;
}

body.theme-dark .matrix-activity-bar,
body.theme-dark .matrix-activity-bar .activity-title,
body.theme-dark .matrix-activity-bar .commessa-num {
  color: #101723;
}

body.theme-dark .matrix-activity-bar .commessa-year {
  color: #3b4b63;
}

body.theme-dark .matrix-activity-bar.activity-lavender .activity-title,
body.theme-dark .matrix-activity-bar.activity-lavender .commessa-num,
body.theme-dark .matrix-activity-bar.activity-lavender .commessa-year {
  color: #3c2658;
}

body.theme-dark .matrix-activity-bar.activity-assente {
  background-color: #3b424c;
  border-color: #6b7480;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(210, 218, 230, 0.2) 0,
    rgba(210, 218, 230, 0.2) 2px,
    rgba(59, 66, 76, 0) 2px,
    rgba(59, 66, 76, 0) 6px
  );
}

body.theme-dark .matrix-activity-bar.activity-assente .activity-title,
body.theme-dark .matrix-activity-bar.activity-assente .commessa-num {
  color: #e7edf7;
}

body.theme-dark .matrix-activity-bar.activity-assente .commessa-year {
  color: #c6d0de;
}

body.theme-dark .matrix-activity-bar.is-done.is-past-task {
  background: #313b46;
  border-color: transparent;
  color: #dfe9f8;
}

body.theme-dark .matrix-activity-bar.is-done.is-past-task .commessa-year,
body.theme-dark .matrix-activity-bar.is-done.is-past-task .activity-title,
body.theme-dark .matrix-activity-bar.is-done.is-past-task .commessa-num {
  color: #dfe9f8;
}

body.theme-dark .calendar-day {
  background: var(--card);
  border-color: var(--border);
}

body.theme-dark .calendar-day.calendar-today {
  background: #2b2a1a;
  border-color: #c9a84b;
  box-shadow: inset 0 0 0 1px rgba(201, 168, 75, 0.35);
}

body.theme-dark .calendar-day h4 {
  color: #b7c3d3;
}

body.theme-dark .calendar-card {
  background: #1c2838;
  border-color: #2a3b52;
  color: var(--ink);
}

body.theme-dark .calendar-card.calendar-cad {
  background: #1f3a2b;
  border-color: #3b6b52;
  color: #d8f3e2;
}

body.theme-dark .calendar-card.calendar-termo {
  background: #1b2a44;
  border-color: #3a5f9a;
  color: #d7e6ff;
}

body.theme-dark .calendar-card.calendar-elett {
  background: #3a3215;
  border-color: #b98f2d;
  color: #fff1c2;
}

.status-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-contrast);
}

.status-msg {
  color: var(--muted);
  font-size: 14px;
  user-select: text;
  cursor: text;
}

.status-msg.ok {
  color: #1f5c4a;
  font-weight: 600;
}

.status-msg.error {
  color: #a33d3d;
  font-weight: 600;
}

.revision-stamp {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.form-warning {
  color: #b23b3b;
  font-size: 12px;
  margin-top: -6px;
}

.form-preview {
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
}

.layout {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr 1fr;
  gap: 16px;
  margin-top: 8px;
  min-height: calc(100vh - 140px);
  align-content: start;
  align-items: stretch;
}

#commessePanel {
  grid-column: 1 / -1;
  height: calc(100vh - 140px);
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

#commessePanel.collapsed {
  height: auto;
}

#commessePanel .panel-body {
  flex: 1;
  min-height: 0;
}

#commessePanel .list {
  flex: 1;
  max-height: none;
}

.panel {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-elev) 100%);
  border: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  padding: 16px;
  box-shadow: var(--elev-1);
  min-height: 200px;
}

.panel-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  background: transparent;
  border-radius: 12px 12px 0 0 !important;
  overflow: hidden;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(34, 74, 122, 0.08);
  color: var(--primary);
}

.icon-btn:hover {
  background: rgba(34, 74, 122, 0.14);
}

.new-btn {
  height: 28px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.2px;
  background: rgba(34, 74, 122, 0.1);
  color: var(--primary);
}

#openNewCommessaBtn {
  order: 1;
  border: none;
}

.commesse-seq-alert {
  font-size: 12px;
  line-height: 1.2;
  border-radius: 8px;
  padding: 4px 8px;
  border: 1px solid transparent;
  background: rgba(100, 116, 139, 0.1);
  color: var(--muted);
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.commesse-seq-alert.error {
  background: rgba(220, 38, 38, 0.11);
  border-color: rgba(220, 38, 38, 0.32);
  color: #b91c1c;
}

body.theme-dark .commesse-seq-alert.error {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.32);
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.todo-panel .panel-body {
  gap: 0;
}

.panel.collapsed .panel-body {
  display: none;
}

.panel.collapsed {
  min-height: auto;
  padding-top: 10px;
  padding-bottom: 10px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.panel.collapsed .panel-header {
  margin-bottom: 0;
}

#commesseTitle {
  cursor: pointer;
  user-select: none;
}

#matrixTitle,
#calendarTitle,
#reportTitle,
#todoTitle {
  cursor: pointer;
  user-select: none;
}

#matrixTitle {
  white-space: nowrap;
  flex-shrink: 0;
}

.matrix-panel.collapsed #matrixWrap,
.calendar-panel.collapsed #calendarGrid,
.report-panel.collapsed #matrixReportGrid {
  display: none;
}

.matrix-panel.collapsed .matrix-controls,
.calendar-panel.collapsed .calendar-controls,
.report-panel.collapsed .report-controls {
  display: none;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
}

.commessa-year-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 6px 4px 0;
}

.item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(20, 40, 70, 0.08);
}

.item.selected {
  border-color: var(--primary);
  background: #f0f5ff;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #111827;
}

.commessa-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e1b4b;
  font-size: 12px;
  font-weight: 700;
}

.commessa-pill.is-suspended {
  background: #ffe4e8;
  border-color: #f2a8b4;
  color: #7a1d2b;
}

.commessa-year {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.commessa-name {
  color: #111827;
  font-weight: 600;
}

.item-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.commessa-risorse {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.risorsa-extra {
  font-size: 11px;
  color: var(--muted);
  align-self: center;
}

.risorsa-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.risorsa-tag.can-copy-email {
  cursor: pointer;
}

.risorsa-tag.dept-elettrici {
  background: #fff6cc;
  border-color: #f2d27a;
  color: #6b5600;
}

.risorsa-tag.dept-termodinamici {
  background: #dceefb;
  border-color: #9cc8e8;
  color: #1e4a6a;
}

.risorsa-tag.dept-cad {
  background: #e2f6e8;
  border-color: #93d9a7;
  color: #1f5c3a;
}

.risorsa-tag.dept-default {
  background: #eef1f6;
  border-color: #d4dbe7;
  color: #3a4557;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.detail-row-main {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 5fr) minmax(0, 3fr);
}

.detail-row-status {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  max-width: 360px;
}

.detail-row-dates {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-telaio-group {
  grid-column: span 2;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid #cfe3ff;
  border-radius: 12px;
  background: #f4f9ff;
}

.detail-telaio-group-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  color: #335a8d;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.detail-telaio-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-telaio-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(191, 215, 255, 0.8);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.68);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

label.form-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

label.form-checkbox-inline {
  align-self: center;
  margin-top: 14px;
}

label.form-checkbox input {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
}

label.form-toggle-field {
  gap: 6px;
}

.detail-client-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-client-picker .client-flag {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #f1f5f9;
  border: none;
}

body.theme-dark .detail-client-picker .client-flag {
  background: #151a22;
}

.detail-client-picker select {
  flex: 1 1 auto;
  min-width: 0;
}

.detail-client-picker .ghost {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.telaio-toggle {
  border: 1px solid #f2d27a;
  background: #fff6cc;
  color: #6b5600;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  width: 100%;
}

.telaio-toggle.is-ordered {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

input,
select,
textarea {
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  user-select: text;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.78;
}

.is-missing-required {
  border-color: #f39c12 !important;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
  background: #fff7e3;
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions .action-right {
  margin-left: auto;
}

button {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.modal-header .ghost:hover {
  color: #c62828;
  border-color: #e57373;
}

.modal-header .activity-gantt-btn {
  color: var(--ink);
  border-color: transparent;
}

.modal-header .activity-gantt-btn:hover {
  color: #7c5caa;
  border-color: transparent;
}

.modal-close-btn {
  border: none !important;
  background: transparent;
  padding: 4px 6px;
  font-size: 26px;
  line-height: 1;
  box-shadow: none;
}

.modal-close-btn:hover {
  color: #c62828;
}

.primary {
  background: #dbeeff;
  color: #1f5f8b;
  border: 1px solid #c5ddf3;
  box-shadow: none;
}

.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.modal .primary,
.modal .ghost:not(.modal-close-btn):not(.activity-gantt-btn),
.modal .danger {
  font-weight: 600;
}

.modal .primary {
  background: #dbeeff;
  color: #1f5f8b;
  border: 1px solid #c5ddf3;
}

.primary:hover,
.modal .primary:hover {
  background: #cfe6ff;
  color: #184b6f;
  border-color: #b7d1eb;
}

.primary:active,
.modal .primary:active {
  background: #c2defb;
  color: #14415f;
  border-color: #a9c7e4;
}

.modal .ghost:not(.modal-close-btn):not(.activity-gantt-btn) {
  background: #eef3fb;
  color: #1f3f66;
  border: 1px solid #c7d3e4;
}

.modal .ghost:not(.modal-close-btn):not(.activity-gantt-btn):hover {
  background: #e4ecf8;
  color: #153252;
}

.modal .danger {
  background: #f5e4e8;
  color: #7b2c3a;
  border: 1px solid #e2c4cc;
}

.modal .danger:hover {
  background: #efd6dc;
  color: #692533;
  border-color: #d9b2bb;
}

.modal .danger:active {
  background: #e8c9d2;
  color: #5d1f2c;
  border-color: #d0a7b1;
}

body.theme-dark .primary,
body.theme-dark .modal .primary {
  background: #223245;
  color: #9fc8f3;
  border-color: #2f4258;
}

body.theme-dark .primary:hover,
body.theme-dark .modal .primary:hover {
  background: #28394f;
  color: #b5d6f8;
  border-color: #3a526b;
}

body.theme-dark .primary:active,
body.theme-dark .modal .primary:active {
  background: #2f425b;
  color: #c6e0fb;
  border-color: #45617d;
}

body.theme-dark .modal .ghost:not(.modal-close-btn):not(.activity-gantt-btn) {
  background: #25292f;
  color: #e5e9ef;
  border-color: #434a55;
}

body.theme-dark .modal .ghost:not(.modal-close-btn):not(.activity-gantt-btn):hover {
  background: #2f343c;
  color: #f1f3f6;
  border-color: #5a626f;
}

body.theme-dark .modal .danger {
  background: #3b2028;
  color: #f2c7d0;
  border-color: #4b2a33;
}

body.theme-dark .modal .danger:hover {
  background: #472630;
  color: #f7d6dd;
  border-color: #5a333d;
}

body.theme-dark .modal .danger:active {
  background: #52303b;
  color: #fde2e7;
  border-color: #6a3c48;
}

.section-toolbar .section-link {
  border: none;
}

.section-toolbar .section-link.section-link-notifications {
  margin-left: auto;
  color: #4a6392;
  font-weight: 600;
  border-bottom-color: rgba(74, 99, 146, 0.3);
}

.section-toolbar .section-link.section-link-refresh {
  padding: 0 2px 2px;
  min-width: 26px;
  color: #4a6392;
  border-bottom-color: rgba(74, 99, 146, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-toolbar .section-link.section-link-report-export {
  padding: 0 2px 2px;
  min-width: 26px;
  color: #4a6392;
  border-bottom-color: rgba(74, 99, 146, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-toolbar .section-link-refresh-icon {
  font-size: 15px;
  line-height: 1;
  display: inline-block;
}

.section-toolbar .section-link.section-link-refresh.is-loading .section-link-refresh-icon {
  animation: section-toolbar-refresh-spin 0.9s linear infinite;
}

.section-toolbar .section-link.section-link-notifications:hover {
  color: #2f4570;
  border-bottom-color: rgba(47, 69, 112, 0.55);
}

.section-toolbar .section-link.section-link-refresh:hover {
  color: #2f4570;
  border-bottom-color: rgba(47, 69, 112, 0.55);
}

.section-toolbar .section-link.section-link-report-export:hover {
  color: #2f4570;
  border-bottom-color: rgba(47, 69, 112, 0.55);
}

body.theme-dark .section-toolbar .section-link.section-link-notifications {
  color: #a9c3f1;
  border-bottom-color: rgba(169, 195, 241, 0.4);
}

.section-toolbar .section-link.section-link-refresh:disabled {
  opacity: 0.7;
}

body.theme-dark .section-toolbar .section-link.section-link-notifications:hover {
  color: #d6e5ff;
  border-bottom-color: rgba(214, 229, 255, 0.65);
}

body.theme-dark .section-toolbar .section-link.section-link-refresh {
  color: #a9c3f1;
  border-bottom-color: rgba(169, 195, 241, 0.4);
}

body.theme-dark .section-toolbar .section-link.section-link-report-export {
  color: #a9c3f1;
  border-bottom-color: rgba(169, 195, 241, 0.4);
}

body.theme-dark .section-toolbar .section-link.section-link-refresh:hover {
  color: #d6e5ff;
  border-bottom-color: rgba(214, 229, 255, 0.65);
}

body.theme-dark .section-toolbar .section-link.section-link-report-export:hover {
  color: #d6e5ff;
  border-bottom-color: rgba(214, 229, 255, 0.65);
}

@keyframes section-toolbar-refresh-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#themeToggleBtn {
  border: none;
}

a.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
}

.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: min(360px, 80vw);
  padding: 10px 14px;
  border-radius: 12px 0 0 12px;
  background: rgba(16, 22, 32, 0.94);
  color: #e6eefc;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-right: none;
  box-shadow: 0 12px 28px rgba(10, 16, 24, 0.35);
  opacity: 0;
  transform: translateX(110%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.ok {
  border-color: rgba(124, 197, 154, 0.6);
}

.toast.error {
  border-color: rgba(222, 106, 88, 0.7);
}

.reset-wait {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 26, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1400;
}

.reset-wait-card {
  width: min(520px, 92vw);
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: 0 20px 40px rgba(10, 20, 35, 0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.reset-wait-card h3 {
  margin: 0;
  font-size: 18px;
}

.reset-wait-countdown {
  font-size: 14px;
  color: var(--muted);
}

body.reset-waiting .app {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

.resources-users {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.resources-users-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.resources-users-header h4 {
  margin: 0;
  font-size: 14px;
}

.resources-users-hint {
  font-size: 12px;
  color: var(--muted);
}

.users-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-email {
  font-weight: 600;
}

.user-name {
  font-size: 12px;
  color: var(--muted);
}

.permessi-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.permessi-summary {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f7f9fc;
  font-size: 13px;
  color: var(--muted);
}

.permessi-rules {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.permessi-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.permessi-rules-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.permessi-rules-list {
  display: grid;
  gap: 10px;
}

.permessi-rules-card {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f7f7;
}

.permessi-rules-body {
  font-size: 14px;
  margin-top: 4px;
}

.permessi-rules-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.permessi-front-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.permessi-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.permessi-role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  color: var(--muted);
}

.permessi-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.debug-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(420px, 92vw);
  max-height: 40vh;
  overflow: auto;
  background: rgba(16, 22, 32, 0.92);
  color: #e6eefc;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(10, 16, 24, 0.35);
  z-index: 999;
  white-space: pre-wrap;
  user-select: text;
}

.danger {
  background: #f5e4e8;
  color: #7b2c3a;
  border: 1px solid #e2c4cc;
}

.danger:hover {
  background: #efd6dc;
  color: #692533;
  border-color: #d9b2bb;
}

.danger:active {
  background: #e8c9d2;
  color: #5d1f2c;
  border-color: #d0a7b1;
}

body.theme-dark .danger:hover {
  background: #472630;
  color: #f7d6dd;
  border-color: #5a333d;
}

body.theme-dark .danger,
body.theme-dark .danger:active {
  background: #3b2028;
  color: #f2c7d0;
  border-color: #4b2a33;
}

body.theme-dark .danger:active {
  background: #52303b;
  color: #fde2e7;
  border-color: #6a3c48;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 26, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}

#confirmModal,
#deleteCommessaModal {
  z-index: 240;
}

#confirmModal .modal-card {
  width: min(420px, 92vw);
  padding: 14px;
  gap: 10px;
}

#confirmModal .modal-header h3 {
  margin: 0;
}

#confirmMessage {
  margin: 0;
}

#notificationsModal {
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

#activityModal {
  z-index: 120;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(12, 18, 26, 0.56);
}

#activityModal .modal-card {
  width: min(1440px, 98vw);
  --activity-actions-right-offset: 128px;
}

#activityModal:not(.hidden) {
  animation: activity-modal-backdrop-in 180ms ease-out;
}

@keyframes activity-modal-backdrop-in {
  from {
    background: rgba(12, 18, 26, 0);
  }
  to {
    background: rgba(12, 18, 26, 0.56);
  }
}

@keyframes activity-modal-backdrop-in-dark {
  from {
    background: rgba(5, 10, 16, 0);
  }
  to {
    background: rgba(5, 10, 16, 0.72);
  }
}

#activityModal .activity-dual-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#activityModal .activity-dual-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  position: relative;
  padding-right: 44px;
  cursor: grab;
  touch-action: none;
}

#activityModal .activity-dual-head button,
#activityModal .activity-dual-head .modal-header-actions {
  cursor: pointer;
}

#activityModal.is-dragging-modal .activity-dual-head {
  cursor: grabbing;
}

#activityModal.is-dragging-modal {
  user-select: none;
}

#activityModal .activity-dual-head-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 1 auto;
}

#activityModal .activity-dual-head .modal-header-actions {
  margin-left: 6px;
  margin-right: 0;
  flex: 0 0 auto;
}

#activityModal #activityCloseBtn {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 2;
}

#activityModal #activityGanttBtn {
  position: absolute;
  top: 50%;
  right: 42px;
  transform: translateY(-50%);
  z-index: 2;
}

#activityModal .activity-dual-head-main h3 {
  margin: 0;
}

#activityModal #activityModalCommessaInfo {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#activityModal .activity-dual-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: 12px;
  align-items: stretch;
}

#activityModal .activity-status-wrap {
  min-width: 0;
  display: flex;
}

#activityModal .activity-main-panel {
  border: none;
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}

#activityModal .activity-grid {
  grid-template-columns: 1.3fr 1fr;
}

#activityModal .activity-section-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

#activityModal .activity-jam-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
}

#activityModal .activity-jam-action-btn {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  border: 1px solid #d0d7e3;
  background: #ffffff;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

#activityModal .activity-jam-action-btn svg {
  width: 30px;
  height: 30px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#activityModal .activity-jam-action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #9fb3d6;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.15);
  color: #1e3a8a;
}

#activityModal .activity-jam-action-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

#activityModal .activity-status-panel {
  min-height: 220px;
  height: 100%;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 10px;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#activityModal .activity-status-placeholder {
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
}

#activityModal .activity-hours-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

#activityModal .activity-hours-row .quick-buttons {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex-wrap: nowrap;
  flex: 0 0 auto;
  gap: 0;
  padding: 4px;
  border: 1px solid #d4d8df;
  border-radius: 999px;
  background: #ffffff;
  --quick-hours-active-index: 0;
  --quick-hours-active-opacity: 0;
}

#activityModal .activity-hours-row .quick-buttons::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: #e8f7ee;
  opacity: var(--quick-hours-active-opacity);
  transform: translateX(calc(var(--quick-hours-active-index) * 100%));
  transition: transform 190ms ease, opacity 140ms ease;
  pointer-events: none;
}

#activityModal .activity-hours-row .quick-buttons .ghost {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 999px;
  min-width: 48px;
  padding: 8px 12px;
  font-weight: 700;
  color: #6b7280;
  transition: transform 120ms ease;
}

#activityModal .activity-hours-row .quick-buttons .ghost:hover {
  transform: scale(1.04);
}

#activityModal .activity-hours-row .quick-buttons .ghost:not(.active):hover {
  background: transparent;
  color: #6b7280;
}

#activityModal .activity-hours-row .quick-buttons .ghost.active {
  border: none;
  background: transparent;
  color: #1f5c35;
}

#activityModal .activity-hours-row .quick-buttons .ghost.active:hover {
  background: transparent;
  color: #1f5c35;
}

#activityModal .filter-pill:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#activityModal #activityTitleList .filter-pill,
#activityModal #activityTitleListExtra .filter-pill {
  min-height: 40px;
  height: auto;
  display: flex;
  align-items: center;
  position: relative;
  padding-right: 28px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#activityModal #activityTitleList {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 360px;
}

#activityModal #activityTitleListExtra {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 6px;
}

#activityModal #activityTitleList .activity-generic-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#activityModal #activityTitleList .filter-pill.active,
#activityModal #activityTitleListExtra .filter-pill.active {
  background: #dff3e7;
  border-color: #2f6f3d;
  color: #0f3d26;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(31, 92, 53, 0.18);
}

#activityModal #activityTitleList .filter-pill:disabled:not(.active),
#activityModal #activityTitleListExtra .filter-pill:disabled:not(.active) {
  opacity: 0.5;
}

#activityModal #activityTitleList .filter-pill.active:disabled,
#activityModal #activityTitleListExtra .filter-pill.active:disabled {
  opacity: 1;
}

#activityModal #activityTitleList .filter-pill.active::after,
#activityModal #activityTitleListExtra .filter-pill.active::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  transform: translateY(-50%);
  opacity: 0.9;
}

#activityModal #activityTitleList .activity-list-divider,
#activityModal #activityTitleListExtra .activity-list-divider {
  grid-column: 1 / -1;
  width: 26px;
  height: 1px;
  margin: 4px auto;
  background: var(--border);
  opacity: 0.8;
}

@media (max-width: 700px) {
  #activityModal #activityTitleList .activity-generic-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

#activityModal #activityTitleList .filter-pill.assente-pill,
#activityModal #activityTitleListExtra .filter-pill.assente-pill {
  border-color: #b5bcc6;
  color: #4b5563;
  background-color: #edf0f3;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(148, 163, 184, 0.22) 0px,
    rgba(148, 163, 184, 0.22) 7px,
    rgba(237, 240, 243, 0.28) 7px,
    rgba(237, 240, 243, 0.28) 14px
  );
}

#activityModal #activityTitleList .filter-pill.assente-pill.active,
#activityModal #activityTitleListExtra .filter-pill.assente-pill.active {
  border-color: #8d95a1;
  color: #374151;
  background-color: #dde2e8;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(107, 114, 128, 0.24) 0px,
    rgba(107, 114, 128, 0.24) 7px,
    rgba(221, 226, 232, 0.3) 7px,
    rgba(221, 226, 232, 0.3) 14px
  );
}

#activityModal #activityDurationInput {
  width: 92px;
  min-width: 92px;
  flex: 0 0 92px;
  height: 40px;
  border-radius: 999px;
  text-align: center;
}

#activityModal .activity-footer-actions {
  justify-content: flex-end;
  margin-left: auto;
  margin-right: 0;
}

#activityModal .activity-footer-actions .primary,
#activityModal .activity-footer-actions .danger {
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

#activityModal .activity-footer-actions .primary {
  background: #2f6f3d;
  color: #ffffff;
  border: 1px solid #245831;
}

#activityModal .activity-footer-actions .danger {
  background: #b4515d;
  color: #ffffff;
  border: 1px solid #8f3b45;
}

#activityModal .activity-footer-actions .primary:hover,
#activityModal .activity-footer-actions .danger:hover {
  filter: brightness(0.96);
}

#activityModal .activity-footer-actions .primary:active,
#activityModal .activity-footer-actions .danger:active {
  filter: brightness(0.92);
}

#commessaDetailModal {
  z-index: 130;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  background: rgba(12, 18, 26, 0.58);
}

#commessaDetailModal:not(.hidden) {
  animation: detail-modal-backdrop-in 180ms ease-out;
}

#commessaDetailModal:not(.hidden) .modal-card {
  animation: detail-modal-card-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes detail-modal-backdrop-in {
  from {
    background: rgba(12, 18, 26, 0);
  }
  to {
    background: rgba(12, 18, 26, 0.58);
  }
}

@keyframes detail-modal-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#commessaDetailModal .modal-card {
  width: min(1140px, 96vw);
  max-height: 90vh;
  height: 90vh;
  padding: 0;
  border-radius: 18px;
  border: none;
  background: #ffffff;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.26);
  overflow: auto;
}

#commessaDetailModal .modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#commessaDetailModal .modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#commessaDetailModal .modal-header h3 {
  font-size: 17px;
  letter-spacing: 0.01em;
}

#commessaDetailModal #closeDetailBtn {
  border: none;
  background: transparent;
  color: #475569;
  border-radius: 0;
  padding: 4px 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

#commessaDetailModal #closeDetailBtn:hover {
  color: #1f2937;
  background: transparent;
}

#commessaDetailModal #selectedCode {
  margin: 0;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: #475569;
  font-size: 12px;
}

#commessaDetailModal #detailForm {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  gap: 14px;
  padding: 0 16px 16px;
}

#commessaDetailModal .detail-grid {
  flex: 1 1 auto;
}

#commessaDetailModal .detail-tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 16px 8px;
  padding: 8px 10px;
  border-radius: 14px;
  border: none;
  background: rgba(226, 232, 240, 0.5);
  box-shadow: none;
}

#commessaDetailModal .detail-tabs::after {
  content: "";
  position: absolute;
  left: var(--detail-tabs-underline-left, 0px);
  bottom: -4px;
  width: var(--detail-tabs-underline-width, 0px);
  height: 3px;
  border-radius: 999px;
  background: var(--detail-tabs-underline-color, var(--primary));
  transition: left 180ms ease, width 180ms ease, background-color 180ms ease;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.18);
}

#commessaDetailModal .detail-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 12px;
  line-height: 1;
}

#commessaDetailModal .detail-tab .tab-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

#commessaDetailModal .detail-tab-jump {
  margin-left: auto;
  min-width: 34px;
  padding: 6px 8px;
  justify-content: center;
}

#commessaDetailModal .detail-tab-jump .tab-icon {
  width: 18px;
  height: 18px;
}

#commessaDetailModal .detail-tab.active {
  color: var(--tab-accent, #0f172a);
  font-weight: 700;
}

body.theme-dark #commessaDetailModal .detail-tab {
  color: #c5ccd6;
}

body.theme-dark #commessaDetailModal .detail-tab.active {
  color: var(--tab-accent-dark, #f3f6fb);
}

body.theme-dark #commessaDetailModal .detail-tabs {
  border: none;
  background: rgba(30, 41, 59, 0.55);
  box-shadow: none;
}

#commessaDetailModal #detailTabMain {
  --tab-accent: #2b6aa1;
  --tab-accent-dark: #8ec1ff;
}

#commessaDetailModal #detailTabClientSpecs {
  --tab-accent: #7b6fd6;
  --tab-accent-dark: #c2b6ff;
}

#commessaDetailModal #detailTabMachineSpecs {
  --tab-accent: #2f7d6a;
  --tab-accent-dark: #8ce0c7;
}

#commessaDetailModal #detailTabNotes {
  --tab-accent: #9b5b3f;
  --tab-accent-dark: #f0c58b;
}

#commessaDetailModal #detailTabLayout {
  --tab-accent: #3a7c99;
  --tab-accent-dark: #9bd3ef;
}

#commessaDetailModal .detail-tab-panel {
  min-height: var(--detail-tab-min-h, auto);
  flex: 1 1 auto;
}

#commessaDetailModal #detailTabPanelSpecs {
  overflow: auto;
}

#commessaDetailModal #detailTabMain {
  border: none;
  background: transparent;
  color: #64748b;
}

#commessaDetailModal #detailTabMain.active {
  border: none;
  background: transparent;
  color: #1f2937;
  font-weight: 700;
}

body.theme-dark #commessaDetailModal #detailTabMain,
body.theme-dark #commessaDetailModal #detailTabMain.active {
  border: none;
  background: transparent;
  color: #e2e8f0;
}

body.theme-dark #commessaDetailModal #detailTabClientSpecs {
  background: transparent;
  color: #d9cff7;
}

body.theme-dark #commessaDetailModal #detailTabClientSpecs.active {
  background: transparent;
  color: #f1edff;
}

#commessaDetailModal .detail-tab-panel.hidden {
  display: none;
}

#commessaDetailModal .detail-client-specs-list {
  margin: 0 0 16px;
  border: none;
  border-radius: 12px;
  background: transparent;
  overflow: auto;
  max-height: min(60vh, 520px);
}

#commessaDetailModal .detail-client-specs-empty {
  margin: 0 0 16px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

#commessaDetailModal .detail-client-specs-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

#commessaDetailModal .detail-client-specs-controls label {
  display: grid;
  gap: 4px;
  min-width: 170px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

#commessaDetailModal .detail-client-specs-controls select {
  min-height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  padding: 0 8px;
}

#commessaDetailModal .detail-client-specs-controls button {
  min-height: 32px;
}

#commessaDetailModal .detail-client-specs-actions {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 16px;
}

#commessaDetailModal .detail-client-specs-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
}

#commessaDetailModal .detail-client-specs-link:hover {
  background: rgba(34, 74, 122, 0.08);
  border-color: transparent;
}

body.theme-dark #commessaDetailModal .detail-client-specs-link:hover {
  background: rgba(121, 166, 255, 0.12);
  border-color: transparent;
}
#commessaDetailModal .detail-client-specs-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}

#commessaDetailModal .detail-client-specs-group {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

#commessaDetailModal .detail-client-specs-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.01em;
}

#commessaDetailModal .detail-client-specs-table th,
#commessaDetailModal .detail-client-specs-table td {
  padding: 8px 10px;
  border-bottom: none;
  border-right: none;
  font-size: 12px;
  vertical-align: top;
}

#commessaDetailModal .detail-client-specs-table th:last-child,
#commessaDetailModal .detail-client-specs-table td:last-child {
  border-right: none;
}

#commessaDetailModal .detail-client-specs-table thead th {
  background: transparent;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #3f4d64;
  position: sticky;
  top: 0;
  z-index: 1;
}

#commessaDetailModal .detail-client-specs-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  margin: 2px 4px 2px 0;
}

#commessaDetailModal .detail-row-main,
#commessaDetailModal .detail-row-status,
#commessaDetailModal .detail-row-dates {
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: transparent;
}

#commessaDetailModal .detail-row-main {
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 1fr)
    minmax(0, 3fr)
    minmax(0, 2fr)
    minmax(0, 2fr);
}

#commessaDetailModal .detail-row-main .detail-span-3 {
  grid-column: span 3;
}

#commessaDetailModal .detail-row-main .detail-span-2 {
  grid-column: span 2;
}

#commessaDetailModal .detail-row-status {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  max-width: 720px;
}

#commessaDetailModal .detail-row-dates {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#commessaDetailModal .detail-telaio-group {
  grid-column: span 3;
  border: none;
  background: transparent;
}

#commessaDetailModal .detail-telaio-group-title {
  color: #2b5f9f;
}

#commessaDetailModal .detail-telaio-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

#commessaDetailModal .detail-telaio-card {
  border: none;
  background: transparent;
  display: contents;
}


#commessaDetailModal label {
  color: #5a6678;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#commessaDetailModal input,
#commessaDetailModal select,
#commessaDetailModal textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  box-shadow: none;
  transition: border-bottom-color 160ms ease, box-shadow 160ms ease;
}

#commessaDetailModal input[data-detail-picker] {
  padding-right: 30px;
  background-image: none;
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px 16px;
}

#commessaDetailModal input[data-detail-picker]:hover,
#commessaDetailModal input[data-detail-picker]:focus {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><line x1='8' y1='3' x2='8' y2='7'/><line x1='16' y1='3' x2='16' y2='7'/><line x1='3' y1='11' x2='21' y2='11'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px 16px;
}

#commessaDetailModal #d_data_telaio_pianificato,
#commessaDetailModal #d_data_telaio_pianificato:hover,
#commessaDetailModal #d_data_telaio_pianificato:focus {
  background-image: none !important;
  padding-right: 8px;
}

#commessaDetailModal .detail-field-empty {
  background: rgba(252, 211, 77, 0.22);
  border-bottom: 1px solid rgba(251, 146, 60, 0.6);
}

#commessaDetailModal input:focus,
#commessaDetailModal select:focus,
#commessaDetailModal textarea:focus {
  border-bottom-color: rgba(59, 130, 246, 0.9);
  box-shadow: 0 1px 0 rgba(59, 130, 246, 0.6);
  outline: none;
}

#commessaDetailModal input:hover,
#commessaDetailModal select:hover,
#commessaDetailModal textarea:hover {
  border-bottom-color: rgba(59, 130, 246, 0.6);
}

#commessaDetailModal #d_note {
  min-height: 220px;
  resize: vertical;
}

#commessaDetailModal .detail-notes-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
}

#commessaDetailModal .detail-notes-panel textarea {
  min-height: 320px;
}

#commessaDetailModal .detail-layout-notes textarea {
  min-height: 180px;
}

#commessaDetailModal .detail-layout {
  display: grid;
  gap: 14px;
}

#commessaDetailModal .detail-layout-row {
  display: grid;
  gap: 12px;
}

#commessaDetailModal .detail-layout-row.is-full {
  grid-template-columns: 1fr;
}

#commessaDetailModal .detail-layout-row.is-inline {
  grid-template-columns: 1fr minmax(180px, 220px);
  align-items: end;
}

#commessaDetailModal .detail-layout-dependent {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

#commessaDetailModal .detail-layout-dependent.is-disabled {
  opacity: 0.5;
}

#commessaDetailModal .detail-toggle-group {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

#commessaDetailModal .detail-layout-card {
  border-radius: 14px;
  padding: 12px;
  border: none;
  background: #f8fafc;
}

#commessaDetailModal .detail-layout-card h4 {
  margin: 0 0 8px;
  font-size: 12px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#commessaDetailModal #layoutCablaggioExtraCard input {
  width: 100%;
}

#commessaDetailModal .detail-layout-note-card textarea {
  min-height: 180px;
  width: 100%;
  display: block;
}

#commessaDetailModal .detail-toggle {
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: transparent;
  color: #1f2937;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

#commessaDetailModal .detail-toggle.is-active {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.12);
  color: #1f3a5f;
}

#commessaDetailModal .detail-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#commessaDetailModal .actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: auto;
  padding: 12px 0 6px;
  background: #ffffff;
  border-top: none;
}

#commessaDetailModal #updateBtn {
  min-width: 150px;
  flex: 0 0 80%;
}

#commessaDetailModal #applyBtn {
  min-width: 100px;
}

#commessaDetailModal #detailDeleteBtn {
  flex: 0 0 20%;
}

@media (max-width: 1024px) {
  #commessaDetailModal .detail-row-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #commessaDetailModal .detail-row-dates {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #commessaDetailModal .detail-telaio-group {
    grid-column: span 2;
  }

  #commessaDetailModal .detail-telaio-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  #commessaDetailModal .modal-card {
    width: min(1140px, 100vw);
    max-height: 100vh;
    border-radius: 0;
  }

  #commessaDetailModal .detail-row-main,
  #commessaDetailModal .detail-row-status,
  #commessaDetailModal .detail-row-dates,
  #commessaDetailModal .detail-telaio-group,
  #commessaDetailModal .detail-telaio-cards {
    grid-template-columns: 1fr;
  }

  #commessaDetailModal .detail-telaio-group {
    grid-column: auto;
  }

  #commessaDetailModal .actions {
    flex-wrap: wrap;
  }

  #commessaDetailModal .actions .action-right {
    margin-left: 0;
  }
}

body.theme-dark #commessaDetailModal {
  background: rgba(5, 10, 16, 0.74);
}

body.theme-dark #commessaDetailModal .modal-card {
  background: #171b21;
  border: none;
}

body.theme-dark #commessaDetailModal .modal-header {
  background: #171b21;
  border-bottom: none;
}

body.theme-dark #commessaDetailModal #closeDetailBtn {
  background: transparent;
  border: none;
  color: #d0d8e4;
}

body.theme-dark #commessaDetailModal #closeDetailBtn:hover {
  background: transparent;
  color: #e2e8f0;
}

body.theme-dark #commessaDetailModal #selectedCode {
  background: transparent;
  border: none;
  color: #b8c2d0;
}

body.theme-dark #commessaDetailModal .detail-row-main,
body.theme-dark #commessaDetailModal .detail-row-status,
body.theme-dark #commessaDetailModal .detail-row-dates {
  background: transparent;
  border: none;
}

body.theme-dark #commessaDetailModal .detail-telaio-group {
  background: transparent;
  border: none;
}

body.theme-dark #commessaDetailModal .detail-telaio-group-title {
  color: #c9d2dd;
}

body.theme-dark #commessaDetailModal .detail-telaio-card {
  background: transparent;
  border: none;
}

body.theme-dark #commessaDetailModal label {
  color: #b9c6d8;
}

body.theme-dark #commessaDetailModal input,
body.theme-dark #commessaDetailModal select,
body.theme-dark #commessaDetailModal textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(120, 134, 152, 0.55);
  color: #e2e8f0;
  box-shadow: none;
}

body.theme-dark #commessaDetailModal input[data-detail-picker] {
  background-image: none;
}

body.theme-dark #commessaDetailModal input[data-detail-picker]:hover,
body.theme-dark #commessaDetailModal input[data-detail-picker]:focus {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='16' rx='2'/><line x1='8' y1='3' x2='8' y2='7'/><line x1='16' y1='3' x2='16' y2='7'/><line x1='3' y1='11' x2='21' y2='11'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px 16px;
}

body.theme-dark #commessaDetailModal #d_data_telaio_pianificato,
body.theme-dark #commessaDetailModal #d_data_telaio_pianificato:hover,
body.theme-dark #commessaDetailModal #d_data_telaio_pianificato:focus {
  background-image: none !important;
  padding-right: 8px;
}

body.theme-dark #commessaDetailModal .detail-field-empty {
  background: rgba(234, 179, 8, 0.18);
  border-bottom: 1px solid rgba(251, 146, 60, 0.7);
}

body.theme-dark #commessaDetailModal .actions {
  background: #171b21;
  border-top: none;
}

body.theme-dark #commessaDetailModal .detail-toggle {
  border-color: rgba(120, 134, 152, 0.6);
  color: #e2e8f0;
}

body.theme-dark #commessaDetailModal .detail-toggle.is-active {
  border-color: rgba(121, 166, 255, 0.6);
  background: rgba(121, 166, 255, 0.16);
  color: #eaf1ff;
}

body.theme-dark #commessaDetailModal .detail-layout-card {
  background: #1b2430;
  border: none;
}

body.theme-dark #commessaDetailModal .detail-layout-card h4 {
  color: #a9b7c8;
}

body.theme-dark #commessaDetailModal input:hover,
body.theme-dark #commessaDetailModal select:hover,
body.theme-dark #commessaDetailModal textarea:hover {
  border-bottom-color: rgba(121, 166, 255, 0.75);
}

body.theme-dark #commessaDetailModal input:focus,
body.theme-dark #commessaDetailModal select:focus,
body.theme-dark #commessaDetailModal textarea:focus {
  border-bottom-color: rgba(121, 166, 255, 0.95);
  box-shadow: 0 1px 0 rgba(121, 166, 255, 0.7);
}

/* Dedicated contrast for customer dropdowns in detail modal (dark mode). */
body.theme-dark #commessaDetailModal .detail-client-picker select {
  background: #1f2631;
  border: 1px solid rgba(116, 136, 164, 0.72);
  border-radius: 10px;
  color: #edf3ff;
  box-shadow: none;
}

body.theme-dark #commessaDetailModal .detail-client-picker select:hover {
  border-color: rgba(142, 169, 209, 0.86);
}

body.theme-dark #commessaDetailModal .detail-client-picker select:focus {
  border-color: rgba(160, 191, 235, 0.95);
  box-shadow: 0 0 0 2px rgba(116, 157, 218, 0.22);
}

body.theme-dark #commessaDetailModal .detail-client-picker select:disabled {
  background: #171d26;
  color: #9eacc0;
  border-color: rgba(95, 109, 131, 0.72);
}

body.theme-dark #commessaDetailModal .detail-client-picker select option,
body.theme-dark #commessaDetailModal .detail-client-picker select optgroup {
  background: #1f2631;
  color: #edf3ff;
}

/* Improve contrast for "Stato" dropdown in detail modal (dark mode). */
body.theme-dark #commessaDetailModal #d_stato {
  background: #1f2631;
  border: 1px solid rgba(116, 136, 164, 0.72);
  border-radius: 10px;
  color: #edf3ff;
  box-shadow: none;
}

body.theme-dark #commessaDetailModal #d_stato:hover {
  border-color: rgba(142, 169, 209, 0.86);
}

body.theme-dark #commessaDetailModal #d_stato:focus {
  border-color: rgba(160, 191, 235, 0.95);
  box-shadow: 0 0 0 2px rgba(116, 157, 218, 0.22);
}

body.theme-dark #commessaDetailModal #d_stato option {
  background: #1f2631;
  color: #edf3ff;
}

.modal-card {
  width: min(980px, 100%);
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 20px 40px rgba(10, 20, 35, 0.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 85vh;
  overflow: auto;
}

.notifications-modal-card {
  width: min(1120px, 97vw);
  height: 86vh;
  max-height: 86vh;
  overflow: hidden;
}

.notifications-summary {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.notifications-window {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  background: #f6f9ff;
  border: 1px solid #d8dfeb;
  border-radius: 10px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.notifications-window-label,
.notifications-window-suffix {
  white-space: nowrap;
}

.notifications-window input {
  width: 56px;
  min-width: 56px;
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  text-align: center;
}

.notifications-resource-filter select {
  min-width: 150px;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

body.theme-dark .notifications-window input {
  background: transparent;
  color: #e5ecf6;
}

body.theme-dark .notifications-window {
  background: #242933;
  border-color: #3a424f;
  color: #c5ceda;
}

body.theme-dark .notifications-resource-filter select {
  background: #1f2430;
  color: #f1f5ff;
  border: 1px solid #3a424f;
  border-radius: 6px;
}

.notifications-class-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.notifications-class-btn {
  border: 1px solid #d8dfeb;
  border-radius: 999px;
  background: #f6f9ff;
  color: #36475f;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
}

.notifications-class-btn:hover {
  background: #edf3ff;
}

.notifications-class-btn.active {
  background: #6f4ad6;
  border-color: #7a54e0;
  color: #f7f3ff;
  box-shadow: 0 0 0 1px rgba(111, 74, 214, 0.35), 0 0 16px rgba(111, 74, 214, 0.45);
  animation: notifications-pill-pulse 3.8s ease-in-out infinite;
}

.notifications-class-btn.dept-termo {
  background: #e3f2ff;
  border-color: #a9cff6;
  color: #1f4f78;
}

.notifications-class-btn.dept-cad {
  background: #e2f7ea;
  border-color: #a9dfbe;
  color: #1f5a3a;
}

.notifications-class-btn.dept-elettrico {
  background: #fff4c9;
  border-color: #f2d27a;
  color: #6b4f00;
}

.notifications-class-btn.dept-termo.active {
  background: #cfe7ff;
  border-color: #8ab8ee;
  color: #1b4367;
}

.notifications-class-btn.dept-cad.active {
  background: #cfeedd;
  border-color: #86cba4;
  color: #1a4a30;
}

.notifications-class-btn.dept-elettrico.active {
  background: #ffe59a;
  border-color: #e3bf4f;
  color: #5a4200;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
  flex: 1 1 auto;
  min-height: 120px;
}

.prelim-assistant-modal-card {
  width: min(1100px, 97vw);
  height: 86vh;
  max-height: 86vh;
  overflow: hidden;
}

.prelim-assistant-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prelim-assistant-tab {
  min-width: 130px;
  justify-content: center;
}

.prelim-assistant-tab.active {
  background: #dfe9ff;
  border-color: #9eb9ed;
  color: #1f3557;
  font-weight: 600;
}

.prelim-assistant-summary {
  font-size: 12px;
  color: var(--muted);
}

.prelim-assistant-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
  flex: 1 1 auto;
  min-height: 140px;
}

.prelim-assistant-item {
  border: 1px solid #d8dfeb;
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prelim-assistant-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.prelim-assistant-item-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.prelim-assistant-code {
  font-size: 12px;
  color: #3f516f;
  font-weight: 600;
}

.prelim-assistant-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2b3d;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.prelim-assistant-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.prelim-assistant-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #c9d6ea;
  background: #edf3ff;
  color: #2f4668;
}

.prelim-assistant-badge.warn {
  background: #fff4d6;
  border-color: #e4cb8a;
  color: #6a500c;
}

.prelim-assistant-badge.danger {
  background: #ffe7e7;
  border-color: #efb0b0;
  color: #7a1f1f;
}

.prelim-assistant-meta {
  font-size: 12px;
  color: #4f5d73;
  line-height: 1.35;
}

.prelim-assistant-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.prelim-assistant-actions .ghost {
  font-size: 12px;
  padding: 5px 10px;
}

.prelim-assistant-fix {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.prelim-assistant-fix input[type="date"] {
  font-size: 12px;
  padding: 4px 6px;
}

.prelim-assistant-empty {
  border: 1px dashed #d1dcea;
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  color: #526176;
  background: #f8fbff;
}

body.theme-dark .prelim-assistant-tab.active {
  background: #2a3750;
  border-color: #5a78ab;
  color: #dfeaff;
}

body.theme-dark .prelim-assistant-item {
  border-color: #3b4454;
  background: #202631;
}

body.theme-dark .prelim-assistant-code {
  color: #b8c8e2;
}

body.theme-dark .prelim-assistant-title {
  color: #e9effb;
}

body.theme-dark .prelim-assistant-badge {
  background: #2a3342;
  border-color: #455168;
  color: #c8d6ee;
}

body.theme-dark .prelim-assistant-badge.warn {
  background: #3a3421;
  border-color: #6d5f31;
  color: #f0d995;
}

body.theme-dark .prelim-assistant-badge.danger {
  background: #402a30;
  border-color: #72444e;
  color: #f5c0cb;
}

body.theme-dark .prelim-assistant-meta {
  color: #c5d0e2;
}

body.theme-dark .prelim-assistant-empty {
  border-color: #3a4456;
  background: #222a37;
  color: #c4d1e6;
}

.detail-hover-tooltip {
  position: fixed;
  z-index: 4000;
  max-width: 360px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #10141b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f3f6fb;
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 10px 24px rgba(10, 14, 20, 0.25);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: normal;
}

.detail-hover-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.matrix-activity-tooltip .matrix-activity-tooltip-title {
  font-weight: 600;
  letter-spacing: 0.1px;
}

.matrix-activity-tooltip .matrix-activity-tooltip-sub {
  margin-top: 4px;
  color: rgba(235, 240, 248, 0.86);
}

.notification-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d8dfeb;
  background: #f8fbff;
}

.delay-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffe7e6;
  border: 1px solid #f2b5b1;
  color: #7a1c1c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.due-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6f4ff;
  border: 1px solid #b8d9ff;
  color: #1c4c7a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.days-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.days-pill--green {
  background: #e8f8eb;
  border-color: #bde6c3;
  color: #1b6a2b;
}

.days-pill--yellow {
  background: #fff6dc;
  border-color: #f1d995;
  color: #7a5b00;
}

.days-pill--red {
  background: #ffe7e6;
  border-color: #f2b5b1;
  color: #7a1c1c;
}

.three-d-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.three-d-pill--red {
  background: #ffe7e6;
  border-color: #f2b5b1;
  color: #7a1c1c;
}

.three-d-pill--blue {
  background: #e6f4ff;
  border-color: #b8d9ff;
  color: #1c4c7a;
}

.three-d-pill--green {
  background: #e8f8eb;
  border-color: #bde6c3;
  color: #1b6a2b;
}

.notification-main {
  display: grid;
  gap: 4px;
}

.notification-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notification-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #edf2fa;
  color: #44546b;
}

.notification-urgency {
  font-size: 11px;
  font-weight: 700;
}

.notification-urgency.is-danger {
  color: #9f2f33;
}

.notification-urgency.is-warn {
  color: #8a5d0f;
}

.notification-urgency.is-soon {
  color: #3a5d8f;
}

.notification-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.notification-meta {
  font-size: 12px;
  color: var(--muted);
}

.notification-open-btn {
  white-space: nowrap;
}

.notification-item.is-danger {
  border-color: #f0c1c3;
  background: #fff6f6;
}

.notification-item.is-warn {
  border-color: #f1ddb3;
  background: #fffbef;
}

.notification-item.is-soon {
  border-color: #cfe0fb;
  background: #f6faff;
}

.notifications-filter-btn {
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  opacity: 0.55;
}

.notifications-filter-btn.active {
  background: #e4f7ed;
  border-color: #9ed3b1;
  color: #1f5a3f;
  opacity: 1;
}

.modal .notifications-filter-btn {
  background: transparent;
  border-color: transparent;
  color: inherit;
  opacity: 0.55;
}

.modal .notifications-filter-btn.active {
  background: #e4f7ed;
  border-color: #9ed3b1;
  color: #1f5a3f;
  opacity: 1;
}

#notificationsOnlyMineBtn {
  background: transparent;
  border-color: transparent;
  opacity: 0.55;
}

#notificationsOnlyMineBtn.active {
  background: #e4f7ed;
  border-color: #9ed3b1;
  color: #1f5a3f;
  opacity: 1;
}

body.theme-dark .notifications-summary {
  color: #b8bfca;
}

body.theme-dark .notifications-class-btn {
  background: #242933;
  border-color: #3a424f;
  color: #d3dde9;
}

body.theme-dark .notifications-class-btn:hover {
  background: #2c3340;
}

body.theme-dark .notifications-class-btn.active {
  background: #7c57ea;
  border-color: #8b66f2;
  color: #fbf8ff;
  box-shadow: 0 0 0 1px rgba(139, 102, 242, 0.4), 0 0 18px rgba(139, 102, 242, 0.5);
  animation: notifications-pill-pulse 3.8s ease-in-out infinite;
}

@keyframes notifications-pill-pulse {
  0% {
    box-shadow: 0 0 0 1px rgba(125, 86, 233, 0.25), 0 0 12px rgba(125, 86, 233, 0.25);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(125, 86, 233, 0.45), 0 0 22px rgba(125, 86, 233, 0.55);
  }
  100% {
    box-shadow: 0 0 0 1px rgba(125, 86, 233, 0.25), 0 0 12px rgba(125, 86, 233, 0.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notifications-class-btn.active {
    animation: none;
  }
}

body.theme-dark .notifications-class-btn.dept-termo {
  background: #1b2c3f;
  border-color: #2b4c71;
  color: #c8e4ff;
}

body.theme-dark .notifications-class-btn.dept-cad {
  background: #1f3a2d;
  border-color: #2f5c43;
  color: #c7f1d8;
}

body.theme-dark .notifications-class-btn.dept-elettrico {
  background: #3c3320;
  border-color: #6d5c2f;
  color: #ffe7a6;
}

body.theme-dark .notifications-class-btn.dept-termo.active {
  background: #244064;
  border-color: #3b69a4;
  color: #d9ecff;
}

body.theme-dark .notifications-class-btn.dept-cad.active {
  background: #26513b;
  border-color: #3f7a58;
  color: #d9f7e6;
}

body.theme-dark .notifications-class-btn.dept-elettrico.active {
  background: #4a3d1a;
  border-color: #8c7327;
  color: #ffeec2;
}

body.theme-dark .notification-item {
  border-color: #353b45;
  background: #1a1d22;
}

body.theme-dark .delay-pill {
  background: #3a1f21;
  border-color: #6e3b3f;
  color: #ffb9ba;
}

body.theme-dark .due-pill {
  background: #1e2f45;
  border-color: #35517a;
  color: #b9d6ff;
}

body.theme-dark .days-pill--green {
  background: #1f3726;
  border-color: #335941;
  color: #b9ebc3;
}

body.theme-dark .days-pill--yellow {
  background: #3a311d;
  border-color: #6c5b2d;
  color: #ffe8a6;
}

body.theme-dark .days-pill--red {
  background: #3a1f21;
  border-color: #6e3b3f;
  color: #ffb9ba;
}

body.theme-dark .three-d-pill--red {
  background: #3a1f21;
  border-color: #6e3b3f;
  color: #ffb9ba;
}

body.theme-dark .three-d-pill--blue {
  background: #1e2f45;
  border-color: #35517a;
  color: #b9d6ff;
}

body.theme-dark .three-d-pill--green {
  background: #1f3726;
  border-color: #335941;
  color: #b9ebc3;
}

body.theme-dark .notification-kind {
  background: #2a303a;
  color: #d4deec;
}

body.theme-dark .detail-hover-tooltip {
  background: #0f1319;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e9eef6;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

body.theme-dark .notification-item.is-danger {
  border-color: #7d484d;
  background: #2a1d20;
}

body.theme-dark .notification-item.is-warn {
  border-color: #72603a;
  background: #28231a;
}

body.theme-dark .notification-item.is-soon {
  border-color: #475d7d;
  background: #1b222d;
}

body.theme-dark .notification-urgency.is-danger {
  color: #ffb6bd;
}

body.theme-dark .notification-urgency.is-warn {
  color: #f0d48f;
}

body.theme-dark .notification-urgency.is-soon {
  color: #b8d4ff;
}

body.theme-dark .notifications-filter-btn.active {
  background: #2a4b3b;
  border-color: #4f8a6a;
  color: #d6f2e1;
  opacity: 1;
}

body.theme-dark .modal .notifications-filter-btn {
  background: transparent;
  border-color: transparent;
  color: inherit;
  opacity: 0.55;
}

body.theme-dark .modal .notifications-filter-btn.active {
  background: #2a4b3b;
  border-color: #4f8a6a;
  color: #d6f2e1;
  opacity: 1;
}

body.theme-dark #notificationsOnlyMineBtn {
  background: transparent;
  border-color: transparent;
  opacity: 0.55;
}

body.theme-dark #notificationsOnlyMineBtn.active {
  background: #2a4b3b;
  border-color: #4f8a6a;
  color: #d6f2e1;
  opacity: 1;
}

#progressModal .modal-card {
  width: min(1200px, 98vw);
}

body.theme-dark #progressModal .modal-card {
  background: #171b21;
  border-color: #2b3442;
  color: #e2e8f0;
}

.reset-layout {
  display: flex;
  justify-content: center;
  padding: 32px 0 60px;
}

.reset-card {
  width: min(560px, 100%);
}

.reset-actions {
  align-items: center;
  justify-content: space-between;
}

.reset-back {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
}

.reset-back:hover {
  text-decoration: underline;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.activity-gantt-btn {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 10px;
  border: none;
  position: relative;
  overflow: visible;
  transition: transform 0.18s ease, color 0.18s ease;
  color: var(--ink);
}

.activity-gantt-icon {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.activity-gantt-label {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.activity-gantt-btn:hover {
  transform: translateX(6px);
  color: #7c5caa;
}

.activity-gantt-btn:hover .activity-gantt-icon {
  color: #7c5caa;
}

.activity-gantt-btn:hover .activity-gantt-label {
  opacity: 1;
  transform: translateY(-50%) translateX(-4px);
  color: #7c5caa;
}

.activity-gantt-btn:focus,
.activity-gantt-btn:active {
  color: var(--ink);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-hint {
  display: none;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#agreementContractModal {
  z-index: 230;
  padding: 10px;
}

#agreementContractModal .agreement-modal-card {
  width: min(1600px, 100%);
  height: 95vh;
  max-height: 95vh;
}

#agreementContractModal .agreement-modal-note {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

#agreementContractModal .agreement-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

#agreementContractModal .agreement-step {
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  background: #eef2f7;
  font-size: 11px;
  color: #5b6b80;
  text-align: center;
  cursor: pointer;
}

#agreementContractModal .agreement-step.active {
  background: #dfe9f7;
  color: #1f2a3a;
  font-weight: 700;
}

#agreementContractModal .agreement-step-panel {
  display: block;
}

#agreementContractModal .agreement-section-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

#agreementContractModal .agreement-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

#agreementContractModal .agreement-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

#agreementContractModal .agreement-full {
  grid-column: 1 / -1;
}

#agreementContractModal .agreement-form input {
  width: 100%;
}

#agreementContractModal .agreement-form input,
#agreementContractModal .agreement-search input,
#agreementContractModal .agreement-note-field input {
  background: #fff7cc;
  border-color: #e2d38a;
}

#agreementContractModal .agreement-block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

#agreementContractModal .agreement-block-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

#agreementContractModal .agreement-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 10px;
  display: grid;
  gap: 8px;
}

#agreementContractModal .agreement-block-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #3f4d64;
}

#agreementContractModal .agreement-search {
  position: relative;
}

#agreementContractModal .agreement-search input {
  width: 100%;
  min-height: 30px;
  font-size: 12px;
}

#agreementContractModal .agreement-dropdown {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 4px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 12;
  width: max(100%, 900px);
  max-width: min(1400px, calc(100vw - 16px));
  max-height: 320px;
  overflow: auto;
  overflow-x: auto;
}

#agreementContractModal .agreement-suggestion {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font-size: 11px;
  align-items: center;
  white-space: nowrap;
}

#agreementContractModal .agreement-suggestion:hover {
  background: #eef3fb;
}

#agreementContractModal .agreement-suggestion-code {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  min-width: 72px;
}

#agreementContractModal .agreement-suggestion-text {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  flex-wrap: nowrap;
}

#agreementContractModal .agreement-suggestion-desc1 {
  font-weight: 600;
  font-size: 11px;
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

#agreementContractModal .agreement-suggestion-sep {
  color: var(--muted);
  font-size: 10px;
  display: inline;
}

#agreementContractModal .agreement-suggestion-desc2 {
  font-size: 10px;
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

#agreementContractModal .agreement-selected-list {
  display: grid;
  gap: 6px;
  max-height: 170px;
  overflow: auto;
}

#agreementContractModal .agreement-selected-empty {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 0;
}

#agreementContractModal .agreement-selected-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
}

#agreementContractModal .agreement-selected-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}

#agreementContractModal .agreement-selected-qty input {
  width: 56px;
  min-height: 26px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
}

#agreementContractModal .agreement-selected-meta {
  flex: 1;
  display: grid;
  gap: 2px;
}

#agreementContractModal .agreement-selected-code {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

#agreementContractModal .agreement-selected-desc {
  font-size: 11px;
  font-weight: 600;
}

#agreementContractModal .agreement-selected-sub {
  font-size: 10px;
  color: var(--muted);
}

#agreementContractModal .agreement-selected-remove {
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
}

#agreementContractModal .agreement-note-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

#agreementContractModal .agreement-note-field input {
  min-height: 30px;
  font-size: 12px;
}

#agreementContractModal .agreement-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#agreementContractModal .agreement-actions-spacer {
  flex: 1;
}

@media (max-width: 760px) {
  #agreementContractModal .agreement-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #agreementContractModal .agreement-form {
    grid-template-columns: 1fr;
  }

  #agreementContractModal .agreement-dropdown {
    width: 100%;
    max-width: calc(100vw - 32px);
  }
}

.modal-preview {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 12px;
}

body.theme-dark .modal-preview {
  background: #1c2026;
}

.import-progress {
  display: grid;
  gap: 6px;
}

.import-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e7ebf3;
  overflow: hidden;
}

.import-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4b8dff 0%, #53c7a8 100%);
  transition: width 0.18s ease;
}

.import-progress-text {
  font-size: 12px;
  color: var(--muted);
}

.import-result {
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid transparent;
}

.import-result.ok {
  background: #e8f7ee;
  color: #1f5c3a;
  border-color: #9ed6b4;
}

.import-result.error {
  background: #fdeeed;
  color: #9b2f2f;
  border-color: #f1b5b2;
}

body.theme-dark .import-progress-track {
  background: #233349;
}

body.theme-dark .import-result.ok {
  background: rgba(49, 114, 80, 0.25);
  color: #bfe8cd;
  border-color: rgba(122, 196, 154, 0.45);
}

body.theme-dark .import-result.error {
  background: rgba(141, 64, 64, 0.25);
  color: #f0c0c0;
  border-color: rgba(200, 116, 116, 0.45);
}

.import-header-guide {
  display: grid;
  gap: 6px;
  margin: 2px 0 10px;
}

.import-header-guide-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.import-header-guide-label {
  font-size: 12px;
  color: var(--muted);
}

.import-header-guide-row {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f7f9fc;
  color: var(--ink);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
}

body.theme-dark .import-header-guide-row {
  background: #182232;
}

.import-copy-icon-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
}

.import-copy-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.import-copy-icon-btn:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.import-copy-icon-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  outline-offset: 1px;
}

.import-preview-table-wrap {
  margin-top: 8px;
  max-height: 180px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}

.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--ink);
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.import-preview-table th {
  position: sticky;
  top: 0;
  background: #f1f4f9;
  font-weight: 600;
  z-index: 1;
}

.import-preview-table tr.import-preview-row-error td {
  background: rgba(220, 53, 69, 0.14);
  color: #8b1e2a;
}

.import-preview-table tr.import-preview-row-error:hover td {
  background: rgba(220, 53, 69, 0.2);
}

body.theme-dark .import-preview-table th {
  background: #1b2638;
}

body.theme-dark .import-preview-table td {
  color: var(--ink);
}

body.theme-dark .import-preview-table tr.import-preview-row-error td {
  background: rgba(255, 99, 132, 0.18);
  color: #ffd6de;
}

body.theme-dark .import-preview-table tr.import-preview-row-error:hover td {
  background: rgba(255, 99, 132, 0.26);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.workload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.workload-form label {
  min-width: 160px;
}

.workload-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workload-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.workload-group-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.workload-group-range {
  color: var(--muted);
  font-weight: 500;
}

.workload-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 140px 140px 100px;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--ink);
}

.workload-item:first-of-type {
  border-top: none;
}

.workload-code {
  font-weight: 700;
}

.workload-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #fff4d6;
  color: #7a5200;
  border: 1px solid #f0c84b;
}

.workload-pill.is-ok {
  background: #e2f6e8;
  color: #1f5c3a;
  border-color: #7cc59a;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.backup-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backup-card h4 {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.backup-confirm input {
  text-transform: uppercase;
}

.report-dept-menu {
  position: fixed;
  z-index: 1200;
  min-width: 220px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(160, 174, 192, 0.5);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  box-shadow: 0 16px 32px rgba(18, 28, 45, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.report-dept-menu-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.report-dept-menu-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.report-dept-menu-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}

.report-dept-menu-item:first-child {
  border-top: none;
}

.report-dept-menu-name {
  font-weight: 600;
  font-size: 12px;
}

.report-dept-menu-acts {
  font-size: 11px;
  color: var(--muted);
}

.report-dept-activity-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-dept-activity-title {
  flex: 1;
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-dept-activity-date {
  font-size: 10px;
  color: var(--muted);
}

.report-dept-activity-arrow {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  padding: 0 4px;
  cursor: pointer;
}

.report-dept-activity-arrow:hover {
  color: #c71f2d;
}

body.theme-dark .report-dept-activity-title {
  color: var(--ink);
}

body.theme-dark .report-dept-activity-arrow {
  color: #79a6ff;
}

body.theme-dark .report-dept-activity-arrow:hover {
  color: #b8ccff;
}

body.theme-dark .report-dept-menu {
  background: rgba(18, 26, 36, 0.45);
  border-color: rgba(80, 100, 125, 0.7);
  color: var(--ink);
}

body.theme-dark #activityModal {
  background: rgba(5, 10, 16, 0.72);
}

body.theme-dark #activityModal:not(.hidden) {
  animation: activity-modal-backdrop-in-dark 180ms ease-out;
}

body.theme-dark #activityModal .modal-card {
  background: #181b20;
  border-color: #353b45;
}

body.theme-dark #activityModal .modal-header h3 {
  color: #f1f5f9;
}

body.theme-dark #activityModal .modal-hint {
  color: #bcc2cc;
}

body.theme-dark #activityModal label,
body.theme-dark #activityModal .activity-note {
  color: #e7eaef;
}

body.theme-dark #activityModal input,
body.theme-dark #activityModal textarea {
  background: #1f242b;
  border-color: #3b424d;
  color: #e7eaef;
}

body.theme-dark #activityModal input::placeholder,
body.theme-dark #activityModal textarea::placeholder {
  color: #94a3b8;
}

body.theme-dark #activityModal .filter-pill {
  background: rgba(36, 40, 47, 0.9);
  border-color: #454c58;
  color: #e7eaef;
}

body.theme-dark #activityModal .filter-pill:hover {
  border-color: #6c7482;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.36);
}

body.theme-dark #activityModal .filter-pill.active {
  background: rgba(30, 58, 42, 0.9);
  border-color: #4ade80;
  color: #dcfce7;
}

body.theme-dark #activityModal #activityTitleList .filter-pill.active:disabled {
  opacity: 1;
  color: #dcfce7;
}

body.theme-dark #activityModal #activityTitleList .filter-pill.active,
body.theme-dark #activityModal #activityTitleList .filter-pill.active:disabled,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.active,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.active:disabled {
  opacity: 1;
  background: #1f5138;
  border-color: #6de2a4;
  color: #f2fff6;
  text-shadow: 0 1px 0 rgba(3, 10, 20, 0.4);
}

body.theme-dark #activityModal .filter-pill.lavender-pill {
  background: rgba(76, 47, 114, 0.35);
  border-color: #a78bfa;
  color: #ede9fe;
}

body.theme-dark #activityModal .filter-pill.lavender-pill.active {
  background: rgba(124, 92, 170, 0.6);
  border-color: #c4b5fd;
  color: #f5f3ff;
}

body.theme-dark #activityModal #activityTitleList .filter-pill.lavender-pill.active,
body.theme-dark #activityModal #activityTitleList .filter-pill.lavender-pill.active:disabled,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.lavender-pill.active,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.lavender-pill.active:disabled {
  opacity: 1;
  background: #6a4a9a;
  border-color: #cfbcff;
  color: #fbf7ff;
}

body.theme-dark #activityModal #activityTitleList .filter-pill.assente-pill.active,
body.theme-dark #activityModal #activityTitleList .filter-pill.assente-pill.active:disabled,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.assente-pill.active,
body.theme-dark #activityModal #activityTitleListExtra .filter-pill.assente-pill.active:disabled {
  opacity: 1;
  background-color: #4f5968;
  border-color: #9aa5b5;
  color: #f4f7fb;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(201, 210, 222, 0.22) 0px,
    rgba(201, 210, 222, 0.22) 7px,
    rgba(79, 89, 104, 0.18) 7px,
    rgba(79, 89, 104, 0.18) 14px
  );
}

body.theme-dark #activityModal .activity-status-panel {
  background: #1b1f25;
}

body.theme-dark #activityModal .activity-jam-action-btn {
  background: #1f242b;
  border-color: #3b424d;
  color: #c8d2df;
}

body.theme-dark #activityModal .activity-jam-action-btn:hover:not(:disabled) {
  border-color: #5b6a80;
  color: #d8e4ff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

body.theme-dark #activityModal .activity-main-panel {
  background: #171b21;
}

body.theme-dark #activityModal .activity-hours-row .quick-buttons {
  background: #21262e;
  border-color: #3b424d;
}

body.theme-dark #activityModal .activity-hours-row .quick-buttons::before {
  background: #234a35;
}

body.theme-dark #activityModal .activity-hours-row .quick-buttons .ghost {
  color: #c2cedd;
}

body.theme-dark #activityModal .activity-hours-row .quick-buttons .ghost:hover {
  color: #e2e8f0;
}

body.theme-dark #activityModal .activity-hours-row .quick-buttons .ghost.active {
  background: transparent;
  color: #dcfce7;
}

body.theme-dark #activityModal .activity-status-placeholder {
  border-color: #3b424d;
  color: #bcc2cc;
  background: #1a1e24;
}

body.theme-dark #agreementContractModal .modal-card {
  background: #181b20;
  border-color: #353b45;
}

body.theme-dark #agreementContractModal .agreement-modal-note {
  color: #bcc2cc;
}

body.theme-dark #agreementContractModal .agreement-form label {
  color: #cfd6df;
}

body.theme-dark #agreementContractModal .agreement-form input {
  background: #3a3320;
  border-color: #6f5f2b;
  color: #f6f2d3;
}

body.theme-dark #agreementContractModal .agreement-form input::placeholder {
  color: #cbbf97;
}

body.theme-dark #agreementContractModal .agreement-section-note {
  color: #bcc2cc;
}

body.theme-dark #agreementContractModal .agreement-step {
  background: #1d2330;
  color: #aab4c3;
}

body.theme-dark #agreementContractModal .agreement-step.active {
  background: #263652;
  color: #e2ebf7;
}

body.theme-dark #agreementContractModal .agreement-block {
  background: #1a212b;
  border-color: #33445f;
}

body.theme-dark #agreementContractModal .agreement-block-title {
  color: #c7d2e3;
}

body.theme-dark #agreementContractModal .agreement-dropdown {
  background: #1a212b;
  border-color: #33445f;
  box-shadow: 0 12px 28px rgba(3, 7, 18, 0.5);
}

body.theme-dark #agreementContractModal .agreement-suggestion:hover {
  background: #253147;
}

body.theme-dark #agreementContractModal .agreement-selected-item {
  background: #1f2734;
  border-color: #33445f;
}

body.theme-dark #agreementContractModal .agreement-selected-qty input {
  background: #1f242b;
  border-color: #3b424d;
  color: #e7eaef;
}

body.theme-dark #agreementContractModal .agreement-note-field input {
  background: #3a3320;
  border-color: #6f5f2b;
  color: #f6f2d3;
}

body.theme-dark #agreementContractModal .agreement-search input {
  background: #3a3320;
  border-color: #6f5f2b;
  color: #f6f2d3;
}

body.theme-dark #agreementContractModal .agreement-search input::placeholder {
  color: #cbbf97;
}

.modal-actions-top {
  justify-content: flex-start;
}

.activity-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.35fr;
  gap: 16px;
  align-items: start;
}

.activity-main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-status-panel {
  min-width: 0;
}

.activity-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-extra-titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-note textarea {
  min-height: 180px;
}

.activity-note {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .activity-grid {
    grid-template-columns: 1fr;
  }

  .activity-note textarea {
    min-height: 140px;
  }
}

.section {
  margin-top: 16px;
}

.reparti {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reparto-row {
  display: grid;
  grid-template-columns: 1fr 140px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#matrixFilterModal {
  background: rgba(10, 14, 20, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#matrixFilterModal .modal-card {
  width: min(920px, 95vw);
  height: min(76vh, 680px);
  max-height: min(76vh, 680px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
  gap: 10px;
}

#matrixFilterModal .matrix-filter-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 32px;
  max-height: 96px;
  overflow: auto;
  padding: 2px 2px 2px 0;
}

#matrixFilterModal .matrix-filter-pill {
  border: 1px solid #bfd1ea;
  background: #e8f1ff;
  color: #1d3a62;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

#matrixFilterModal .matrix-filter-pill:hover {
  background: #dbe9ff;
  border-color: #9db7dc;
}

#reportSpecialFilterModal {
  background: rgba(10, 14, 20, 0.58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#reportSpecialFilterModal .report-special-filter-card {
  width: min(1120px, 98vw);
  height: min(86vh, 820px);
  max-height: min(86vh, 820px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.report-special-filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.report-special-year-label {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #4c5566;
}

#reportSpecialFilterYear {
  min-width: 170px;
}

.report-special-filter-pills {
  display: grid;
  grid-template-columns: repeat(10, minmax(62px, 1fr));
  gap: 8px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  padding: 2px 4px 2px 0;
}

.report-special-pill {
  border: 1px solid #c7d2e4;
  border-radius: 999px;
  padding: 7px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f8;
  color: #526079;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.report-special-pill:hover {
  border-color: #91a8c8;
  background: #e5edf9;
  color: #1f3f69;
  transform: translateY(-1px);
}

.report-special-pill.active {
  border-color: #1f5c35;
  background: #e8f7ee;
  color: #1f5c35;
}

.report-special-pill.group-col-end {
  margin-right: 12px;
}

.report-special-pill.group-row-end {
  margin-bottom: 12px;
}

body.theme-dark #reportSpecialFilterModal {
  background: rgba(4, 7, 11, 0.74);
}

body.theme-dark #reportSpecialFilterModal .report-special-filter-card {
  background: #181b20;
  border-color: #3a404b;
  color: #eef2f8;
}

body.theme-dark .report-special-year-label {
  color: #c4cedd;
}

body.theme-dark #reportSpecialFilterYear {
  background: #1f232a;
  border-color: #454d5a;
  color: #eef2f8;
}

body.theme-dark .report-special-pill {
  border-color: #4f5d75;
  background: #2a313d;
  color: #cbd7e9;
}

body.theme-dark .report-special-pill:hover {
  border-color: #6f82a3;
  background: #323c4c;
  color: #f0f5ff;
}

body.theme-dark .report-special-pill.active {
  border-color: #8db79a;
  background: #243629;
  color: #bfe9cc;
}

#assignModal {
  background: rgba(10, 14, 20, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#assignModal .modal-card {
  width: min(760px, 94vw);
}

#matrixFilterModal #matrixFilterList {
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding-right: 4px;
}

#matrixFilterModal .matrix-filter-commessa-pill {
  display: grid;
  grid-template-columns: minmax(108px, 128px) minmax(0, 1fr) minmax(120px, 170px);
  gap: 10px;
  align-items: center;
}

#matrixFilterModal .matrix-filter-commessa-code {
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

#matrixFilterModal .matrix-filter-commessa-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#matrixFilterModal .matrix-filter-commessa-type {
  justify-self: end;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: #5c677d;
  white-space: nowrap;
}

#matrixFilterModal #matrixFilterList .filter-pill.active .matrix-filter-commessa-type {
  color: #1f5c35;
}

body.theme-dark #matrixFilterModal {
  background: rgba(4, 7, 11, 0.72);
}

body.theme-dark #matrixFilterModal .modal-card {
  background: #181b20;
  border-color: #3a404b;
}

body.theme-dark #matrixFilterModal #matrixFilterTitle {
  color: #f1f4f9;
}

body.theme-dark #matrixFilterModal #matrixFilterYear,
body.theme-dark #matrixFilterModal #matrixFilterNumero,
body.theme-dark #matrixFilterModal #matrixFilterSearch {
  background: #1f232a;
  border-color: #454d5a;
  color: #eef2f8;
}

body.theme-dark #matrixFilterModal #matrixFilterYear::placeholder,
body.theme-dark #matrixFilterModal #matrixFilterNumero::placeholder,
body.theme-dark #matrixFilterModal #matrixFilterSearch::placeholder {
  color: #aeb7c4;
}

body.theme-dark #matrixFilterModal #matrixFilterList .filter-pill {
  background: #252a33;
  border-color: #4b5463;
  color: #edf2fb;
}

body.theme-dark #matrixFilterModal #matrixFilterList .filter-pill:hover {
  background: #2d3440;
  border-color: #6c7688;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.32);
}

body.theme-dark #matrixFilterModal #matrixFilterList .filter-pill.active {
  background: #cfe0ff;
  border-color: #a9c2ee;
  color: #16253f;
}

body.theme-dark #matrixFilterModal .matrix-filter-commessa-type {
  color: #b9c4d6;
}

body.theme-dark #matrixFilterModal #matrixFilterList .filter-pill.active .matrix-filter-commessa-type {
  color: #213d68;
}

body.theme-dark #matrixFilterModal .matrix-filter-pill {
  border-color: #4f5d75;
  background: #2c3950;
  color: #deebff;
}

body.theme-dark #matrixFilterModal .matrix-filter-pill:hover {
  background: #364563;
  border-color: #6d7f9f;
}

body.theme-dark #assignModal {
  background: rgba(4, 7, 11, 0.74);
}

body.theme-dark #assignModal .modal-card {
  background: #181b20;
  border-color: #3a404b;
  color: #eef2f8;
}

body.theme-dark #assignModal .modal-header h3 {
  color: #f2f5fa;
}

body.theme-dark #assignModal .modal-hint {
  color: #c0c8d4;
}

body.theme-dark #assignModal #assignActivities .filter-pill {
  background: #252b35;
  border-color: #4d5868;
  color: #edf2fb;
}

body.theme-dark #assignModal #assignActivities .filter-pill:hover {
  background: #2e3745;
  border-color: #6c7e98;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

body.theme-dark #assignModal #assignActivities .filter-pill.active {
  background: #d7e6ff;
  border-color: #afc5ea;
  color: #16253f;
}

body.theme-dark #assignModal #assignAssenzaOre,
body.theme-dark #assignModal #assignAltroNote {
  background: #1f232a;
  border-color: #454d5a;
  color: #eef2f8;
}

body.theme-dark #assignModal #assignAssenzaOre::placeholder,
body.theme-dark #assignModal #assignAltroNote::placeholder {
  color: #aeb7c4;
}

body.theme-dark #assignModal .ghost:not(.modal-close-btn):not(.activity-gantt-btn) {
  background: #252b35;
  border-color: #5a6a83;
  color: #deebff;
}

body.theme-dark #assignModal .ghost:not(.modal-close-btn):not(.activity-gantt-btn):hover {
  background: #2f3949;
  border-color: #7f94b5;
  color: #f3f8ff;
}

.calendar-panel {
  grid-column: 1 / -1;
}

.calendar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  min-height: 240px;
}

.calendar-day {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}

.calendar-day.calendar-today {
  border-color: #f0c84b;
  background: #fff8df;
  box-shadow: inset 0 0 0 1px rgba(240, 200, 75, 0.35);
}

.calendar-day h4 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.calendar-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #f2f6ff;
  font-size: 12px;
  cursor: pointer;
}

.calendar-card.calendar-cad {
  background: #e9f6ef;
  border-color: #7cc59a;
  color: #1f4f2b;
}

.calendar-card.calendar-termo {
  background: #e9f1fb;
  border-color: #7aa4dc;
  color: #1f3d6a;
}

.calendar-card.calendar-elett {
  background: #fff4d6;
  border-color: #f0c84b;
  color: #5a3f07;
}

.calendar-card.calendar-cad .calendar-meta,
.calendar-card.calendar-termo .calendar-meta,
.calendar-card.calendar-elett .calendar-meta {
  color: inherit;
  opacity: 0.75;
}

.calendar-card strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.calendar-meta {
  color: var(--muted);
  font-size: 11px;
}

.calendar-empty {
  font-size: 12px;
  color: var(--muted);
}

.matrix-panel {
  grid-column: 1 / -1;
  position: relative;
}

.todo-panel {
  grid-column: 1 / -1;
}

.matrix-panel .panel-header {
  margin-bottom: 0;
  padding-bottom: 10px;
}

.report-panel {
  grid-column: 1 / -1;
}

.report-panel .panel-header {
  position: sticky;
  top: calc(var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
  z-index: 6;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin: -16px -16px 0 -16px;
  padding: 2px 16px 4px;
  border-bottom: 1px solid rgba(215, 219, 227, 0.7);
}

.report-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

.report-controls-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.report-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1 0 auto;
  min-width: max-content;
  align-items: center;
}

#reportDescFilter {
  flex: 1 1 160px;
  min-width: 120px;
  width: min(240px, 100%);
  max-width: 240px;
}

#reportNumberFilter {
  flex: 0 0 82px;
  width: 82px;
  max-width: 82px;
}

#reportYearFilter {
  flex: 0 0 112px;
  width: 112px;
  max-width: 112px;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  margin-left: 8px;
  justify-content: flex-end;
}

#reportThermoFilterBtn {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-view-toggle-btn {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  height: 30px;
  padding: 4px 6px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-list-export-btn {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  height: 30px;
  padding: 4px 6px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-list-export-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.report-prelim-assistant-btn {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  height: 30px;
  padding: 4px 6px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-prelim-assistant-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.report-view-toggle-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  width: 14px;
  transition: transform 0.18s ease;
  transform-origin: center;
}

.report-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.report-header-actions .ghost {
  border: none;
}

.report-view-toggle-icon > span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.report-view-toggle-btn.is-list .report-view-toggle-icon {
  transform: rotate(90deg);
}

.report-gantt {
  --report-gantt-row-height: 58px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: none;
}

.report-gantt-header,
.report-gantt-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.report-gantt-row {
  background: transparent;
  min-height: var(--report-gantt-row-height);
}

.report-gantt-row:nth-of-type(even) {
  background: #f7f9fc;
}

.milestone-picker {
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 18px 30px rgba(10, 20, 35, 0.18);
  z-index: 200;
  min-width: 220px;
}

.milestone-picker.is-telaio-target {
  border-color: #cbb6f0;
  box-shadow: 0 18px 30px rgba(92, 64, 140, 0.2);
}

.milestone-picker.is-telaio-target .milestone-label {
  color: #5b3f8b;
}

.milestone-picker.is-telaio-on-time {
  border-color: #7cc59a;
  box-shadow: 0 18px 30px rgba(60, 132, 94, 0.2);
}

.milestone-picker.is-telaio-on-time .milestone-label {
  color: #2b6a4a;
}

.milestone-picker.is-telaio-late {
  border-color: #7aa4dc;
  box-shadow: 0 18px 30px rgba(61, 102, 154, 0.2);
}

.milestone-picker.is-telaio-late .milestone-label {
  color: #2b4e78;
}

.milestone-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.milestone-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.milestone-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-transform: capitalize;
}

.milestone-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 8px 0 6px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.milestone-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.milestone-day {
  border: 1px solid transparent;
  background: #f7f9fc;
  border-radius: 8px;
  height: 28px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
}

.milestone-day:hover {
  border-color: #cbb6f0;
}

.milestone-day.today {
  border-color: #f0c84b;
  background: #fff4d6;
}

.milestone-day.weekend {
  color: #9aa3ad;
}

.milestone-day.selected {
  border-color: #cbb6f0;
  background: #f3edff;
  color: #4c2f72;
  font-weight: 600;
}

.milestone-picker.is-telaio-on-time .milestone-day.selected {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.milestone-picker.is-telaio-late .milestone-day.selected {
  background: #dceefb;
  border-color: #7aa4dc;
  color: #1e4a6a;
}

.milestone-day.empty {
  background: transparent;
  cursor: default;
}

.milestone-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

body.theme-dark .milestone-picker {
  background: #141c26;
  border-color: #2a3b52;
  box-shadow: 0 18px 30px rgba(8, 14, 24, 0.45);
}

body.theme-dark .milestone-title {
  color: #9aa6b5;
}

body.theme-dark .milestone-label {
  color: #e6edf5;
}

body.theme-dark .milestone-weekdays {
  color: #9aa6b5;
}

body.theme-dark .milestone-day {
  background: #1c2736;
  color: #e6edf5;
}

body.theme-dark .milestone-day:hover {
  border-color: #6c5fc7;
}

body.theme-dark .milestone-day.today {
  border-color: #c9a84b;
  background: #3a3215;
  color: #fff1c2;
}

body.theme-dark .milestone-day.weekend {
  color: #7f8fa6;
}

body.theme-dark .milestone-day.selected {
  border-color: #6c5fc7;
  background: #2a1f3f;
  color: #e7dbff;
}

.milestone-actions .milestone-transport-btn {
  margin-right: auto;
}

.milestone-actions .is-ordered {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.milestone-transport-btn {
  width: 30px;
  padding: 4px 0;
  text-align: center;
  font-size: 13px;
  line-height: 1;
  border: 1px solid rgba(108, 95, 199, 0.35);
  background: rgba(108, 95, 199, 0.08);
  color: #6c5fc7;
}

.milestone-transport-btn.is-active {
  border-color: #6c5fc7;
  background: rgba(108, 95, 199, 0.18);
  box-shadow: 0 0 0 2px rgba(108, 95, 199, 0.2);
}

.milestone-actions #milestoneOrderBtn {
  background: #fff6cc;
  border: 1px solid #f2d27a;
  color: #6b5600;
}

.milestone-drag-label {
  position: fixed;
  z-index: 1000;
  padding: 6px 10px;
  border-radius: 10px;
  background: #f3edff;
  border: 1px solid #cbb6f0;
  color: #4c2f72;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 22px rgba(36, 40, 66, 0.18);
  pointer-events: none;
}

.milestone-drag-label.is-telaio-on-time {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.milestone-drag-label.is-telaio-late {
  background: #dceefb;
  border-color: #7aa4dc;
  color: #1e4a6a;
}

.report-gantt-label {
  width: 220px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  text-align: right;
  min-height: var(--report-gantt-row-height);
  position: relative;
  padding-left: 16px;
}

.report-commessa-block {
  text-align: right;
  padding: 6px 4px;
  line-height: 1.2;
  border-radius: 10px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  align-self: flex-end;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.report-commessa-head {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  width: 100%;
}

.report-commessa-num {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.report-commessa-year {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.report-commessa-desc {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  align-self: flex-end;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-commessa-block:hover,
.report-commessa-block:focus-visible {
  background: #e9e1f7;
  box-shadow: 0 10px 24px rgba(108, 95, 199, 0.18);
  transform: translateY(-1px);
}

.report-commessa-block:hover .report-commessa-head,
.report-commessa-block:focus-visible .report-commessa-head,
.report-commessa-block:hover .report-commessa-desc,
.report-commessa-block:focus-visible .report-commessa-desc {
  color: #2f1c4d;
}

.report-commessa-block:hover .report-commessa-year,
.report-commessa-block:focus-visible .report-commessa-year {
  color: #4b3a66;
}

body.theme-dark .report-commessa-block:hover,
body.theme-dark .report-commessa-block:focus-visible {
  background: #5b4a7a;
  box-shadow: 0 10px 24px rgba(20, 14, 34, 0.4);
}

body.theme-dark .report-commessa-block:hover .report-commessa-head,
body.theme-dark .report-commessa-block:focus-visible .report-commessa-head,
body.theme-dark .report-commessa-block:hover .report-commessa-desc,
body.theme-dark .report-commessa-block:focus-visible .report-commessa-desc {
  color: #f5f0ff;
}

body.theme-dark .report-commessa-block:hover .report-commessa-year,
body.theme-dark .report-commessa-block:focus-visible .report-commessa-year {
  color: #d9c9f5;
}

.report-gantt-track {
  position: relative;
  flex: 1;
  height: 100%;
  min-height: 28px;
  border-radius: 10px;
  background: transparent;
  border: none;
  overflow: hidden;
  width: 100%;
}

.report-gantt-track.report-gantt-jump-glow {
  box-shadow:
    0 0 0 2px rgba(124, 92, 170, 0.7),
    0 0 26px rgba(124, 92, 170, 0.55);
  animation: reportGanttGlow 2.6s ease-out 1;
}

@keyframes reportGanttGlow {
  0% {
    box-shadow:
      0 0 0 0 rgba(124, 92, 170, 0.9),
      0 0 0 rgba(124, 92, 170, 0.7);
  }
  65% {
    box-shadow:
      0 0 0 3px rgba(124, 92, 170, 0.7),
      0 0 28px rgba(124, 92, 170, 0.6);
  }
  100% {
    box-shadow:
      0 0 0 2px rgba(124, 92, 170, 0.6),
      0 0 20px rgba(124, 92, 170, 0.45);
  }
}

.report-gantt-track-pan {
  cursor: grab;
}

.report-gantt-track-pan:active {
  cursor: grabbing;
}

.report-gantt-track.is-dragging {
  outline: 1px dashed rgba(100, 116, 139, 0.5);
  outline-offset: -1px;
  background: rgba(148, 163, 184, 0.08);
}

.report-gantt-track-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: var(--report-gantt-row-height);
  align-self: stretch;
}

.report-gantt-track-header {
  cursor: grab;
  height: 56px;
  min-height: 56px;
}

.report-gantt-track-header.is-dragging {
  cursor: grabbing;
}

.report-gantt-header-content {
  position: absolute;
  inset: 0;
  will-change: transform;
  padding-left: 2px;
}

.report-gantt-track-content {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.report-gantt-track-content.is-previewing {
  opacity: 0.95;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1);
  --preview-icon-scale: var(--preview-inv-scale, 1);
}

.report-gantt-label-resize {
  position: absolute;
  left: 2px;
  top: 4px;
  bottom: 4px;
  width: 10px;
  border: none;
  border-radius: 999px;
  padding: 0;
  margin: 0;
  cursor: ns-resize;
  background: linear-gradient(
    to bottom,
    rgba(130, 142, 162, 0.22) 0%,
    rgba(130, 142, 162, 0.45) 50%,
    rgba(130, 142, 162, 0.22) 100%
  );
  opacity: 0.35;
  transition: opacity 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  z-index: 2;
  touch-action: none;
}

.report-gantt-label-resize:hover,
.report-gantt-label-resize:focus-visible,
.report-gantt-label-resize.is-dragging {
  opacity: 0.92;
  transform: scaleX(1.05);
  box-shadow: 0 0 0 1px rgba(95, 112, 140, 0.35);
}

body.is-report-gantt-row-resizing {
  cursor: ns-resize;
  user-select: none;
}

body.is-report-gantt-row-resizing .report-gantt-label-resize {
  opacity: 0.92;
}

.report-gantt-week-bands {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.report-gantt-week-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(200, 188, 236, 0.08);
  box-sizing: border-box;
}

.report-gantt-week-band.is-alt {
  background: rgba(200, 188, 236, 0.16);
}

.report-gantt-week-boundary {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(140, 150, 165, 0.35);
  z-index: 1;
}

.report-gantt-weekend {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(120, 130, 145, 0.12);
  border-right: 1px solid rgba(120, 130, 145, 0.2);
}

.report-gantt-week-label {
  position: absolute;
  top: 2px;
  text-align: left;
  font-size: 10px;
  color: #7a7f8c;
  text-transform: lowercase;
  z-index: 1;
  pointer-events: none;
  padding-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  transform: scaleX(var(--preview-inv-scale, 1));
  transform-origin: center;
}

.report-gantt-months {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.report-gantt-month-label {
  position: absolute;
  top: 18px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #8b8f99;
  text-transform: lowercase;
  padding: 1px 0;
  border-radius: 6px;
  transform: scaleX(var(--preview-inv-scale, 1));
  transform-origin: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-gantt-month-label.is-base {
  background: rgba(218, 226, 238, 0.3);
}

.report-gantt-month-label.is-alt {
  background: rgba(200, 212, 230, 0.45);
}

.report-gantt-day-numbers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.report-gantt-day-number {
  position: absolute;
  top: 34px;
  text-align: center;
  font-size: 10px;
  color: #6b7280;
  transform: scaleX(var(--preview-inv-scale, 1));
  transform-origin: center;
}

.report-gantt-day-number.is-monday {
  color: #374151;
  font-weight: 700;
}

.report-gantt-day-numbers.is-sparse .report-gantt-day-number {
  display: none;
}

.report-gantt-day-numbers.is-sparse .report-gantt-day-number.is-monday,
.report-gantt-day-numbers.is-sparse .report-gantt-day-number.is-range-start {
  display: block;
}

.report-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.report-pill-orange {
  background: transparent;
  border: none;
  color: #f97316;
  text-decoration: underline;
}

body.theme-dark .report-pill-orange {
  color: #fb923c;
}

.report-gantt-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e1e6ef;
}

.report-gantt-tick-label {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.report-gantt-today-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(148, 163, 184, 0.25);
  border-left: 1px solid rgba(100, 116, 139, 0.6);
  border-right: 1px solid rgba(100, 116, 139, 0.6);
  z-index: 2;
  pointer-events: none;
}

.report-gantt-bar {
  position: absolute;
  bottom: 4px;
  height: 8px;
  border-radius: 999px;
  background: #e1cffc;
  border: 1px solid #9b78df;
  opacity: 0.85;
  z-index: 1;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.55) 0,
    rgba(255, 255, 255, 0.55) 1px,
    rgba(255, 255, 255, 0) 1px,
    rgba(255, 255, 255, 0) var(--day-px, 14px)
  );
  background-position-x: calc(var(--bar-offset, 0px) * -1);
}

.report-gantt-bar.is-ordine-only {
  background: #e1cffc;
  border-color: #9b78df;
  opacity: 0.9;
}

.report-gantt-bar.is-missing-ordine {
  background: #ffe0bf;
  border-color: #f59e0b;
  opacity: 0.85;
}

.report-gantt-row .report-gantt-label.missing-both .report-title {
  color: #b45309;
}

.report-gantt-row .report-gantt-label.missing-ordine .report-title {
  color: #c26d00;
}

.report-gantt-bar.is-late {
  background: #d8c2fb;
  border-color: #8c63d6;
}

.report-gantt-dot {
  position: absolute;
  bottom: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aab4c1;
  z-index: 1;
  transform: scaleX(var(--preview-icon-scale, 1));
  transform-origin: center;
}

.report-gantt-milestone {
  --gantt-milestone-transform: translateX(-50%);
  position: absolute;
  top: auto;
  bottom: 2px;
  width: 16px;
  height: 16px;
  background: #f3edff;
  border: 1px solid #cbb6f0;
  color: #4c2f72;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: var(--gantt-milestone-transform) scaleX(var(--preview-icon-scale, 1));
  transform-origin: center;
  z-index: 3;
  cursor: pointer;
  padding: 0;
}

.report-gantt-milestone.is-consegna {
  --gantt-milestone-transform: translateX(-50%) scaleX(-1);
  background: transparent;
  border: none;
  color: #6c5fc7;
  width: 18px;
  height: 18px;
}

.report-gantt-milestone.is-prelievo {
  background: transparent;
  border: none;
  color: #6c5fc7;
  width: 18px;
  height: 18px;
  font-size: 14px;
}

.report-gantt-milestone.is-consegna-totale {
  background: #dceefb;
  border: 1px solid #7aa4dc;
  color: #1e4a6a;
  width: 18px;
  height: 18px;
  font-size: 13px;
  border-radius: 4px;
  cursor: default;
}

.report-gantt-milestone.is-consegna-totale-done {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.report-gantt-milestone.is-collaudo {
  background: #dceefb;
  border: 1px solid #7aa4dc;
  color: #1e4a6a;
  width: 18px;
  height: 18px;
  font-size: 12px;
  border-radius: 999px;
  cursor: default;
}

.report-gantt-milestone.is-collaudo-done {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.report-gantt-milestone.is-kit-cavi {
  --gantt-milestone-transform: translateX(-50%);
  background: #f7f0e6;
  border: 1px solid #e7d5c1;
  color: #5a3b2a;
  width: 18px;
  height: 18px;
  font-size: 13px;
  border-radius: 4px;
}

.report-gantt-kit-glyph {
  display: inline-block;
  line-height: 1;
  transform: rotate(90deg);
}


.report-gantt-milestone.is-telaio-on-time {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.report-gantt-milestone.is-telaio-late {
  background: #dceefb;
  border-color: #7aa4dc;
  color: #1e4a6a;
}

.report-gantt-milestone.is-telaio-planned {
  background: #dceefb;
  border-color: #7aa4dc;
  color: #1e4a6a;
}

.report-gantt-milestone.is-telaio-ordered {
  background: #e2f6e8;
  border-color: #7cc59a;
  color: #1f5c3a;
}

.report-gantt-milestone.is-telaio-done-not-ordered {
  background: #fff3e6;
  border-color: #f4b077;
  color: #8a4b10;
}

.report-gantt-milestone.dragging {
  cursor: ew-resize;
  box-shadow: 0 6px 12px rgba(76, 47, 114, 0.2);
}

.report-gantt-milestone-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #cbb6f0;
  opacity: 0.8;
  z-index: 2;
  pointer-events: none;
  transform: translateX(-50%) scaleX(var(--preview-icon-scale, 1));
  transform-origin: center;
}

.report-gantt-milestone.is-telaio-actual {
  box-shadow: 0 6px 12px rgba(30, 74, 106, 0.18);
}

.report-gantt-milestone.is-locked {
  cursor: not-allowed;
  opacity: 0.8;
}

.report-gantt-milestone.is-locked[data-field="ordine_pianificato"] {
  cursor: default;
}

.report-gantt-milestone-line.is-telaio-actual {
  opacity: 0.9;
}

.report-gantt-milestone.is-telaio-delivered {
  border-color: #1ea77a;
  box-shadow: 0 0 0 2px rgba(30, 167, 122, 0.28);
}

.report-gantt-milestone-line.is-telaio-on-time {
  background: #7cc59a;
  opacity: 0.9;
}

.report-gantt-milestone-line.is-telaio-late {
  background: #7aa4dc;
  opacity: 0.9;
}

.report-gantt-activity {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid;
  border-radius: 0;
  z-index: 2;
  cursor: copy;
}

.report-gantt-activity.dept-cad {
  background: #e9f6ef;
  border-color: #7cc59a;
}

.report-gantt-activity.dept-termo {
  background: #e9f1fb;
  border-color: #7aa4dc;
}

.report-gantt-activity.dept-elett {
  background: #fff4d6;
  border-color: #f0c84b;
}

.report-gantt-activity.dept-other {
  background: #eef2f7;
  border-color: #c7d0dd;
}

.report-gantt-empty {
  position: static;
  font-size: 10px;
  color: var(--muted);
  align-self: flex-end;
  text-align: right;
  margin-left: auto;
}

.report-gantt-empty.report-pill-orange {
  color: #f97316;
}

body.theme-dark .report-gantt-empty.report-pill-orange {
  color: #fb923c;
}

.report-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.report-toggle-btn {
  height: 30px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.report-toggle-btn.active {
  background: #e8f7ee;
  color: #1f5c35;
  border: none;
}

.report-grid.report-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none;
}

.report-year-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 6px 4px 0;
}

.report-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card);
  display: grid;
  grid-template-columns: minmax(220px, 380px) repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: center;
}

.report-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}

.report-commessa-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.report-commessa-link:hover {
  text-decoration: underline;
  background: transparent;
  color: inherit;
}

body.theme-dark .report-commessa-link:hover {
  background: transparent;
  color: inherit;
}

.report-title-parts {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.report-title-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.report-title-year {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.report-title-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

.report-machine-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #ccd8ea;
  background: #eef4ff;
  color: #27446f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18px;
  text-transform: uppercase;
}

.report-meta {
  font-size: 11px;
  color: var(--muted);
}

.report-schedule {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
}

.report-schedule-item {
  line-height: 1.3;
}

.report-schedule-empty,
.report-schedule-loading {
  font-style: italic;
  color: var(--muted);
}

.report-missing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.missing-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff1f2;
  border: 1px solid #f2b8b5;
  color: #b42318;
  font-weight: 600;
}

.report-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.report-value {
  font-weight: 600;
  font-size: 12px;
}

.report-milestone {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-sub {
  font-size: 11px;
  color: var(--muted);
}

.report-milestone.is-late .report-value,
.report-milestone.is-late .report-sub {
  color: #b42318;
}

.report-milestone.is-ok .report-value,
.report-milestone.is-ok .report-sub {
  color: #1f5c35;
}

.report-milestone.is-planned .report-value,
.report-milestone.is-planned .report-sub {
  color: #1a66d4;
}

.report-milestone.is-today .report-value,
.report-milestone.is-today .report-sub {
  color: #ad6a00;
}

body.theme-dark .report-grid.report-list {
  background: transparent;
}

body.theme-dark .report-year-header {
  color: #c4cad4;
}

body.theme-dark .report-item {
  background: #1a1f26;
  border-color: #3a4352;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
}

body.theme-dark .report-title,
body.theme-dark .report-commessa-link {
  color: #eef2f8;
}

body.theme-dark .report-title-year {
  color: #b8c1cf;
}

body.theme-dark .report-machine-pill {
  background: #2a3b54;
  border-color: #546d95;
  color: #dce9ff;
}

body.theme-dark .report-commessa-link:hover {
  color: #ffffff;
}

body.theme-dark .report-meta,
body.theme-dark .report-schedule,
body.theme-dark .report-schedule-empty,
body.theme-dark .report-schedule-loading,
body.theme-dark .report-label,
body.theme-dark .report-sub {
  color: #b8c1cf;
}

body.theme-dark .report-value {
  color: #edf2fb;
}

body.theme-dark .missing-pill {
  background: rgba(180, 35, 24, 0.2);
  border-color: rgba(237, 113, 99, 0.58);
  color: #ffd2cc;
}

body.theme-dark .report-milestone.is-late .report-value,
body.theme-dark .report-milestone.is-late .report-sub {
  color: #ff9f93;
}

body.theme-dark .report-milestone.is-ok .report-value,
body.theme-dark .report-milestone.is-ok .report-sub {
  color: #9be4b5;
}

body.theme-dark .report-milestone.is-planned .report-value,
body.theme-dark .report-milestone.is-planned .report-sub {
  color: #8ec8ff;
}

body.theme-dark .report-milestone.is-today .report-value,
body.theme-dark .report-milestone.is-today .report-sub {
  color: #f5d18a;
}

@media (max-width: 980px) {
  .report-item {
    grid-template-columns: 1fr;
  }
}

.report-grid {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}

.todo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  flex-wrap: wrap;
  position: sticky;
  top: calc(var(--todo-panel-header-height, 58px) + var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
  z-index: 16;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(215, 219, 227, 0.7);
  padding: 6px 8px;
}

.todo-header-table-host {
  width: calc(100% + 16px);
  margin: 6px -8px 0;
  overflow-x: hidden;
  overflow-y: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  background: #f9fbff;
  overflow-anchor: none;
}

.todo-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.todo-sub {
  font-size: 11px;
  color: var(--muted);
}

.todo-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.todo-filters input,
.todo-filters select {
  min-width: 120px;
}

.todo-number-sync-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.todo-number-sync-wrap #todoNumberFilter {
  min-width: 108px;
}

.todo-filter-sync-btn {
  position: relative;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #b9c5d8;
  color: #385378;
}

.todo-filter-sync-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.todo-filter-sync-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-2px);
  min-width: 230px;
  max-width: 290px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid #b7c7dd;
  background: #f4f8ff;
  color: #2a4469;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  box-shadow: 0 8px 18px rgba(21, 34, 53, 0.15);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  z-index: 24;
}

.todo-filter-sync-btn:hover .todo-filter-sync-tooltip,
.todo-filter-sync-btn:focus-visible .todo-filter-sync-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.todo-filter-sync-btn:hover {
  color: #1f3e67;
  border-color: #8ea8cb;
  background: #eef4ff;
}

.todo-filter-sync-btn.active {
  color: #2b2054;
  border-color: rgba(178, 159, 230, 0.75);
  background: rgba(178, 159, 230, 0.28);
}

.todo-filter-sync-btn.active::after {
  content: attr(data-count);
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  border: 1px solid rgba(178, 159, 230, 0.65);
  background: #efe9ff;
  color: #3b2b6d;
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

.report-special-filter-btn {
  position: relative;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: none;
  color: #4d5f7c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-special-filter-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.report-special-filter-btn:hover {
  color: #1f3e67;
  background: none;
}

.report-special-filter-btn.active {
  color: #2b2054;
  background: none;
}

.report-special-filter-btn.active::after {
  content: attr(data-count);
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  border: 1px solid rgba(178, 159, 230, 0.65);
  background: #efe9ff;
  color: #3b2b6d;
  font-size: 9px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

.todo-toggle-btn.active {
  background: rgba(178, 159, 230, 0.28);
  border-color: rgba(178, 159, 230, 0.6);
  color: #3b2b6d;
}

button.todo-toggle-btn {
  border-color: rgba(178, 159, 230, 0.35);
  color: #5b4a88;
}

button.todo-toggle-btn:hover {
  border-color: rgba(178, 159, 230, 0.55);
  background: rgba(178, 159, 230, 0.12);
}

body.theme-dark .todo-toggle-btn.active {
  background: rgba(178, 159, 230, 0.22);
  border-color: rgba(178, 159, 230, 0.6);
  color: #efe9ff;
}

body.theme-dark button.todo-toggle-btn {
  border-color: rgba(178, 159, 230, 0.4);
  color: #d9cff7;
}

body.theme-dark button.todo-toggle-btn:hover {
  border-color: rgba(178, 159, 230, 0.6);
  background: rgba(178, 159, 230, 0.16);
}

.todo-grid {
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  overflow-x: auto;
  overflow-y: visible;
  background: #f9fbff;
  overflow-anchor: none;
}

.todo-table {
  display: grid;
  min-width: 900px;
}

.todo-table-head {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.todo-table-body .todo-cell {
  border-top: none;
}

.todo-cell {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  font-size: 12px;
}

.todo-cell:last-child {
  border-right: none;
}

.todo-head {
  background: #f3f6fb;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 10px;
}

.todo-head-sticky {
  position: sticky;
  z-index: 18;
  background: #f3f6fb;
}

.todo-head-sticky-primary {
  top: var(--todo-head-row1-top, 0px);
}

.todo-head-sticky-secondary {
  top: var(--todo-head-row2-top, 36px);
}

.todo-group {
  text-align: center;
  font-weight: 600;
}

.todo-group.todo-group-cad {
  background: #e9f7ef;
  color: #1f5d3f;
}

.todo-group.todo-group-elettrico {
  background: #fff6cc;
  color: #6b5600;
}

.todo-group.todo-group-termodinamico {
  background: #e8f3ff;
  color: #2b4b7c;
}

.todo-activity-head {
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--ink);
}

.todo-commessa {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f9fbff;
  font-weight: 600;
}

.todo-commessa .todo-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.todo-commessa-status {
  background: #f9fbff;
}

.todo-machine-head {
  text-transform: none;
  letter-spacing: 0;
}

.todo-machine-cell {
  background: #f9fbff;
}

.todo-machine-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.todo-commessa-status-clickable {
  cursor: pointer;
}

.todo-priority-head {
  text-transform: none;
  letter-spacing: 0;
}

.todo-priority-cell {
  background: #f9fbff;
  text-align: center;
}

.todo-priority-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d4dce8;
  background: #edf2f9;
  color: #334155;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.todo-priority-value.is-empty {
  color: #7b8799;
  background: #f3f5fa;
  border-color: #e1e6ee;
}

.todo-global-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.12px;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: none;
}

.todo-global-in-corso {
  background: #e8f0ff;
  color: #2a4f86;
  border-color: #bdd2ff;
}

.todo-global-rilasciata {
  background: #efe9ff;
  color: #5b3f8f;
  border-color: #d4c6ff;
}

.todo-global-sospesa {
  background: #fde8e8;
  color: #8f3a3a;
  border-color: #f3b2b2;
}

.todo-global-evasa {
  background: #e7f6ee;
  color: #2e6b4b;
  border-color: #b9e1cb;
}

.todo-global-nuova {
  background: #fff5cf;
  color: #7a5b0f;
  border-color: #efd080;
}

body.theme-dark .todo-global-pill {
  font-weight: 700;
  text-shadow: none;
  box-shadow: none;
}

body.theme-dark .todo-global-in-corso {
  background: #24354f;
  color: #d9e7ff;
  border-color: #4d6f9f;
}

body.theme-dark .todo-global-rilasciata {
  background: #3f3358;
  color: #f1eaff;
  border-color: #8f79c2;
}

body.theme-dark .todo-global-sospesa {
  background: #53333a;
  color: #ffdfe3;
  border-color: #b7747f;
}

body.theme-dark .todo-global-evasa {
  background: #2c473b;
  color: #dcf8ea;
  border-color: #6fa58a;
}

body.theme-dark .todo-global-nuova {
  background: #5b4b25;
  color: #fff0c9;
  border-color: #b89a4d;
}

.todo-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.todo-status-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.todo-client-meta {
  max-width: 100%;
  font-size: 10px;
  line-height: 1.2;
  color: #6b7280;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.todo-client-meta-ok {
  color: #1f5d3f;
}

.todo-client-meta-warn {
  color: #7a5a00;
}

.todo-client-meta-danger {
  color: #7f1d1d;
}

.todo-status:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  filter: saturate(1.08);
}

.todo-status.todo-da-schedulare {
  background: #fff6cc;
  color: #6b5600;
  border-color: #f0c84b;
}

.todo-status.todo-schedulata {
  background: #e6f1ff;
  color: #24508a;
  border-color: #bdd6ff;
}

.todo-status.todo-fatta {
  background: #e8f9ef;
  color: #246945;
  border-color: #a9dbbe;
}

.todo-status.todo-non-necessaria {
  background: #f6eaf6;
  color: #6b2c6f;
  border-color: #e3cfe6;
}

.todo-status-menu {
  position: fixed;
  z-index: 220;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#todoStatusMenu.todo-status-menu {
  min-width: 560px;
  max-width: 760px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 10px;
  gap: 8px;
}

#todoStatusMenu.todo-status-menu.matrix-side-by-side {
  position: static;
  z-index: auto;
  min-width: 100%;
  max-width: 100%;
  max-height: calc(85vh - 12px);
  overflow: visible;
  box-shadow: none;
  border-radius: 12px;
  border: none;
  background: transparent;
  padding: 0;
}

#todoStatusMenu .todo-status-context {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#todoStatusMenu .todo-status-context-meta {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--muted);
  font-weight: 700;
}

#todoStatusMenu .todo-status-context-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

#todoStatusMenu .todo-status-context-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#todoStatusMenu .todo-status-context-link:hover {
  text-decoration: underline;
}

#todoStatusMenu .todo-status-context-matrix {
  flex: 0 0 auto;
  margin-left: auto;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

#todoStatusMenu .todo-status-context-matrix.is-blocked {
  opacity: 0.5;
}

#todoStatusMenu .todo-status-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#todoStatusMenu .todo-status-section-nav {
  border: none;
  background: transparent;
  padding: 0;
}

#todoStatusMenu .todo-status-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--muted);
  font-weight: 700;
}

#todoStatusMenu .todo-status-section-note {
  font-size: 12px;
  color: var(--muted);
  background: #eef3fb;
  border: 1px dashed #c7d2e8;
  border-radius: 8px;
  padding: 7px 9px;
  line-height: 1.35;
}

#todoStatusMenu .todo-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#todoStatusMenu .todo-status-section-nav .todo-status-row {
  justify-content: flex-end;
}

#todoStatusMenu .todo-status-row button {
  flex: 1 1 calc(50% - 6px);
  min-height: 36px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#todoStatusMenu .todo-status-btn-icon {
  flex: 0 0 36px !important;
  min-width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

#todoStatusMenu .todo-status-date-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#todoStatusMenu .todo-status-date-dual,
#todoStatusMenu .todo-status-date-confirm {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

#todoStatusMenu .todo-status-date-dual {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 132px;
  column-gap: 18px;
  align-items: start;
}

#todoStatusMenu .todo-status-date-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--muted);
  font-weight: 700;
}

#todoStatusMenu .todo-status-date-subtitle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}

#todoStatusMenu .todo-status-date-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

#todoStatusMenu .todo-status-date-head button {
  flex: 0 0 32px;
  min-width: 32px;
  padding: 4px;
  text-align: center;
}

#todoStatusMenu .todo-status-date-label {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-transform: capitalize;
}

#todoStatusMenu .todo-status-date-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

#todoStatusMenu .todo-status-date-counter {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #eef2f9;
  padding: 10px 8px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

#todoStatusMenu .todo-status-counter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

#todoStatusMenu .todo-status-counter-value {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  text-align: center;
  line-height: 1.3;
}

#todoStatusMenu .todo-status-counter-value.is-warn {
  color: #8a6500;
}

#todoStatusMenu .todo-status-counter-value.is-soon {
  color: #c2410c;
}

#todoStatusMenu .todo-status-counter-value.is-future {
  color: #a16207;
}

#todoStatusMenu .todo-status-counter-value.is-danger {
  color: #9f1239;
}

@media (max-width: 900px) {
  #todoStatusMenu.todo-status-menu {
    min-width: min(94vw, 560px);
  }

  #todoStatusMenu .todo-status-date-dual {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1200px) {
  #activityModal .modal-card {
    width: min(1140px, 98vw);
    --activity-actions-right-offset: 0px;
  }

  #activityModal .activity-dual-sections {
    grid-template-columns: minmax(0, 1fr);
  }
}

#todoStatusMenu .todo-status-date-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}

#todoStatusMenu .todo-status-date-actions button {
  flex: 0 0 auto;
  min-width: 112px;
  text-align: center;
}

#todoStatusMenu .todo-status-date-actions button[data-action="todo_date_apply"] {
  background: #2f6f3d;
  color: #ffffff;
  border: 1px solid #245831;
}

#todoStatusMenu .todo-status-date-actions button[data-action="todo_date_apply"]:hover:not(:disabled) {
  background: #2a6236;
}

body.theme-dark #todoStatusMenu .todo-status-date-actions button[data-action="todo_date_apply"] {
  background: #2f6f3d;
  color: #ffffff;
  border-color: #245831;
}

.todo-status-menu button {
  border: none;
  background: #f3f6fb;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, transform 120ms ease;
}

.todo-status-menu button:hover:not(:disabled) {
  background: #e6ecf9;
  transform: translateY(-1px);
}

.todo-status-menu button.active {
  background: #e0e9ff;
  color: #2b4b7c;
}

.todo-status-menu button.is-planned {
  background: #e5f0ff;
  color: #2b4b7c;
  border: 1px solid #cddcff;
}

.todo-status-menu button.is-planned:hover:not(:disabled) {
  background: #dce9ff;
}

.todo-status-menu button.is-client-sent {
  background: #fff2e5;
  color: #9a3412;
  border: 1px solid #f6b98a;
}

.todo-status-menu button.is-client-sent:hover:not(:disabled) {
  background: #ffe8d4;
}

.todo-status-menu button.is-success {
  background: #e2f6e8;
  color: #1f5c3a;
  border: 1px solid #7cc59a;
}

.todo-status-menu button.is-success:hover:not(:disabled) {
  background: #d5f0df;
}

.todo-status-menu button.is-warning {
  background: #fff4cc;
  color: #8a6500;
  border: 1px solid #f3d36b;
}

.todo-status-menu button.is-warning:hover:not(:disabled) {
  background: #ffefba;
}

.todo-status-menu button.is-not-needed {
  background: #f6eaf6;
  color: #6b2c6f;
  border: 1px solid #e3cfe6;
}

.todo-status-menu button.is-not-needed:hover:not(:disabled) {
  background: #f1e1f3;
}

.todo-status-menu button:disabled {
  opacity: 0.5;
  cursor: pointer;
}

.todo-status-menu button.todo-order-confirm-glow {
  border: 1px solid #6bcf90;
  animation: todo-order-confirm-glow 1.35s ease-in-out infinite;
}

@keyframes todo-order-confirm-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.12);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.33);
  }
}

.todo-status-menu button.is-blocked {
  opacity: 0.52;
  cursor: pointer;
}

body.theme-dark .todo-section {
  background: #171b21;
}

body.theme-dark .todo-grid {
  background: #15191e;
}

body.theme-dark .todo-cell {
  background: #171b21;
  color: #e7eaef;
}

body.theme-dark .todo-head {
  background: #1b2028;
  color: #b1b7c1;
}

body.theme-dark .todo-commessa {
  background: #171b21;
}

body.theme-dark .todo-commessa-status {
  background: #171b21;
}

body.theme-dark .todo-machine-cell {
  background: #171b21;
}

body.theme-dark .todo-machine-value {
  color: #c6d1df;
}

body.theme-dark .todo-priority-cell {
  background: #171b21;
}

body.theme-dark .todo-priority-value {
  background: #252a33;
  border-color: #434b58;
  color: #e7ebf1;
}

body.theme-dark .todo-priority-value.is-empty {
  color: #a7afbb;
  background: #20252d;
  border-color: #3a404a;
}

body.theme-dark .todo-head-sticky {
  background: rgba(27, 32, 40, 0.92);
}

body.theme-dark .todo-group.todo-group-cad {
  background: rgba(40, 87, 62, 0.55);
  color: #d1fae5;
}

body.theme-dark .todo-group.todo-group-elettrico {
  background: rgba(92, 74, 17, 0.62);
  color: #fde68a;
}

body.theme-dark .todo-group.todo-group-termodinamico {
  background: rgba(34, 62, 99, 0.58);
  color: #bfdbfe;
}

body.theme-dark .todo-header {
  background: rgba(25, 28, 33, 0.78);
  border-bottom-color: rgba(56, 61, 70, 0.82);
}

body.theme-dark .todo-filter-sync-btn {
  border-color: #4e5f78;
  color: #c9dcf8;
  background: #242c38;
}

body.theme-dark .todo-filter-sync-btn:hover {
  border-color: #7290ba;
  background: #2c384a;
  color: #e8f2ff;
}

body.theme-dark .todo-filter-sync-btn.active {
  border-color: rgba(178, 159, 230, 0.7);
  background: rgba(178, 159, 230, 0.2);
  color: #efe9ff;
}

body.theme-dark .todo-filter-sync-tooltip {
  border-color: #5e7091;
  background: #273244;
  color: #e4edfb;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.4);
}

body.theme-dark .todo-filter-sync-btn.active::after {
  border-color: rgba(178, 159, 230, 0.6);
  background: #2a243f;
  color: #efe9ff;
}

body.theme-dark .report-special-filter-btn {
  color: #a9b7cc;
}

body.theme-dark .report-special-filter-btn:hover {
  color: #e7eefb;
  background: #2b3444;
}

body.theme-dark .report-special-filter-btn.active {
  color: #f4ecff;
  background: rgba(132, 110, 184, 0.42);
}

body.theme-dark .report-special-filter-btn.active::after {
  border-color: rgba(146, 129, 197, 0.78);
  background: #33295c;
  color: #efe9ff;
}

body.theme-dark .todo-header-table-host {
  background: #161a20;
  border-color: rgba(56, 61, 70, 0.82);
}

body.theme-dark .todo-status-menu {
  background: #171b21;
}

body.theme-dark #todoStatusMenu.todo-status-menu {
  background: #1a212c;
  border: 1px solid #2f3a4a;
}

body.theme-dark .todo-status-menu button {
  background: #252a33;
  color: #e7ebf1;
  border: 1px solid #434b58;
}

body.theme-dark .todo-status-menu button:hover:not(:disabled) {
  background: #303641;
  color: #f2f4f7;
}

body.theme-dark .todo-status-menu button.active {
  background: #3a414d;
  color: #f2f4f7;
  border-color: #616a79;
}

body.theme-dark #todoStatusMenu .todo-status-section {
  background: #1b1f25;
  border-color: #373d48;
}

body.theme-dark #todoStatusMenu .todo-status-context {
  background: #1b1f25;
  border-color: #373d48;
}

body.theme-dark #todoStatusMenu .todo-status-context-meta {
  color: #b2b9c4;
}

body.theme-dark #todoStatusMenu .todo-status-context-link {
  color: #e6eaef;
}

body.theme-dark #todoStatusMenu .todo-status-context-matrix {
  border-color: #888f9d;
  color: #c7ccd6;
}

body.theme-dark #todoStatusMenu .todo-status-section-title {
  color: #b2b9c4;
}

body.theme-dark #todoStatusMenu .todo-status-section-note {
  color: #c0c7d2;
  background: #171b21;
  border-color: #373d48;
}

body.theme-dark .todo-status-menu button.is-success {
  background: #1f3b2c;
  color: #9de3b8;
  border-color: #3f8b63;
}

body.theme-dark .todo-status-menu button.is-warning {
  background: #5b4316;
  color: #ffe6a6;
  border-color: #c79e2e;
}

body.theme-dark .todo-status-menu button.is-planned {
  background: #e5f0ff;
  color: #2b4b7c;
  border-color: #cddcff;
}

body.theme-dark .todo-status-menu button.is-planned:hover:not(:disabled) {
  background: #dce9ff;
  color: #244267;
}

body.theme-dark .todo-status-menu button.is-client-sent {
  background: #4a2c14;
  color: #fdba74;
  border-color: #b45309;
}

body.theme-dark .todo-status-menu button.is-not-needed {
  background: #3b1f3f;
  color: #e9d5ff;
  border-color: #7e4a87;
}

body.theme-dark #todoStatusMenu .todo-status-date-panel {
  background: #1b1f25;
  border-color: #373d48;
}

body.theme-dark #todoStatusMenu .todo-status-date-title {
  color: #b2b9c4;
}

body.theme-dark #todoStatusMenu .todo-status-date-subtitle {
  color: #b2b9c4;
}

body.theme-dark #todoStatusMenu .todo-status-date-label {
  color: #e6eaef;
}

body.theme-dark #todoStatusMenu .todo-status-date-counter {
  background: #171b21;
  border-color: #373d48;
}

body.theme-dark #todoStatusMenu .todo-status-counter-value {
  color: #e6eaef;
}

body.theme-dark #todoStatusMenu .todo-status-counter-value.is-warn {
  color: #facc15;
}

body.theme-dark #todoStatusMenu .todo-status-counter-value.is-soon {
  color: #fdba74;
}

body.theme-dark #todoStatusMenu .todo-status-counter-value.is-future {
  color: #fde68a;
}

body.theme-dark #todoStatusMenu .todo-status-counter-value.is-danger {
  color: #fca5a5;
}

body.theme-dark .todo-status.todo-da-schedulare {
  background: #4a3d16;
  color: #ffe9a3;
  border-color: #c9a84b;
}

body.theme-dark .todo-status.todo-schedulata {
  background: #e6f1ff;
  color: #24508a;
  border-color: #bdd6ff;
}

body.theme-dark .todo-status.todo-fatta {
  background: #e8f9ef;
  color: #246945;
  border-color: #a9dbbe;
}

body.theme-dark .todo-client-meta {
  color: #94a3b8;
}

body.theme-dark .todo-client-meta-ok {
  color: #86efac;
}

body.theme-dark .todo-client-meta-warn {
  color: #facc15;
}

body.theme-dark .todo-client-meta-danger {
  color: #fca5a5;
}

.todo-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(16, 22, 32, 0.24);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.todo-menu-open .todo-table .todo-cell {
  filter: blur(1.8px);
  opacity: 0.5;
  transition: filter 160ms ease, opacity 160ms ease;
}

body.todo-menu-open .todo-table .todo-cell.todo-cell-focus {
  position: relative;
  z-index: 210;
  filter: blur(1.8px);
  opacity: 0.5;
}

.report-cell {
  padding: 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  font-size: 12px;
}

.report-cell:last-child {
  border-right: none;
}

.report-header {
  background: #f4f7fb;
  font-weight: 600;
  color: var(--muted);
}

.report-commessa {
  background: #f9fbff;
}

.report-commessa .item-title {
  font-weight: 600;
}

.report-commessa .item-meta {
  font-size: 11px;
  color: var(--muted);
}

.report-empty {
  color: var(--muted);
  text-align: center;
}

.report-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3ff;
  border: 1px solid #d7dbe3;
  font-weight: 600;
  color: #2b3a55;
  font-size: 10px;
  white-space: nowrap;
}

.matrix-controls {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  box-shadow: none;
}

.matrix-control {
  justify-content: center;
}

.matrix-control > button,
.matrix-control > input,
.matrix-control > select,
.matrix-control > .matrix-attivita-picker,
.matrix-control > .mono,
.matrix-control > .matrix-extra {
  align-self: center;
}

.matrix-attivita-picker {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.matrix-attivita-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-attivita-field input {
  flex: 1;
}

.matrix-attivita-summary {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.matrix-control {
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.matrix-control > button,
.matrix-control > input,
.matrix-control > select,
.matrix-control > .matrix-attivita-picker,
.matrix-control > .mono,
.matrix-control > .matrix-extra {
  min-height: 30px;
}

.matrix-control-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: none;
}

.matrix-controls button.ghost {
  background: transparent;
  border: none !important;
  color: #1a1f2b;
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.matrix-controls button.ghost:hover {
  color: #1a1f2b;
  background: rgba(34, 74, 122, 0.12);
}

.matrix-controls button.ghost:active {
  background: transparent;
}

.matrix-controls .matrix-icon-btn {
  background: transparent;
  border: none !important;
  box-shadow: none !important;
  outline: none;
  padding: 4px 8px;
  font-size: 14px;
  color: #1a1f2b;
}

.matrix-controls .matrix-icon-btn:hover {
  background: rgba(34, 74, 122, 0.12);
  box-shadow: none;
  transform: none;
}

.matrix-controls #matrixDate {
  background: transparent;
  border: none !important;
  box-shadow: none !important;
  outline: none;
  padding: 4px 8px;
  font-size: 13px;
  color: #1a1f2b;
}

.matrix-controls .matrix-flat-btn {
  background: transparent;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 8px;
  color: #1a1f2b;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.matrix-controls .matrix-flat-btn:hover {
  background: transparent;
}

.matrix-controls .matrix-filter-clear-btn {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(132, 96, 206, 0.62) !important;
  background: rgba(184, 155, 255, 0.2) !important;
  color: #5b3fa2 !important;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
}

.matrix-controls .matrix-filter-clear-btn:hover {
  background: rgba(184, 155, 255, 0.34) !important;
  border-color: rgba(132, 96, 206, 0.85) !important;
}

.matrix-controls #matrixCommessaPickerToggleBtn.is-disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.matrix-quick-commessa-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 2px 8px;
  border-radius: 9px;
  border: 1px solid rgba(146, 163, 189, 0.58);
  background: rgba(255, 255, 255, 0.75);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.matrix-quick-commessa-wrap:focus-within {
  border-color: rgba(89, 123, 176, 0.78);
  box-shadow: 0 0 0 2px rgba(120, 147, 193, 0.2);
}

.matrix-quick-commessa-wrap.is-active {
  border-color: rgba(106, 143, 201, 0.82);
  background: rgba(243, 248, 255, 0.9);
}

.matrix-quick-commessa-wrap.is-no-match {
  border-color: rgba(220, 147, 63, 0.82);
}

.matrix-quick-commessa-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4b6387;
  opacity: 0.86;
}

.matrix-quick-commessa-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matrix-quick-commessa-fit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 2px;
  margin-left: 2px;
  color: #4b6387;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.matrix-quick-commessa-fit svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-dasharray: 3 2;
  stroke-linecap: round;
}

.matrix-quick-commessa-fit:hover {
  background: rgba(106, 134, 178, 0.16);
}

.matrix-quick-commessa-fit:focus-visible {
  outline: 2px solid rgba(89, 123, 176, 0.5);
  outline-offset: 2px;
}

.matrix-quick-commessa-fit[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

#matrixQuickCommessaFilter {
  width: 102px;
  min-width: 102px;
  border: none !important;
  outline: none;
  background: transparent;
  box-shadow: none !important;
  font-size: 12px;
  color: #1a1f2b;
  padding: 0;
}

#matrixQuickCommessaFilter::placeholder {
  color: #73819a;
}

.matrix-switch {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #2b3a55;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.matrix-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.matrix-switch-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #d7dbe3;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.matrix-switch-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.matrix-switch input:checked + .matrix-switch-slider {
  background: #007aff;
}

.matrix-switch input:checked + .matrix-switch-slider::after {
  transform: translateX(20px);
}

.matrix-controls .matrix-flat-btn:hover {
  background: rgba(34, 74, 122, 0.12);
}

.matrix-controls #matrixCommessaPickerToggleBtn.active,
.matrix-controls #matrixAttivitaToggleBtn.active {
  background: rgba(184, 155, 255, 0.28) !important;
  color: #5b3fa2 !important;
  border: 1px solid rgba(146, 108, 224, 0.78) !important;
  border-radius: 10px;
  padding: 4px 10px;
}

.matrix-controls #matrixCommessaPickerToggleBtn.active:hover,
.matrix-controls #matrixAttivitaToggleBtn.active:hover {
  background: rgba(184, 155, 255, 0.36) !important;
}

body.theme-dark .matrix-controls button.ghost,
body.theme-dark .matrix-controls .matrix-icon-btn,
body.theme-dark .matrix-controls .matrix-flat-btn,
body.theme-dark .matrix-controls #matrixDate,
body.theme-dark .matrix-attivita-summary,
body.theme-dark .matrix-switch {
  color: #e6edf5;
}

body.theme-dark .matrix-controls button.ghost:hover,
body.theme-dark .matrix-controls .matrix-icon-btn:hover,
body.theme-dark .matrix-controls .matrix-flat-btn:hover {
  color: #e6edf5;
  background: rgba(255, 255, 255, 0.1);
}

body.theme-dark .matrix-controls #matrixCommessaPickerToggleBtn.active,
body.theme-dark .matrix-controls #matrixAttivitaToggleBtn.active {
  background: rgba(156, 120, 233, 0.36) !important;
  color: #efe7ff !important;
  border-color: rgba(202, 177, 255, 0.72) !important;
}

body.theme-dark .matrix-controls .matrix-filter-clear-btn {
  border-color: rgba(193, 166, 255, 0.78) !important;
  background: rgba(156, 120, 233, 0.34) !important;
  color: #f2e9ff !important;
}

body.theme-dark .matrix-controls .matrix-filter-clear-btn:hover {
  background: rgba(176, 142, 245, 0.44) !important;
  border-color: rgba(224, 205, 255, 0.86) !important;
}

body.theme-dark .matrix-controls #matrixCommessaPickerToggleBtn.is-disabled {
  opacity: 0.42;
}

body.theme-dark .matrix-quick-commessa-wrap {
  border-color: rgba(116, 130, 154, 0.65);
  background: rgba(25, 31, 39, 0.9);
}

body.theme-dark .matrix-quick-commessa-wrap:focus-within {
  border-color: rgba(147, 171, 214, 0.86);
  box-shadow: 0 0 0 2px rgba(114, 144, 195, 0.25);
}

body.theme-dark .matrix-quick-commessa-wrap.is-active {
  border-color: rgba(156, 182, 226, 0.86);
  background: rgba(31, 39, 50, 0.95);
}

body.theme-dark .matrix-quick-commessa-wrap.is-no-match {
  border-color: rgba(234, 161, 72, 0.86);
}

body.theme-dark .matrix-quick-commessa-icon {
  color: #c6d3e8;
}

body.theme-dark .matrix-quick-commessa-fit {
  color: #c6d3e8;
}

body.theme-dark .matrix-quick-commessa-fit:hover {
  background: rgba(136, 160, 198, 0.2);
}

body.theme-dark .matrix-quick-commessa-fit:focus-visible {
  outline-color: rgba(147, 171, 214, 0.6);
}

body.theme-dark #matrixQuickCommessaFilter {
  color: #e8eef8;
}

body.theme-dark #matrixQuickCommessaFilter::placeholder {
  color: #9eacc2;
}

body.theme-dark .matrix-controls #matrixDate {
  border-color: transparent;
}

body.theme-dark .matrix-controls {
  background: rgba(25, 28, 33, 0.72);
}

.report-controls .ghost,
.report-controls button {
  border: none !important;
  box-shadow: none !important;
  border-radius: 8px;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
}

.report-controls .ghost:hover,
.report-controls button:hover {
  background: rgba(34, 74, 122, 0.12);
}

.report-controls input,
.report-controls select {
  min-height: 30px;
  border-radius: 8px;
  font-size: 12px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.report-actions .mono {
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
}

body.theme-dark .report-panel .panel-header {
  background: rgba(25, 28, 33, 0.82);
  border-bottom-color: rgba(56, 61, 70, 0.85);
}

body.theme-dark .matrix-panel .panel-header {
  background: rgba(25, 28, 33, 0.82);
  border-bottom-color: rgba(56, 61, 70, 0.85);
}

body.theme-dark .todo-panel .panel-header {
  background: rgba(25, 28, 33, 0.82);
  border-bottom-color: rgba(56, 61, 70, 0.85);
}

body.theme-dark .report-controls {
  background: rgba(25, 28, 33, 0.72);
}

body.theme-dark .report-controls .ghost:hover,
body.theme-dark .report-controls button:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.theme-dark .matrix-attivita-list {
  background: #1b1f25;
  border-color: #373d48;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.42);
}

body.theme-dark .matrix-switch-slider {
  background: #2a3b52;
}

body.theme-dark .matrix-switch input:checked + .matrix-switch-slider {
  background: #79a6ff;
}

.matrix-attivita-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  max-height: 220px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 20px rgba(16, 28, 43, 0.12);
  z-index: 50;
}

.matrix-attivita-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink);
}

.matrix-extra {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-extra-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.matrix-grid {
  border: none;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  grid-column: 2;
}

.matrix-header-row {
  cursor: grab;
}

.matrix-grid.is-panning .matrix-header-row {
  cursor: grabbing;
}

.matrix-grid.is-panning {
  transition: none;
  user-select: none;
}

.matrix-grid.is-panning .matrix-cell:not(.matrix-resource),
.matrix-grid.is-panning .matrix-activity-bar {
  will-change: transform;
}

.matrix-grid.is-pan-snapping .matrix-cell:not(.matrix-resource),
.matrix-grid.is-pan-snapping .matrix-activity-bar {
  will-change: transform;
}

.matrix-grid.is-zooming-preview .matrix-cell:not(.matrix-resource),
.matrix-grid.is-zooming-preview .matrix-activity-bar {
  opacity: 0.96;
}

.matrix-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
}

.matrix-commesse {
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  position: sticky;
  top: calc(
    var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px) + var(--matrix-panel-header-height, 86px)
  );
  align-self: start;
}

.matrix-commesse.collapsed {
  display: none;
}

.matrix-commesse-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: #f4f7fb;
  font-size: 12px;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 4;
}

.matrix-commesse-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.matrix-commesse-header-main > span {
  display: none;
}

.matrix-commesse-header input {
  width: 120px;
}

.matrix-commesse-header-filters {
  display: flex;
  justify-content: flex-end;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f4f7fb;
}

#matrixCommessaYear {
  width: 78px;
  min-width: 78px;
  height: 24px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.1;
  border-radius: 8px;
}

.matrix-commesse-list {
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
}

.matrix-commesse-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  background: #f7f9fc;
}

.resources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resource-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 140px 180px auto auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.resource-order-btn {
  min-width: 34px;
  padding: 6px 8px;
}

.resource-row input,
.resource-row select {
  font-size: 13px;
}

.resource-active {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.resources-form {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 140px auto auto;
  gap: 8px;
  align-items: center;
}

body.theme-dark #resourcesModal .modal-card {
  background: linear-gradient(180deg, #1b2129 0%, #171c24 100%);
  border-color: #3a4453;
}

body.theme-dark #resourcesModal .resource-row {
  background: #222b36;
  border-color: #435063;
  color: #eef3f8;
}

body.theme-dark #resourcesModal .resource-row input,
body.theme-dark #resourcesModal .resource-row select,
body.theme-dark #resourcesModal .resources-form input,
body.theme-dark #resourcesModal .resources-form select {
  background: #131a23;
  color: #eef3f8;
  border-color: #435063;
}

body.theme-dark #resourcesModal .resource-active,
body.theme-dark #resourcesModal .resources-users-hint,
body.theme-dark #resourcesModal .user-name {
  color: #c3ccda;
}

body.theme-dark #resourcesModal .user-row {
  padding: 6px 8px;
  border: 1px solid #435063;
  border-radius: 10px;
  background: #1d2530;
}

body.theme-dark #resourcesModal .resources-users {
  border-top-color: #3a4453;
}

body.theme-dark #resourcesModal .resources-users-header h4 {
  color: #f1f4f8;
}

.progress-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 14px;
  min-height: 56vh;
}

.progress-side {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #f8fafc;
}

.progress-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-year-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-year-pill {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.progress-year-pill.active {
  border-color: #2f6f3d;
  background: #e9f5ee;
}

.progress-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(56vh - 18px);
  overflow: auto;
  padding-right: 4px;
}

.progress-result {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 8px;
  background: #ffffff;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-result.active {
  border-color: #2f6f3d;
  background: #e9f5ee;
}

.progress-result-title {
  font-weight: 600;
  color: var(--ink);
}

.progress-result-date {
  font-size: 11px;
  color: var(--muted);
}

.progress-list {
  display: grid;
  grid-auto-rows: 50px;
  row-gap: 8px;
  column-gap: 10px;
  padding: 10px 4px 14px;
  position: relative;
  min-width: 100%;
  width: max-content;
}

.progress-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.progress-timeline-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 42vh;
  overflow-y: auto;
  overflow-x: auto;
  padding: 2px 2px 6px 0;
}

.progress-timeline-days {
  display: grid;
  gap: 12px;
  padding: 0 4px 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
  border-bottom: 2px solid #e2e8f0;
  min-width: 100%;
  width: max-content;
}

.progress-timeline-day {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-item {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  background: #ffffff;
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 8px;
  align-items: center;
}

.progress-group-title {
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #335a8d;
  border-bottom: 1px solid #d7e6fb;
}

.progress-color {
  width: 8px;
  height: 100%;
  border-radius: 8px;
  background: var(--progress-color, #9fb3d1);
}

/* duplicate rules removed: progress-list/progress-item handled above */

.progress-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-dark .progress-side {
  background: #162031;
}

body.theme-dark .progress-year-pill {
  background: #1b2430;
  border-color: #2f3948;
  color: #d6dde8;
}

body.theme-dark .progress-year-pill.active {
  border-color: #4a8c67;
  background: #203529;
  color: #dff4e7;
}

body.theme-dark .progress-results {
  color: #d6dde8;
}

body.theme-dark .progress-result {
  background: #1a222c;
  border-color: #2f3948;
}

body.theme-dark .progress-result.active {
  border-color: #4a8c67;
  background: #203529;
}

body.theme-dark .progress-result-title {
  color: #eef2f6;
}

body.theme-dark .progress-result-date {
  color: #a8b3c4;
}

body.theme-dark .progress-timeline-days {
  color: #a8b3c4;
  border-bottom-color: #2f3948;
}

body.theme-dark .progress-item {
  background: #1a222c;
  border-color: #2f3948;
}

body.theme-dark .progress-group-title {
  color: #9fc4ff;
  border-bottom-color: #2b3d57;
}

body.theme-dark .progress-title {
  color: #eef2f6;
}

body.theme-dark .progress-meta {
  color: #9aa6ba;
}

@media (max-width: 980px) {
  .progress-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .progress-side {
    padding: 6px;
  }

  .progress-results {
    max-height: 180px;
  }

  .progress-timeline-scroll {
    min-height: 36vh;
  }
}

.matrix-assenza-item {
  border: 1px dashed #8fa2c4;
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  color: #2b3a55;
  background: #ffffff;
  cursor: grab;
}

.matrix-altro-item {
  border-style: solid;
  background: #f5f1ff;
}

.lavender-item {
  border-style: solid;
  border-color: #cbb6f0;
  background: #f3edff;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(124, 92, 170, 0.18) 0,
    rgba(124, 92, 170, 0.18) 2px,
    rgba(255, 255, 255, 0) 2px,
    rgba(255, 255, 255, 0) 6px
  );
  color: #4c2f72;
  text-transform: lowercase;
}

.lavender-item::first-letter {
  text-transform: uppercase;
}

.matrix-commesse-footer .matrix-assenza-item + .matrix-assenza-item {
  margin-top: 8px;
}

.matrix-assenza-item:active {
  cursor: grabbing;
}

.matrix-commessa-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #ffffff;
  font-size: 12px;
  cursor: grab;
}

.matrix-commessa-item:active {
  cursor: grabbing;
}

.matrix-row {
  display: grid;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.matrix-header-row {
  position: sticky;
  top: calc(
    var(--matrix-panel-header-height, 64px) + var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px) - 1px
  );
  z-index: 25;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: none;
}

.matrix-header-row .matrix-cell {
  min-height: 44px;
  padding: 4px 6px;
}

.matrix-header-row::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(-1 * var(--matrix-panel-header-height, 64px));
  height: var(--matrix-panel-header-height, 64px);
  background: var(--card);
  pointer-events: none;
}

.matrix-row:last-child {
  border-bottom: none;
}

.matrix-row.matrix-row-uninvolved {
  min-height: 24px !important;
  max-height: 24px;
  opacity: 0.42;
}

.matrix-row.matrix-row-uninvolved .matrix-bar-layer {
  display: none;
}

.matrix-row.matrix-row-uninvolved .matrix-cell {
  min-height: 24px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.matrix-row.matrix-row-uninvolved .matrix-cell:not(.matrix-resource) {
  padding: 0;
  border-right-color: transparent;
  background: transparent;
}

.matrix-row.matrix-row-uninvolved .matrix-resource {
  justify-content: center;
}

.matrix-row.matrix-row-uninvolved .matrix-resource .resource-name {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-row.matrix-row-uninvolved .matrix-resource .resource-dept {
  display: none;
}

.matrix-section-row {
  background: transparent;
}

.matrix-section-row.matrix-section-row-uninvolved {
  display: none;
}

.matrix-section-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #1b3a57;
  background: #e6f0ff;
  border-bottom: 1px solid #c9dbf5;
  cursor: pointer;
}

.matrix-section-toggle {
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.matrix-section-title {
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.matrix-cell {
  padding: 8px;
  min-height: 70px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #ffffff;
  z-index: 1;
  grid-row: 1;
  position: relative;
}

.matrix-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease-out;
  background: linear-gradient(
    to left,
    rgba(112, 148, 214, 0.68) 0px,
    rgba(124, 158, 220, 0.42) 10px,
    rgba(136, 168, 226, 0.2) 20px,
    rgba(136, 168, 226, 0) 30px
  );
}

.matrix-cell.week-sep {
  border-right: 3px solid #b8c1d1;
}

.matrix-bar-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-auto-rows: 0;
  pointer-events: none;
}

.matrix-cell.today-col {
  background: #e5f7eb;
}

.matrix-cell.matrix-cell-smartworking {
  background: #e8f4ff;
}

.matrix-cell.matrix-cell-smartworking.today-col {
  background: #d9effd;
}

.matrix-smartworking-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2f6fbd;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(130, 168, 214, 0.9);
  pointer-events: none;
  z-index: 2;
}

.matrix-smartworking-indicator svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matrix-cell.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
  background: #f4f8ff;
}

.matrix-cell.resize-target-col::after {
  opacity: 1;
}

.matrix-cell.overbooked-hours {
  background: #ffe2e2;
}

body.theme-dark .matrix-cell.overbooked-hours {
  background: rgba(196, 48, 48, 0.3);
}

body.theme-dark .matrix-cell.matrix-cell-smartworking {
  background: rgba(40, 81, 128, 0.5);
}

body.theme-dark .matrix-cell.matrix-cell-smartworking.today-col {
  background: rgba(48, 96, 143, 0.55);
}

body.theme-dark .matrix-smartworking-indicator {
  color: #8cc2ff;
  background: rgba(17, 27, 40, 0.85);
  border-color: rgba(99, 143, 193, 0.8);
}

body.theme-dark .matrix-cell::after {
  background: linear-gradient(
    to left,
    rgba(146, 178, 232, 0.62) 0px,
    rgba(132, 166, 226, 0.38) 10px,
    rgba(118, 152, 214, 0.18) 20px,
    rgba(118, 152, 214, 0) 30px
  );
}

.matrix-cell:last-child {
  border-right: none;
}


.matrix-header {
  background: #f4f7fb;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 6px;
}

.matrix-header-day {
  display: block;
  line-height: 1.15;
}

.matrix-header-week {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #2f6f3d;
}

.matrix-header-week-placeholder {
  visibility: hidden;
}

body.theme-dark .matrix-header-week {
  color: #9fd9ad;
}

.matrix-resource {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: #f9fbff;
}

.matrix-resource .resource-name {
  font-weight: 600;
  font-size: 13px;
}

.matrix-resource .resource-dept {
  font-size: 11px;
  color: var(--muted);
}

.matrix-activity-bar {
  border: 1px solid var(--border);
  background: #eef3ff;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.2;
  height: 44px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
  grid-row: 1;
}

.matrix-activity-bar.dragging {
  opacity: 0;
}

.matrix-drag-follower {
  position: fixed;
  margin: 0;
  z-index: 2600;
  pointer-events: none;
  opacity: 0.92;
  transition: none;
  will-change: left, top;
}

.matrix-drag-follower .matrix-resize-handle {
  display: none;
}

.matrix-dragging .matrix-activity-bar:not(.dragging) {
  pointer-events: none;
}

.matrix-activity-bar.commessa-highlight {
  box-shadow: 0 0 0 2px #2f6f3d;
  border-color: #2f6f3d;
}

.matrix-activity-bar.matrix-jump-glow {
  box-shadow:
    0 0 0 2px rgba(124, 92, 170, 0.7),
    0 0 26px rgba(124, 92, 170, 0.55);
  border-color: rgba(124, 92, 170, 0.85);
  animation: matrixJumpPulse 2.6s ease-out 1;
}

@keyframes matrixJumpPulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(124, 92, 170, 0.9),
      0 0 0 rgba(124, 92, 170, 0.7);
  }
  70% {
    box-shadow:
      0 0 0 3px rgba(124, 92, 170, 0.7),
      0 0 28px rgba(124, 92, 170, 0.6);
  }
  100% {
    box-shadow:
      0 0 0 2px rgba(124, 92, 170, 0.6),
      0 0 20px rgba(124, 92, 170, 0.45);
  }
}

.matrix-activity-bar.commessa-dim {
  opacity: 0.25;
}

.matrix-activity-bar.resizing-preview {
  opacity: 0.4;
  border-style: dashed;
  transition: none;
  will-change: left, width;
}

.matrix-activity-bar .commessa-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.matrix-activity-bar .commessa-num {
  font-weight: 600;
  font-size: 12px;
}

.matrix-activity-bar .commessa-year {
  color: var(--muted);
  font-size: 10px;
}

.matrix-activity-bar .activity-title {
  color: var(--ink);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-resize-handle {
  position: absolute;
  top: 20%;
  right: 2px;
  width: 6px;
  height: 60%;
  border-radius: 6px;
  background: rgba(34, 74, 122, 0.35);
  cursor: ew-resize;
}

.matrix-activity-bar.resizing .matrix-resize-handle {
  background: rgba(34, 74, 122, 0.7);
}
.matrix-activity-bar.colorized {
  background: var(--matrix-activity-bg, #eef3ff);
  border-color: var(--matrix-activity-border, var(--border));
}

.matrix-activity-bar.activity-preliminare {
  border-style: dashed;
}

.matrix-activity-bar.activity-3d {
  border-width: 2px;
}

.matrix-activity-bar.activity-assente {
  background-color: #e5e7eb;
  border-color: #9aa3ad;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(90, 97, 105, 0.16) 0,
    rgba(90, 97, 105, 0.16) 2px,
    rgba(255, 255, 255, 0) 2px,
    rgba(255, 255, 255, 0) 6px
  );
}

.matrix-activity-bar.activity-lavender {
  background: #f3edff;
  border-color: #cbb6f0;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(124, 92, 170, 0.18) 0,
    rgba(124, 92, 170, 0.18) 2px,
    rgba(255, 255, 255, 0) 2px,
    rgba(255, 255, 255, 0) 6px
  );
}

.matrix-activity-bar.activity-lavender .activity-title,
.matrix-activity-bar.activity-lavender .commessa-num,
.matrix-activity-bar.activity-lavender .commessa-year {
  color: #4c2f72;
}

.matrix-trash {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #b23b3b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.matrix-trash svg {
  width: 28px;
  height: 28px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matrix-trash.is-dragover {
  border-color: #b23b3b;
}

.matrix-activity-bar.is-done {
  background: #2fbf71;
  border-color: #1f8f53;
  color: #ffffff;
}

.matrix-activity-bar.is-done .commessa-year,
.matrix-activity-bar.is-done .activity-title,
.matrix-activity-bar.is-done .commessa-num {
  color: #ffffff;
}

.matrix-activity-bar.is-done::after {
  content: "\2713";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #86efac;
}

.matrix-activity-bar.is-done.is-telaio-ordered::after {
  content: "\2713\2713";
  letter-spacing: -1px;
  color: #86efac;
}

.matrix-activity-bar.is-done.is-client-sent::after,
.matrix-activity-bar.is-done.is-client-final::after {
  right: 18px;
}

.matrix-activity-bar.is-done.is-client-sent::before,
.matrix-activity-bar.is-done.is-client-final::before {
  content: "\2713";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 12px;
  font-weight: 700;
}

.matrix-activity-bar.is-done.is-client-sent::before {
  color: #fb923c;
}

.matrix-activity-bar.is-done.is-client-final::before {
  color: #86efac;
}

.matrix-activity-bar.is-done.is-past-task {
  background: #d8dee8;
  border-color: transparent;
  color: #3d4c63;
}

.matrix-activity-bar.is-done.is-past-task .commessa-year,
.matrix-activity-bar.is-done.is-past-task .activity-title,
.matrix-activity-bar.is-done.is-past-task .commessa-num {
  color: #3d4c63;
}

.matrix-quick-menu {
  position: fixed;
  z-index: 140;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
}

.matrix-quick-info {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-line;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.matrix-quick-menu button {
  border: 1px solid #2f6f3d;
  background: #e9f5ee;
  color: #1f4f2b;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.commessa-focus-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 26, 0.12);
  backdrop-filter: blur(3px);
  z-index: 120;
}

.commessa-quick-menu {
  position: fixed;
  z-index: 140;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 24px rgba(10, 20, 35, 0.2);
}

.commessa-quick-menu button {
  border: 1px solid #244a7a;
  background: #eef3fb;
  color: #1e3e68;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.commessa-item-focused {
  position: relative;
  z-index: 130;
  box-shadow: 0 10px 20px rgba(20, 30, 45, 0.18);
}

.sheet-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 40px;
  min-height: calc(100vh - 120px);
}

.sheet-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(16, 28, 43, 0.08);
}

.sheet-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

@media (max-width: 980px) {
  .sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .sheet-grid {
    grid-template-columns: 1fr;
  }
}

.quick-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost.active {
  background: var(--primary);
  color: var(--primary-contrast);
}

.matrix-activity.dragging {
  opacity: 0.6;
}

.matrix-activity strong {
  display: block;
  font-size: 11px;
}

.matrix-activity span {
  color: var(--muted);
  font-size: 10px;
}

.matrix-empty {
  font-size: 11px;
  color: var(--muted);
}

.check-item {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 10px;
  background: #ffffff;
}

.filter-pill {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.filter-pill:hover {
  border-color: #9fb3d1;
  box-shadow: 0 6px 12px rgba(20, 35, 60, 0.08);
  transform: translateY(-1px);
}

.filter-pill.active {
  border-color: #1f5c35;
  border-width: 0.5px;
  background: #e8f7ee;
  color: #1f5c35;
  box-shadow: none;
}

.filter-pill.lavender-pill {
  border-color: #cbb6f0;
  background: #f3edff;
  color: #4c2f72;
  text-transform: capitalize;
}

.filter-pill.lavender-pill:hover {
  border-color: #b69be8;
}

.filter-pill.lavender-pill.active {
  border-color: #8c6bd6;
  background: #eadfff;
  color: #4c2f72;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .list {
    max-height: none;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .reparto-row {
    grid-template-columns: 1fr;
  }
  .filters {
    flex-direction: column;
  }
  .calendar-grid {
    grid-template-columns: 1fr;
  }
  .matrix-row {
    grid-template-columns: 1fr;
  }
  .matrix-wrap {
    grid-template-columns: 1fr;
  }
  .matrix-grid {
    grid-column: 1 / -1;
  }
}
.matrix-panel .panel-header {
  position: sticky;
  top: calc(var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
  z-index: 20;
  background: rgba(255, 255, 255, 0.62);
  padding-top: 2px;
  padding-bottom: 4px;
  box-shadow: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 0;
  margin: -16px -16px 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid rgba(215, 219, 227, 0.7);
}

.todo-panel .panel-header {
  position: sticky;
  top: calc(var(--section-toolbar-h, 56px) + var(--section-toolbar-gap, 4px));
  z-index: 17;
  background: rgba(255, 255, 255, 0.62);
  padding-top: 2px;
  padding-bottom: 4px;
  box-shadow: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 0;
  margin: -16px -16px 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid rgba(215, 219, 227, 0.7);
}

.matrix-panel .panel-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -24px;
  height: 24px;
  background: var(--card);
  pointer-events: none;
}
