*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #3b82f6;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

input, select, textarea, button {
  font: inherit;
}

ul {
  list-style: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 3px;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}
.sidebar__logo-icon {
  font-size: 22px;
}
.sidebar__logo-text {
  letter-spacing: 0.3px;
}
.sidebar__logo-img {
  max-width: 140px;
  max-height: 40px;
  width: 100%;
  object-fit: contain;
  object-position: left center;
}
.sidebar__logo-version {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.3px;
  margin-top: auto;
}
.sidebar__nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease;
  text-decoration: none;
}
.sidebar__link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}
.sidebar__link.is-active {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.sidebar__footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar__user {
  flex: 1;
  color: #94a3b8;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__logout {
  color: #94a3b8;
  display: flex;
  align-items: center;
  transition: color 0.18s ease;
}
.sidebar__logout svg {
  width: 17px;
  height: 17px;
}
.sidebar__logout:hover {
  color: #ef4444;
  text-decoration: none;
}

.main {
  flex: 1;
  margin-left: 220px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__title {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
}
.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 24px;
  flex: 1;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
}

.login-page {
  background: #0f172a;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.login-card__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}
.login-card__logo-img {
  max-width: 160px;
  max-height: 60px;
  width: 100%;
  object-fit: contain;
}
.login-card__logo-sub {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}
.login-card__logo-sub span {
  font-size: 11px;
  opacity: 0.6;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--primary {
  background: #3b82f6;
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: #2563eb;
  text-decoration: none;
  color: #fff;
}
.btn--danger {
  background: #ef4444;
  color: #fff;
}
.btn--danger:hover:not(:disabled) {
  background: rgb(235.7842364532, 30.4157635468, 30.4157635468);
  text-decoration: none;
  color: #fff;
}
.btn--outline {
  border-color: #e2e8f0;
  background: transparent;
  color: #1e293b;
}
.btn--outline:hover:not(:disabled) {
  background: #f1f5f9;
  text-decoration: none;
}
.btn--ghost {
  background: transparent;
  color: #64748b;
}
.btn--ghost:hover:not(:disabled) {
  background: #f1f5f9;
  text-decoration: none;
}
.btn--sm {
  padding: 5px 11px;
  font-size: 12.5px;
}
.btn--full {
  width: 100%;
  justify-content: center;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge--success {
  background: rgba(34, 197, 94, 0.12);
  color: rgb(18.987012987, 110.012987013, 52.4935064935);
}
.badge--info {
  background: rgba(6, 182, 212, 0.12);
  color: rgb(4.5963302752, 139.4220183486, 162.4036697248);
}
.badge--warning {
  background: rgba(245, 158, 11, 0.12);
  color: rgb(123.4409448819, 79.4271653543, 5.0590551181);
}
.badge--muted {
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
}
.badge--primary {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}
.badge--danger {
  background: rgba(239, 68, 68, 0.12);
  color: rgb(234.9802955665, 21.0197044335, 21.0197044335);
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
}
.card__title {
  font-size: 15px;
  font-weight: 700;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=date],
.form-group input[type=search],
.form-group input[type=password],
.form-group select,
.form-group textarea {
  padding: 8px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  width: 100%;
}
.form-group input[type=text]:focus,
.form-group input[type=email]:focus,
.form-group input[type=date]:focus,
.form-group input[type=search]:focus,
.form-group input[type=password]:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.form-group input[type=text]::placeholder,
.form-group input[type=email]::placeholder,
.form-group input[type=date]::placeholder,
.form-group input[type=search]::placeholder,
.form-group input[type=password]::placeholder,
.form-group select::placeholder,
.form-group textarea::placeholder {
  color: #64748b;
}
.form-group textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  margin-top: 8px;
  padding: 9px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 4px;
  color: rgb(234.9802955665, 21.0197044335, 21.0197044335);
  font-size: 13px;
}

.input-password {
  position: relative;
}
.input-password input {
  padding-right: 40px;
}
.input-password .btn-toggle-pw {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 4px;
  display: flex;
  align-items: center;
}
.input-password .btn-toggle-pw:hover {
  color: #1e293b;
}

.alert {
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert--danger {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: rgb(234.9802955665, 21.0197044335, 21.0197044335);
}
.alert--success {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: rgb(18.987012987, 110.012987013, 52.4935064935);
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  min-height: 40px;
  background: #fff;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.check-item input[type=checkbox] {
  cursor: pointer;
}
.check-item:has(input:checked) {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #2563eb;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}
.table th {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: #f1f5f9;
  white-space: nowrap;
}
.table tbody tr {
  transition: background 0.18s ease;
}
.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.03);
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table .th-actions {
  text-align: right;
  width: 1px;
}
.table td:last-child {
  text-align: right;
  white-space: nowrap;
}
.table__loading, .table__empty, .table__error {
  text-align: center !important;
  padding: 32px !important;
  color: #64748b;
  font-style: italic;
}
.table__error {
  color: #ef4444;
}

.actions-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal.is-open {
  display: flex;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal__box {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  width: 94%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 0;
  animation: modal-in 0.18s ease;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}
.modal__box::-webkit-scrollbar {
  width: 6px;
}
.modal__box::-webkit-scrollbar-track {
  background: transparent;
}
.modal__box::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 3px;
}
.modal--sm .modal__box {
  max-width: 420px;
}
.modal--wide .modal__box {
  max-width: 860px;
  width: min(860px, 96vw);
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 18px;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
  border-radius: 12px 12px 0 0;
}
.modal__title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}
.modal__close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal__close:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.modal form {
  padding: 24px 28px 28px;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.form-commessa {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.form-commessa .form-group--full,
.form-commessa .modal__actions,
.form-commessa .form-error,
.form-commessa .form-section {
  grid-column: 1/-1;
}

.form-section {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #64748b;
  margin-top: 4px;
}
.form-section::before, .form-section::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}
.form-section::before {
  flex: 0 0 0;
}

.allegati-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.allegati-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 10px;
  background: #f1f5f9;
  border-radius: 4px;
}
.allegati-list li a {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.allegati-list li button {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
.allegati-list li button:hover {
  opacity: 0.7;
}

.allegati-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.allegati-upload input[type=file] {
  font-size: 13px;
}

.text-muted {
  color: #64748b;
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #94a3b8;
}
.stat-card--success::before {
  background: #22c55e;
}
.stat-card--info::before {
  background: #06b6d4;
}
.stat-card--warning::before {
  background: #f59e0b;
}
.stat-card--muted::before {
  background: #94a3b8;
}
.stat-card__label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 6px;
}
.stat-card__value {
  font-size: 28px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}
.filter-form__input {
  padding: 7px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #1e293b;
  font-size: 13.5px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  min-width: 170px;
}
.filter-form__input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.filter-form__input::placeholder {
  color: #64748b;
}
.filter-form__select {
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #1e293b;
  font-size: 13.5px;
  cursor: pointer;
}
.filter-form__select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.table-wrap {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

#commesse-table td:nth-child(1) {
  white-space: nowrap;
}
#commesse-table td:nth-child(4) {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#commesse-table .commessa-row {
  cursor: pointer;
}

.gantt-wrap {
  margin-top: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}
.gantt-wrap__header h2 {
  font-size: 14px;
  margin: 0 0 10px;
}

.gantt-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gantt-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}
.gantt-row__label {
  font-size: 12.5px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-row__track {
  position: relative;
  height: 26px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  overflow: hidden;
}
.gantt-row__bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.82);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tabs__btn {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
}
.tabs__btn.is-active {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: #2563eb;
}

.tab-panel {
  display: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.tab-panel.is-active {
  display: block;
}

.notes-list,
.links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.note-item,
.link-item {
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 10px;
  background: #fff;
}
.note-item header,
.link-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 6px;
}