#traceability {
  padding-bottom: 85px;
}

#traceability .tr-heading {
  color: #082a4d;
  margin: 12px 0 18px;
}

.tr-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tr-stat {
  background: white;
  border: 1px solid #e4dfd3;
  border-radius: 14px;
  padding: 16px;
}

.tr-stat strong {
  display: block;
  font-size: 30px;
  color: #082a4d;
  margin: 6px 0;
}

.tr-stat span {
  color: #277484;
  font-size: 13px;
}

.tr-stat-icon {
  font-size: 24px;
}

.tr-action {
  display: block;
  width: 100%;
  padding: 20px 12px;
  margin: 12px 0;
  border: 0;
  border-radius: 14px;
  background: #082a4d;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.tr-action.secondary {
  background: #e5f0ee;
  color: #082a4d;
}

.tr-empty {
  background: white;
  border: 1px solid #e4dfd3;
  border-radius: 14px;
  text-align: center;
  padding: 30px 15px;
  color: #66747b;
}

#trNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: white;
  border-top: 1px solid #e4dfd3;
  padding: 8px 4px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

#trNav button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #082a4d;
  padding: 8px 2px;
  font-size: 11px;
  cursor: pointer;
}

#trNav button.active {
  background: #e5f0ee;
  color: #277484;
}

#trNav button span {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

#trNav.hide {
  display: none !important;
}

.tr-form {
  background: white;
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
}

.tr-form label {
  display: block;
  margin: 12px 0 5px;
  color: #082a4d;
  font-weight: 600;
}

.tr-form input,
.tr-form select,
.tr-form textarea {
  width: 100%;
  box-sizing: border-box;
}

.tr-list-item {
  background: white;
  border: 1px solid #e4dfd3;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.tr-status {
  color: #277484;
  font-size: 13px;
  margin: 10px 0;
}

@media print {
  #traceability,
  #trNav {
    display: none !important;
  }
}

.app-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.tr-stat-icon {
  color: #277484;
}

.tr-stat-icon .app-icon {
  width: 30px;
  height: 30px;
}

#trNav .app-icon,
nav .app-icon {
  width: 23px;
  height: 23px;
}

.tr-action .app-icon {
  margin-right: 8px;
  width: 26px;
  height: 26px;
}

.hamburger .app-icon {
  width: 28px;
  height: 28px;
}

#home .home-module {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 18px 14px;
  margin: 16px 0;
  text-align: left;
  background: white;
  border: 1px solid #e4dfd3;
  border-radius: 16px;
  box-sizing: border-box;
}

.home-module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 14px;
  background: #e5f0ee;
  color: #277484;
}

.home-module-icon .app-icon {
  width: 34px;
  height: 34px;
}

.home-module-text {
  flex: 1;
  min-width: 0;
}

#home .home-module-text strong {
  display: block;
  color: #082a4d;
  font-size: 17px;
  margin-bottom: 6px;
}

#home .home-module-text span {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  color: #66747b;
}

.home-module-arrow {
  color: #082a4d;
  flex-shrink: 0;
}

.home-module-arrow .app-icon {
  width: 20px;
  height: 20px;
}

/* CONTROLLO SCADENZE */

.tr-expiry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.tr-expiry-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-height: 100px;
  padding: 16px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-left: 5px solid currentColor;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}

.tr-expiry-stat span {
  font-size: 30px;
  font-weight: 700;
}

.tr-expiry-stat small {
  font-size: 12px;
  font-weight: 600;
  color: #082a4d;
}

.tr-red {
  color: #b42318;
}

.tr-orange {
  color: #c76b19;
}

.tr-yellow {
  color: #a17a00;
}

.tr-green {
  color: #28774b;
}

.tr-grey {
  color: #687780;
}

.tr-expiry-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.tr-expiry-filters .btn {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 20px;
}

.tr-expiry-filters .btn.active {
  background: #082a4d;
  color: #fff;
}

.tr-expiry-stat.active {
  box-shadow: 0 0 0 2px currentColor;
}

#trExpirySearch {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
}

#trExpiryList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tr-expiry-item {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-left: 5px solid currentColor;
  border-radius: 12px;
  padding: 14px;
  text-align: left;
}

.tr-expiry-item strong {
  display: block;
  color: #082a4d;
  font-size: 16px;
  margin-bottom: 6px;
}

.tr-expiry-item p {
  margin: 4px 0;
  font-size: 13px;
  color: #52616b;
}

.tr-expiry-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.tr-red .tr-expiry-badge {
  background: #fce8e6;
}

.tr-orange .tr-expiry-badge {
  background: #fff0dc;
}

.tr-yellow .tr-expiry-badge {
  background: #fff7d6;
}

.tr-green .tr-expiry-badge {
  background: #e8f3eb;
}

.tr-grey .tr-expiry-badge {
  background: #eef0f2;
}


/* ACQUISIZIONE ETICHETTE */

#trCapture {
  padding-bottom: 20px;
}

.tr-capture-card {
  background: #fff;
  border: 1px solid #e1e5e5;
  border-radius: 14px;
  padding: 20px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tr-capture-card > svg {
  color: #277484;
  align-self: center;
  margin: 8px 0;
}

.tr-capture-card h3 {
  color: #082a4d;
  margin: 0;
  font-size: 18px;
}

.tr-capture-card p {
  margin: 0;
  line-height: 1.5;
}

.tr-capture-card .btn {
  width: 100%;
  min-height: 46px;
}

.tr-capture-card select {
  width: 100%;
  box-sizing: border-box;
}

#trCapturePreview {
  margin: 20px 0;
}

#trCaptureImages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.tr-capture-image {
  position: relative;
  background: #fff;
  border: 1px solid #e1e5e5;
  border-radius: 12px;
  overflow: hidden;
}

.tr-capture-image img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f0f2f2;
}

.tr-capture-image-info {
  padding: 10px;
  font-size: 12px;
  color: #52616b;
  overflow-wrap: anywhere;
}

.tr-capture-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: #b42318;
  color: #fff;
  cursor: pointer;
}

.tr-capture-remove svg {
  width: 18px;
  height: 18px;
}

#trClearImages {
  width: 100%;
  color: #b42318;
}

#trCaptureMessage {
  overflow-wrap: anywhere;
}

@media (min-width: 700px) {
  #trCaptureImages {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tr-capture-image img {
    height: 220px;
  }
}


/* DETTAGLIO LOTTO */

#trLotDetail {
  padding-bottom: 24px;
}

.tr-detail-card {
  background: #fff;
  border: 1px solid #e1e5e5;
  border-radius: 14px;
  padding: 18px;
  margin: 16px 0;
}

.tr-detail-card h3 {
  color: #082a4d;
  font-size: 18px;
  margin: 0 0 16px;
}

.tr-detail-card .btn {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
}

.tr-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tr-detail-name {
  color: #082a4d;
  font-size: 24px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tr-detail-number {
  color: #687780;
  font-size: 14px;
  margin-top: 4px;
}

.tr-detail-state {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: #eef0f2;
  color: #52616b;
}

.tr-state-disponibile {
  background: #e8f3eb;
  color: #28774b;
}

.tr-state-esaurito {
  background: #eef0f2;
  color: #687780;
}

.tr-state-scartato,
.tr-state-bloccato {
  background: #fce8e6;
  color: #b42318;
}

.tr-detail-quantities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
  padding: 16px 0;
  border-top: 1px solid #edf0f0;
  border-bottom: 1px solid #edf0f0;
}

.tr-detail-quantity small {
  display: block;
  color: #687780;
  font-size: 12px;
  margin-bottom: 6px;
}

.tr-detail-quantity strong {
  color: #082a4d;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.tr-detail-expiry {
  padding: 12px;
  border-radius: 8px;
  background: #f0f3f3;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.tr-detail-expiry.tr-red {
  background: #fce8e6;
}

.tr-detail-expiry.tr-orange {
  background: #fff0dc;
}

.tr-detail-expiry.tr-yellow {
  background: #fff7d6;
}

.tr-detail-expiry.tr-green {
  background: #e8f3eb;
}

.tr-detail-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #edf0f0;
  font-size: 14px;
}

.tr-detail-field:last-child {
  border-bottom: 0;
}

.tr-detail-field span {
  color: #687780;
}

.tr-detail-field strong {
  color: #082a4d;
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

#trDetailLabels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.tr-detail-label {
  display: block;
  background: #fff;
  border: 1px solid #e1e5e5;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: #082a4d;
}

.tr-detail-label img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f0f2f2;
}

.tr-detail-label-info {
  padding: 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tr-detail-label-info small {
  display: block;
  margin-top: 5px;
  color: #687780;
}

#trDetailEdit {
  width: 100%;
  min-height: 46px;
}

#trDetailBack,
#trDetailAddLabel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tr-lot-open {
  width: 100%;
  margin-top: 10px;
}

@media (min-width: 700px) {
  #trDetailLabels {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tr-detail-label img {
    height: 240px;
  }
}


/* Storico movimenti di magazzino */

#trDetailMovements {
  text-align: left;
  padding: 0;
}

.tr-movement-item {
  padding: 14px 0;
  border-bottom: 1px solid #e3e8eb;
}

.tr-movement-item:last-child {
  border-bottom: 0;
}

.tr-movement-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tr-movement-top strong {
  color: #082a4d;
  font-size: 15px;
}

.tr-movement-top small {
  display: block;
  color: #667580;
  font-size: 12px;
  margin-top: 4px;
}

.tr-movement-quantity {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.tr-movement-quantity.positive {
  color: #27784a;
}

.tr-movement-quantity.negative {
  color: #9e3f3f;
}

.tr-movement-reason {
  color: #082a4d;
  font-size: 13px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.tr-movement-note {
  color: #667580;
  font-size: 12px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}


/* Registrazione movimenti */

#trDetailMovements {
  padding: 0 14px;
}

.tr-movement-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.tr-movement-actions .btn {
  width: 100%;
  min-height: 54px;
  margin: 0;
  font-size: 14px;
}

#trDetailConsume:not(:disabled) {
  background: #277484;
  color: white;
}

#trDetailWaste:not(:disabled) {
  background: #9e3f3f;
  color: white;
}

#trMovementForm {
  margin-top: 18px;
  padding: 16px;
  background: #f7f3e8;
  border: 1px solid #ded8ca;
  border-radius: 14px;
}

.tr-movement-preview {
  background: white;
  color: #082a4d;
  border-radius: 10px;
  padding: 14px;
  margin: 14px 0;
  font-weight: 700;
}

