:root {
  --bg: #0b1020;
  --card: #121a33;
  --text: #e7ecff;
  --muted: #a9b3d3;
  --line: rgba(255, 255, 255, 0.1);
  --btn: #3b82f6;
  --btn2: #24314f;
  --danger: #ef4444;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    sans-serif;
  background: linear-gradient(180deg, #050816, #0b1020 30%, #060a17);
  color: var(--text);
}
a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10, 14, 30, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800;
  letter-spacing: 0.3px;
}
.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.nav a {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
}
.nav a.active,
.nav a:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.badge {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
}

.container {
  max-width: 1150px;
  margin: 0 auto;
  padding: 16px;
}
h1 {
  font-size: 24px;
  margin: 12px 0 10px;
}
h2 {
  font-size: 18px;
  margin: 8px 0 10px;
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.card {
  background: rgba(18, 26, 51, 0.75);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  margin: 12px 0;
  overflow: hidden;
}
.pad {
  padding: 14px;
}
.hr {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
textarea,
input,
select {
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}
textarea {
  min-height: 80px;
  resize: vertical;
}
.form-grid .span2 {
  grid-column: span 2;
}

#manualItemForm datalist option {
  color: #000;
}

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

@media (max-width: 900px) {
  .template-options-grid {
    grid-template-columns: 1fr;
  }
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--btn);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.btn.secondary {
  background: var(--btn2);
}
.btn.danger {
  background: var(--danger);
}
.btn.ok {
  background: var(--ok);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.items-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 18px;
  align-items: start;
}

.items-topbar h1 {
  margin-top: 0;
}

.items-import-card {
  justify-self: end;
  width: 100%;
}

.items-import-card h2 {
  margin-top: 0;
}

@media (max-width: 900px) {
  .items-topbar {
    grid-template-columns: 1fr;
  }

  .items-import-card {
    justify-self: stretch;
  }
}

.label-sheet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
@media (max-width: 900px) {
  .label-sheet {
    grid-template-columns: 1fr;
  }
}

.label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
}
.label .qr {
  width: 168px;
  height: 168px;
  background: white;
  border-radius: 8px;
  padding: 4px;
}
.label-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.small {
  font-size: 13px;
}
.tiny {
  font-size: 11px;
  word-break: break-all;
}

.flash {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}
.flash.ok {
  border-color: rgba(34, 197, 94, 0.4);
}
.flash.err {
  border-color: rgba(239, 68, 68, 0.5);
}

/* Rende visibile l'icona calendario su tema scuro */

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 1;
  cursor: pointer;
}

/* --- ROTOLI 50x30mm --- */
@page {
  size: 50mm 30mm;
  margin: 0;
}

@media print {
  header,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    margin: 0;
  }
  .container {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* IMPORTANTISSIMO: su rotolo non vuoi "griglie" di etichette */
  .label-sheet {
    display: block !important;
    padding: 0;
    margin: 0;
  }
  .label {
    page-break-after: always;
    break-after: page;
  }
}

/* Etichetta singola */
.label {
  width: 50mm;
  height: 30mm;
  box-sizing: border-box;
  padding: 1mm 1.5mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3mm;
  background: #fff;
}

.label .qr {
  width: 17mm;
  height: 17mm;
  box-sizing: border-box;
  padding: 0;
  flex: 0 0 auto;
}

.label-description {
  width: 47mm;
  min-height: 4mm;
  max-height: 4mm;
  overflow: hidden;
  text-align: center;
  font-size: 5.4pt;
  line-height: 1;
  color: #000;
  font-weight: 700;
}

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

.sku {
  width: 47mm;
  min-height: 5.5mm;
  max-height: 5.5mm;
  overflow: hidden;
  text-align: center;
  font-size: 6.6pt;
  line-height: 1.05;
  color: #000;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.label-area {
  width: 47mm;
  min-height: 3.5mm;
  max-height: 3.5mm;
  overflow: hidden;
  text-align: center;
  font-size: 6.4pt;
  line-height: 1.1;
  color: #000;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lot {
  font-size: 10pt;
  line-height: 1.1;
  margin-top: 1.2mm;
  color: #000;
  font-weight: 600;
}

.stock-equipment-select,
.stock-equipment-select option {
  background: #0b1f5e;
  color: #e7ecff;
}

/* ===== FIX BOM TABLE DARK MODE ===== */

.table-wrap table {
  background-color: #1e1e1e;
  color: #e6e6e6;
}

.table-wrap thead {
  background-color: #2c2c2c;
}

.table-wrap th {
  color: #ffffff;
  border-bottom: 1px solid #444;
}

.table-wrap td {
  color: #e6e6e6;
  border-bottom: 1px solid #333;
}

.table-wrap tr:hover {
  background-color: #333333;
}
.table-wrap tr,
.dark-table tr {
  background-color: #1e1e1e;
}
/* ===== BOM DARK TABLE ===== */

.dark-table {
  width: 100%;
  border-collapse: collapse;
  background-color: #1e1e1e;
  color: #e6e6e6;
}

.dark-table th {
  background-color: #2c2c2c;
  color: #ffffff;
  padding: 10px;
  border-bottom: 1px solid #444;
}

.dark-table td {
  padding: 10px;
  border-bottom: 1px solid #333;
  color: #e6e6e6;
}

.dark-table tr:hover {
  background-color: #333;
}
.table-wrap tr:nth-child(even),
.table-wrap tr:nth-child(odd),
.dark-table tr:nth-child(even),
.dark-table tr:nth-child(odd) {
  background-color: #1e1e1e !important;
}
