body {
  margin: 0;
  font-family: 'Inter', Arial, sans-serif;
  font-size: 16px;
  background: #f6f8fa;
  color: #222;
}

.sidebar {
  width: 72px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  height: 100vh;
  position: fixed;
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width 0.2s;
}
.sidebar:hover,
.sidebar.expanded {
  width: 220px;
}
.sidebar-logo {
  text-align: center;
  font-size: 2rem;
  margin: 1rem 0;
}
.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar nav li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  position: relative;
}
.sidebar nav li:hover, .sidebar nav li.active {
  background: #e6f0fd;
  color: #2563EB;
}
.sidebar nav li span {
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.sidebar:hover nav li span,
.sidebar.expanded nav li span {
  opacity: 1;
}
.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
}

.btn-primary {
  background: #2563EB;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transition: background 0.2s;
}
.btn-primary:hover {
  background: #1746a2;
}
.btn-extra {
  background: #F7E3A0;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.title-extra::before {
  content: '★ ';
  color: #f7b500;
  font-size: 1.25em;
  margin-right: 0.3em;
}
.star {
  color: #f7b500;
}

main#main-content {
  margin-left: 72px;
  padding: 2rem 1rem 3rem 1rem;
  min-height: 100vh;
  transition: margin-left 0.2s;
}

.kpi-cards {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.kpi-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  padding: 1.2rem 2rem;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: box-shadow 0.2s;
}
.kpi-card .kpi-emoji {
  font-size: 2rem;
  margin-bottom: 0.3em;
}
.kpi-card .kpi-value {
  font-size: 2.1rem;
  font-weight: 600;
}
.kpi-card .kpi-label {
  font-size: 1rem;
  color: #555;
}
.kpi-card.kpi-alert {
  background: #fff5f0;
  border: 1.5px solid #f87171;
  color: #b91c1c;
}

.dashboard-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.dashboard-col {
  flex: 1 1 320px;
  min-width: 280px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  padding: 1.3rem 1rem 1.3rem 1.5rem;
  margin-bottom: 2rem;
}
.semaforo-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.semaforo-table th, .semaforo-table td {
  padding: 0.5rem 0.7rem;
  text-align: left;
}
.semaforo-table tr:nth-child(even) {
  background: #f6f8fa;
}
.semaforo {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  margin-right: 0.5em;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0,0,0,.09);
}
.semaforo-green { background: #22c55e; border: 2px solid #14a34a; }
.semaforo-yellow { background: #fde047; border: 2px solid #eab308; }
.semaforo-red { background: #f87171; border: 2px solid #b91c1c; }
.timeline-today {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}
.timeline-today li {
  padding: 0.4em 0.2em;
  border-bottom: 1px solid #f0f0f0;
  font-size: 1.04rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.timeline-time {
  background: #e0e7ff;
  color: #2563EB;
  border-radius: 6px;
  padding: 0.1em 0.7em;
  font-size: 0.98em;
  margin-left: 1em;
}

h1 span, h2 span {
  font-size: 1.3em;
  vertical-align: middle;
}

.fa-info-circle {
  color: #2563EB;
  margin-left: 0.4em;
  cursor: pointer;
}

.spese-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.3rem;
  gap: 1.5rem;
}
.spese-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.spese-table th, .spese-table td {
  padding: 0.7em 1em;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.spese-table th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 1.06rem;
}
.spese-table tr:last-child td {
  border-bottom: none;
}

.timesheet-bar {
  margin-bottom: 1.3rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.bar-bg {
  background: #e0e7ff;
  border-radius: 12px;
  width: 160px;
  height: 18px;
  overflow: hidden;
  margin-left: 1rem;
}
.bar-fill {
  background: #2563EB;
  height: 100%;
  border-radius: 12px;
  transition: width 0.3s;
}
.timesheet-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.timesheet-table th, .timesheet-table td {
  padding: 0.7em 1em;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
}
.timesheet-table th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 1.06rem;
}
.timesheet-table tr:last-child td {
  border-bottom: none;
}
.ts-input {
  width: 48px;
  padding: 0.3em 0.2em;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 1rem;
  text-align: center;
}
.toast {
  visibility: hidden;
  min-width: 180px;
  background: #f87171;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 0.7em 1.2em;
  position: fixed;
  z-index: 99;
  left: 50%;
  bottom: 2.5em;
  transform: translateX(-50%);
  font-size: 1.05em;
  opacity: 0;
  transition: opacity 0.25s, visibility 0.25s;
}
.toast.show {
  visibility: visible;
  opacity: 1;
}

.task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.task-filter {
  padding: 0.5em 1em;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 1rem;
  min-width: 180px;
}
.task-view-switch {
  display: flex;
  gap: 0.5em;
}
.task-view-switch .btn-primary.active {
  background: #1746a2;
  color: #fff;
}
.task-content {
  position: relative;
}
.task-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  overflow: hidden;
}
.task-table th, .task-table td {
  padding: 0.7em 1em;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.task-table th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 1.06rem;
}
.task-table tr:last-child td {
  border-bottom: none;
}

.kanban-board {
  display: flex;
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.kanban-column {
  flex: 1 1 200px;
  background: #f6f8fa;
  border-radius: 8px;
  min-width: 180px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: 0.7em;
}
.kanban-header {
  font-weight: 600;
  margin-bottom: 0.7em;
  font-size: 1.1em;
}
.kanban-tasks {
  display: flex;
  flex-direction: column;
  gap: 0.7em;
}
.kanban-card {
  background: #fff;
  border-radius: 8px;
  padding: 0.8em 1em;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
  cursor: pointer;
  transition: box-shadow 0.18s;
}
.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(37,99,235,0.12);
}
.kanban-title {
  font-weight: 500;
  margin-bottom: 0.2em;
}
.kanban-meta {
  font-size: 0.97em;
  color: #555;
}

.gantt-mock {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  padding: 1.3rem 1.2rem;
  margin-top: 1.2rem;
}
.gantt-header {
  font-weight: 600;
  margin-bottom: 1.1em;
}
.gantt-legend {
  font-size: 0.98em;
  color: #2563EB;
  margin-left: 1em;
}
.gantt-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
}
.gantt-row {
  display: flex;
  align-items: center;
  gap: 1em;
}
.gantt-label {
  width: 160px;
  font-size: 1em;
}
.gantt-bar {
  display: inline-block;
  height: 14px;
  background: #2563EB;
  border-radius: 5px;
  margin: 0 0.7em;
}
.gantt-date {
  font-size: 0.97em;
  color: #555;
}

.sidepanel {
  position: fixed;
  top: 0; right: 0;
  width: 340px;
  height: 100vh;
  background: #fff;
  box-shadow: -2px 0 8px rgba(0,0,0,.10);
  z-index: 50;
  padding: 2rem 1.2rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  animation: slideInRight 0.18s;
}
@keyframes slideInRight {
  from { right: -380px; }
  to { right: 0; }
}
.sidepanel-tabs {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1em;
}
.tab-btn {
  background: #f6f8fa;
  border: none;
  border-radius: 6px 6px 0 0;
  padding: 0.6em 1.2em;
  font-size: 1em;
  cursor: pointer;
  font-weight: 500;
  color: #222;
}
.tab-btn.active {
  background: #2563EB;
  color: #fff;
}
.sidepanel-content {
  background: #f6f8fa;
  border-radius: 6px;
  padding: 1em;
  min-height: 120px;
  font-size: 1em;
}
.sidepanel .btn-extra {
  align-self: flex-end;
}

/* Settings page enhancements */
.settings-header {
  margin-bottom: 1.5rem;
}
.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
.settings-section label {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  font-weight: 500;
}
.settings-form input,
.settings-form select,
.settings-section button[id^="settings-"],
.settings-section button[id^="add-"],
.user-management .btn-icon,
#clear-logs {
  width: 100%;
}
.settings-section h2 {
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  color: #1746a2;
}
.user-management table {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.user-management th,
.user-management td {
  padding: 0.6rem;
}
.user-management tr:hover {
  background: #f6f8fa;
}
.logs-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem;
}
.logs-list li:nth-child(odd) {
  background: #f9fafb;
}
.logs-list li {
  padding: 0.6rem;
}
#clear-logs {
  margin-bottom: 1rem;
}

.settings-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}
.settings-section {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.settings-section h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.3rem;
  color: #1746a2;
}
.user-management table {
  width: 100%;
  border-collapse: collapse;
}
.user-management th, .user-management td {
  padding: 0.6rem;
  border-bottom: 1px solid #e5e7eb;
}
.user-management .btn-icon {
  color: #dc2626;
}
.logs-section {
  max-height: 300px;
  overflow-y: auto;
}
.logs-list {
  list-style: none;
  padding: 0;
}
.logs-list li {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.95rem;
}
#clear-logs {
  margin-bottom: 1rem;
}

@media (max-width: 900px) {
  .kpi-cards {
    flex-direction: column;
    gap: 1rem;
  }
  .dashboard-row {
    flex-direction: column;
    gap: 1rem;
  }
  .progetti-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }
  .progetti-table th, .progetti-table td {
    font-size: 0.97rem;
  }
}

.progetti-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.3rem;
  gap: 1.5rem;
}
.progetti-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.progetti-table th, .progetti-table td {
  padding: 0.7em 1em;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}
.progetti-table th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 1.06rem;
}
.progetti-table tr:last-child td {
  border-bottom: none;
}
.progetto-stato {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 0.4em;
  vertical-align: middle;
}
.stato-ontrack { background: #22c55e; border: 2px solid #14a34a; }
.stato-delayed { background: #fde047; border: 2px solid #eab308; }
.stato-critical { background: #f87171; border: 2px solid #b91c1c; }

.wizard {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  padding: 2rem 1.5rem 1.5rem 1.5rem;
  max-width: 420px;
  margin: 2rem auto;
  position: relative;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  margin-top: 1em;
}
.wizard label {
  font-weight: 500;
  margin-bottom: 0.4em;
}
.wizard input, .wizard select {
  padding: 0.5em 0.7em;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 1rem;
  margin-top: 0.3em;
  margin-bottom: 0.7em;
}
.wizard .btn-primary, .wizard .btn-extra {
  margin-top: 1.2em;
  width: fit-content;
}
.wizard .btn-extra {
  position: absolute;
  right: 1.5rem;
  top: 1.5rem;
}

.sidebar:hover ~ main#main-content,
.sidebar.expanded ~ main#main-content {
  margin-left: 220px;
}

@media (max-width: 900px) {
  .sidebar {
    width: 56px;
  }
  .sidebar:hover, .sidebar.expanded {
    width: 180px;
  }
  main#main-content {
    margin-left: 56px;
  }
  .sidebar:hover ~ main#main-content,
  .sidebar.expanded ~ main#main-content {
    margin-left: 180px;
  }
}
.js-fallback-msg {
  color: red;
  font-weight: bold;
  font-size: 1.3em;
  padding: 2em;
}

@media (max-width: 600px) {
  .sidebar {
    position: absolute;
    left: -72px;
    top: 0;
    height: 100vh;
    width: 180px;
    z-index: 100;
    transition: left 0.2s;
  }
  .sidebar.open {
    left: 0;
  }
  main#main-content {
    margin-left: 0;
    padding: 1rem 0.5rem;
  }
}

/* Footer global */
.app-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: #555;
  margin-top: 2rem;
}
