:root {
  --bg: #f5f7fb;
  --accent: #1c93e2;
  --muted: #666;
  --c-vuoto: #ffffff;
  --c-acc-inserita: #dcdcdc;
  --c-acc-lavorabile: #9ea7b0;
  --c-in_lavorazione: #ffe08a;
  --c-pronta: #b7f2b0;
  --c-validata: #c8f7d4;
  --c-standby: #ff8a8a;
  --c-fermo: #8b4b2d;
  --c-priorita: #a34ff0;
  --card-bg: #fff;
  --border: #e6e9ef;
  --table-row-hover: #fafcff;
  --max-width: 98%;
}

/* RESET / BASICS */
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: #222;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* HEADER */
header {
  padding: 14px 18px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

header .header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

/* LAYOUT CONTAINER */
.container {
  max-width: var(--max-width);
  margin: 18px auto;
  padding: 18px;
}

/* LEGEND */
.legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-item .color-box {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: inline-block;
}

/* CONTROLS (se servono) */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px
}

/* ORLOGIO */
.orologio-div {
  margin-bottom: 12px;
  text-align: center;
}

.orologio {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  /* border-collapse and table-layout removed as they don't apply to p tag */
}

.table-wrapper h3 {
  text-align: center;
}

.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid #eef2f6;
  text-align: left;
  vertical-align: middle;
}

/* Center first column (Numero) */
.table td:first-child,
.table th:first-child {
  text-align: center;
}

/* FORZARE I PULSANTI SU UNICA RIGA */
.table td {
  white-space: nowrap;
  /* non andare a capo */
  overflow: hidden;
  text-overflow: ellipsis;
}

.table td .btn {
  /* garantisce che il bottone sia inline e non si rompa */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-right: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
}

.table td .btn:last-child {
  margin-right: 0;
}

/* Allow wrapping for actions column to prevent overflow */
.table td:last-child {
  white-space: nowrap;
}

/* classi utility per bottoni */
.btn {
  display: inline-flex;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none
}

.btn-small {
  padding: 4px 6px;
  font-size: 0.9rem
}

/* BOX / GRID (per visual board se usata altrove) */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px
}

.box {
  background: var(--card-bg);
  padding: 12px;
  border-radius: 8px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--border);
}

/* QUADRATO COLORE --> INGRANDITO */
.color-square {
  width: 56px;
  /* prima era 40px, ora più grande */
  height: 56px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

/* PRIORITÀ: effetto lampeggiante */
.blink {
  animation: blink 2s infinite
}

@keyframes blink {
  0% {
    box-shadow: 0 0 20px rgba(163, 79, 240, 1)
  }

  50% {
    box-shadow: 0 0 2px rgba(163, 79, 240, 0.25)
  }

  100% {
    box-shadow: 0 0 20px rgba(163, 79, 240, 1)
  }
}

/* SMALL TEXT */
.small-muted {
  font-size: 0.9rem;
  color: var(--muted)
}

/* RESPONSIVE: riduci il quadrato sui piccoli schermi */
@media (max-width:720px) {
  .color-square {
    width: 44px;
    height: 44px
  }

  .table th,
  .table td {
    padding: 8px 6px
  }

  .orologio {
    font-size: 1.2rem
  }
}

/* ----- STILI SPECIFICI PER LA VISTA UFFICIO (ADMIN) ----- */
/* Il DOM generato dallo script mette due <div> affiancati dentro #office-tables.
   Applichiamo bordo verticale alla seconda colonna per fare la "linea" centrale. */
#office-tables>div {
  display: block;
}

#office-tables>div>div {
  /* i due pannelli figli */
  background: transparent;
}

#office-tables>div>div:nth-child(2) {
  border-left: 1px solid var(--border);
  padding-left: 14px;
}

/* Workshop Table Centering */
#workshop-table {
  display: flex;
  justify-content: center;
}

#workshop-table table {
  width: auto;
  min-width: 600px;
}

/* Miglioramento visuale tabelle */
.table thead th {
  font-weight: 700;
  background: transparent;
  border-bottom: 2px solid #eef2f6
}

.table tbody tr:hover {
  background: var(--table-row-hover)
}

.orologio {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  /* border-collapse and table-layout removed as they don't apply to p tag */
}

.table-wrapper h3 {
  text-align: center;
}

.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid #eef2f6;
  text-align: left;
  vertical-align: middle;
}

/* Center first column (Numero) */
.table td:first-child,
.table th:first-child {
  text-align: center;
}

/* FORZARE I PULSANTI SU UNICA RIGA */
.table td {
  white-space: nowrap;
  /* non andare a capo */
  overflow: hidden;
  text-overflow: ellipsis;
}

.table td .btn {
  /* garantisce che il bottone sia inline e non si rompa */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-right: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
}

.table td .btn:last-child {
  margin-right: 0;
}

/* Allow wrapping for actions column to prevent overflow */
.table td:last-child {
  white-space: nowrap;
}

/* classi utility per bottoni */
.btn {
  display: inline-flex;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none
}

.btn-small {
  padding: 4px 6px;
  font-size: 0.9rem
}

/* BOX / GRID (per visual board se usata altrove) */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px
}

.box {
  background: var(--card-bg);
  padding: 12px;
  border-radius: 8px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--border);
}

/* QUADRATO COLORE --> INGRANDITO */
.color-square {
  width: 56px;
  /* prima era 40px, ora più grande */
  height: 56px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

/* PRIORITÀ: effetto lampeggiante */
.blink {
  animation: blink 2s infinite
}

@keyframes blink {
  0% {
    box-shadow: 0 0 20px rgba(163, 79, 240, 1)
  }

  50% {
    box-shadow: 0 0 2px rgba(163, 79, 240, 0.25)
  }

  100% {
    box-shadow: 0 0 20px rgba(163, 79, 240, 1)
  }
}

/* SMALL TEXT */
.small-muted {
  font-size: 0.9rem;
  color: var(--muted)
}

/* RESPONSIVE: riduci il quadrato sui piccoli schermi */
@media (max-width:720px) {
  .color-square {
    width: 44px;
    height: 44px
  }

  .table th,
  .table td {
    padding: 8px 6px
  }

  .orologio {
    font-size: 1.2rem
  }
}

/* ----- STILI SPECIFICI PER LA VISTA UFFICIO (ADMIN) ----- */
/* Il DOM generato dallo script mette due <div> affiancati dentro #office-tables.
   Applichiamo bordo verticale alla seconda colonna per fare la "linea" centrale. */
#office-tables>div {
  display: block;
}

#office-tables>div>div {
  /* i due pannelli figli */
  background: transparent;
}

#office-tables>div>div:nth-child(2) {
  border-left: 1px solid var(--border);
  padding-left: 14px;
}

/* Workshop Table Centering */
#workshop-table {
  display: flex;
  justify-content: center;
}

#workshop-table table {
  width: auto;
  min-width: 600px;
}

/* Miglioramento visuale tabelle */
.table thead th {
  font-weight: 700;
  background: transparent;
  border-bottom: 2px solid #eef2f6
}

.table tbody tr:hover {
  background: var(--table-row-hover)
}

/* MODAL: overlay centrato sopra il contenuto con sfondo semitrasparente e blur */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal .card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transform: translateY(0);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal .card h4 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #111;
  border-bottom: 1px solid #eee;
  padding-bottom: 16px;
}

/* FORM STYLES */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #f9fafb;
  color: #333;
  transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(28, 147, 226, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Checkbox styling wrapper */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-wrapper label {
  margin-bottom: 0;
  cursor: pointer;
}

/* Modal Actions */
.modal-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.btn-danger {
  background: #ff4d4f;
  color: white;
}

.btn-danger:hover {
  background: #ff7875;
}

@media (max-width:520px) {
  .modal .card {
    max-width: 100%;
    padding: 16px;
    border-radius: 12px;
  }
}