/* Gestionale Preventivi - Stylesheet */

:root {
  --gp-primary: #1a56db;
  --gp-sidebar-width: 220px;
  --gp-topbar-height: 48px;
}

/* ===== LAYOUT SIDEBAR ===== */
body { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar — safe area Apple / webkit */
.gp-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: var(--gp-topbar-height);
  /* iOS 11.0-11.2 (vecchia sintassi) */
  padding-top: constant(safe-area-inset-top);
  /* iOS 11.2+ / webkit moderno */
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: constant(safe-area-inset-left);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: constant(safe-area-inset-right);
  padding-right: env(safe-area-inset-right, 0px);
  background: #ffc008;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  /* Estendi il colore di sfondo sopra il safe area */
  -webkit-background-clip: padding-box;
}
/* Colore status-bar = topbar color su iOS (PWA) */
@supports (padding-top: env(safe-area-inset-top)) {
  .gp-topbar {
    background-color: #ffc008;
  }
}
.gp-topbar-brand { font-size: 1rem; letter-spacing: -.01em; }
.gp-topbar-hamburger { line-height: 1; }

/* Layout principale */
.gp-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar desktop */
.gp-sidebar {
  width: var(--gp-sidebar-width);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  position: sticky;
  top: calc(var(--gp-topbar-height) + constant(safe-area-inset-top));
  top: calc(var(--gp-topbar-height) + env(safe-area-inset-top, 0px));
  align-self: flex-start;
  height: calc(100vh - var(--gp-topbar-height) - constant(safe-area-inset-top));
  height: calc(100vh - var(--gp-topbar-height) - env(safe-area-inset-top, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .2s ease;
}
.gp-layout.sidebar-collapsed .gp-sidebar {
  width: 0;
  border-right: none;
}

/* Offcanvas sidebar mobile/tablet */
.gp-sidebar-offcanvas {
  width: var(--gp-sidebar-width) !important;
  background: #fff;
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: constant(safe-area-inset-left);
  padding-left: env(safe-area-inset-left, 0px);
}

/* Main content */
.gp-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

/* Nav links sidebar */
.gp-side-nav { font-size: .9rem; }
.gp-nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .75rem;
  border-radius: .5rem;
  color: #374151;
  text-decoration: none;
  transition: background .12s, color .12s;
  font-weight: 500;
}
.gp-nav-link i { font-size: 1.05rem; flex-shrink: 0; }
.gp-nav-link:hover { background: #f3f4f6; color: #111; }
.gp-nav-link.active { background: #fef9e7; color: #92400e; font-weight: 600; }
.gp-side-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: .25rem .75rem .2rem;
  margin-bottom: .15rem;
}

/* Layout */
.main-content {
  min-height: calc(100vh - var(--gp-topbar-height) - 52px);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
}

/* Navbar */
.navbar.bg-primary {
  background-color: #ffc008 !important;
}
.navbar-brand,
.navbar .nav-link,
.navbar .navbar-text,
.navbar .dropdown-toggle {
  color: #333 !important;
}
.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: #000 !important;
}
.navbar-toggler {
  border-color: rgba(51,51,51,.4);
}
.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2851,51,51,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.navbar-brand {
  font-size: 1.1rem;
  letter-spacing: -.02em;
}

/* Cards */
.card {
  transition: box-shadow .15s;
}

/* DataTables */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  padding: .25rem 1.75rem .25rem .5rem;
}
.dataTables_wrapper .dataTables_length select {
  min-width: 75px;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: .75rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  margin-top: .5rem;
}
table.dataTable tbody tr:hover {
  background-color: rgba(26,86,219,.04) !important;
}

/* Select2 */
.select2-container {
  width: 100% !important;
}

/* Sfondo pagina grigio chiaro — le card restano bianche */
body { background-color: #f0f2f5 !important; }

/* Preventivo editor */
#tblRighe thead th {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  font-weight: 600;
}

.riga-separatore td {
  background: #f1f3f5;
  font-weight: 600;
}
.riga-testo td {
  background: #fafafa;
  color: #6c757d;
  font-style: italic;
}
.drag-handle {
  cursor: grab;
  opacity: .4;
  transition: opacity .15s;
}
tr:hover .drag-handle { opacity: .8; }
.sortable-chosen { background: #e8f0fe !important; }
.riga-row td { padding: .4rem .5rem; vertical-align: top; }
.riga-row input, .riga-row select, .riga-row textarea {
  font-size: .85rem;
}
.riga-totale {
  font-weight: 600;
  color: var(--gp-primary);
  white-space: nowrap;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  top: 100%;
  left: 0;
  right: 0;
  border: 1px solid #dee2e6;
  background: #fff;
  border-radius: .375rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.autocomplete-dropdown .list-group-item:hover {
  background: #f0f4ff;
}

/* Badges */
.badge { font-weight: 500; }

/* Toast */
#toastContainer .toast { min-width: 280px; }

/* Print preventivo */
@media print {
  .gp-topbar, .gp-sidebar, .footer, .print-bar { display: none !important; }
  .main-content { padding: 0 !important; margin: 0 !important; }
  .card { border: none !important; box-shadow: none !important; }
}

/* Status colors */
.stato-bozza    { background: #6c757d; }
.stato-inviato  { background: var(--gp-primary); }
.stato-accettato{ background: #198754; }
.stato-rifiutato{ background: #dc3545; }
.stato-scaduto  { background: #ffc107; color: #000; }

/* ===== Tabelle responsive: stile card su mobile (≤767px) ===== */
@media (max-width: 767.98px) {
  /* Tabella card-stack: ogni riga diventa un blocco */
  .gp-table-stack { border-collapse: separate; border-spacing: 0; }
  .gp-table-stack thead { display: none; }
  .gp-table-stack tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .6rem;
    margin-bottom: .6rem;
    padding: .4rem .6rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  .gp-table-stack tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    border: none !important;
    padding: .28rem .1rem;
    font-size: .88rem;
  }
  .gp-table-stack tbody td:empty { display: none; }
  .gp-table-stack tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    font-size: .78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  /* Colonna azioni: a tutta larghezza */
  .gp-table-stack tbody td.td-azioni {
    justify-content: flex-end;
    padding-top: .4rem;
  }
  .gp-table-stack tbody td.td-azioni::before { display: none; }
  /* Wrapper: senza scroll orizzontale */
  .gp-table-stack-wrap { overflow: visible; }
}

/* ===== Responsive generale ===== */
@media (max-width: 767.98px) {
  /* padding laterali includono safe-area per iPhone con notch */
  .main-content {
    padding-top:    .75rem !important;
    padding-bottom: .75rem !important;
    padding-left:  max(.75rem, calc(.5rem + env(safe-area-inset-left)))  !important;
    padding-right: max(.75rem, calc(.5rem + env(safe-area-inset-right))) !important;
  }
  .display-6 { font-size: 1.5rem; }

  /* Evita scroll orizzontale a livello di pagina */
  body { overflow-x: hidden; }

  /* Card header più compatta */
  .card-body { padding: .75rem; }
  .card-header { padding: .6rem .75rem; }

  /* Heading pagina + bottone su colonne separate → stack */
  .row.mb-3.align-items-center > .col-auto { margin-top: .25rem; }

  /* Tabelle DataTable: forza overflow nel wrapper */
  .dataTables_wrapper { overflow-x: hidden; }
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_filter { font-size: .8rem; }

  /* Nasconde i controlli DataTable meno utili su mobile */
  .dataTables_length { display: none; }

  /* Bottoni gruppo azioni nelle tabelle: più compatti */
  .btn-group .btn { padding: .25rem .4rem; }

  /* Filtri: nasconde l'etichetta delle date su mobile (risparmia spazio) */
  .filtri-label-mobile { display: none; }

  /* Select2 non tracima */
  .select2-container--bootstrap-5 .select2-selection { font-size: 14px; }

  /* preventivo_create: header pagina */
  #btnSalvaPreventivo { width: 100%; }

  /* preventivo_view: bottoni top in flex-wrap */
  .col-12.col-md-auto.order-1 { flex-wrap: wrap; gap: .4rem !important; }
  .col-12.col-md-auto.order-1 .btn { font-size: .8rem; padding: .35rem .6rem; }
}

@media (max-width: 991.98px) {
  /* Tablet */
  .main-content { padding: 1rem; }
}

/* Articolo image preview */
.articolo-img-preview {
  background: #f8f9fa;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer */
.footer {
  font-size: .85rem;
}

/* Form labels */
.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: #374151;
}

/* Utils */
.cursor-pointer { cursor: pointer; }
.bg-primary-subtle { background-color: #dbeafe !important; }
.text-primary { color: var(--gp-primary) !important; }

/* ===== PWA / Mobile full-screen — Safe Area (iPhone notch + Dynamic Island) =====
   ARCHITETTURA:
   - body: SOLO padding-bottom (home indicator). NON left/right per evitare
     il doppio conteggio con navbar e .main-content che li gestiscono direttamente.
   - navbar sticky: padding-top copre notch/status-bar, left/right coprono
     le aree arrotondate; il colore di sfondo si estende nell'area notch
     grazie a viewport-fit=cover + apple-mobile-web-app-status-bar-style.
   - .main-content: padding laterali sicuri su mobile.
   - In standalone (PWA): NO padding-top sul body, la navbar lo gestisce da sola.
   ============================================================================ */

body {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Navbar: sfondo copre la zona notch/Dynamic Island */
.navbar {
  padding-left:  calc(.75rem + env(safe-area-inset-left));
  padding-right: calc(.75rem + env(safe-area-inset-right));
  padding-top:   calc(.5rem  + env(safe-area-inset-top));
}

/* Menu hamburger aperto: non finire sotto l'home indicator */
#navbarMain.show {
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
}

/* Footer sopra la barra home di iOS */
.footer {
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* Toast sopra la barra home e fuori dalle aree sicure */
#toastContainer {
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  padding-right:  calc(.75rem + env(safe-area-inset-right));
}

/* Modali: footer non tagliato dall'home indicator */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Standalone PWA: nessun padding-top sul body
   (la navbar con padding-top gestisce da sola il notch) */
@media (display-mode: standalone) {
  body {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* Bottoni e tap target minimi 44×44px su mobile */
@media (max-width: 767.98px) {
  .btn { min-height: 44px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
  .dropdown-item { min-height: 44px; display: flex; align-items: center; }
  .btn-sm { min-height: 36px; }
}

/* DataTables responsive child row stile */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
  background-color: var(--gp-primary);
}

/* Bottoni azioni in lista: su mobile mostra solo icone principali */
@media (max-width: 767.98px) {
  /* Nasconde i bottoni email/firma dalla lista su mobile (troppo affollati) */
  .btn-group .btn-outline-success.d-mobile-none,
  .btn-group .btn-outline-primary.d-mobile-none { display: none !important; }
}

/* preventivo_create + view: mobile */
@media (max-width: 767.98px) {
  /* Totali riepilogo: layout colonna */
  #totaliRiepilogo .row > div { margin-bottom: .4rem; }

  /* Bottoni top in preventivo_view: più piccoli */
  .col-12.col-md-auto.order-1.order-md-2 .btn { font-size: .8rem; padding: .35rem .55rem; }

  /* Sezioni form: meno padding */
  .col-lg-8 > .card > .card-body,
  .col-lg-4 > .card > .card-body { padding: .75rem; }

  /* preventivo_view: tabella righe scrollabile */
  .card .table-responsive { -webkit-overflow-scrolling: touch; }

  /* prevent overflows in card bodies with long text */
  .card-body { word-break: break-word; }
}

/* ================================================
   RIGHE PRODOTTO DESKTOP — layout a 2 righe per riga prodotto
   Attivo da 992px in su
   ================================================ */
@media (min-width: 992px) {
  #tblRighe,
  #tblRighe tbody { display: block; width: 100%; }
  #tblRighe thead { display: none; }

  /* Card con CSS Grid: 8 colonne logiche, 2 righe per prodotto */
  #tblRighe tr.riga-prodotto {
    display: grid;
    grid-template-columns: 28px 52px minmax(160px, 1fr) 72px 52px 98px 108px 88px 32px;
    /* col: drag | img | desc | qty | um | prezzo | iva* | totale | del */
    grid-template-rows: auto auto;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 4px 2px;
    background: #fff;
    column-gap: 4px;
    align-items: start;
  }

  #tblRighe tr.riga-prodotto > td {
    border: none !important;
    padding: 3px 4px !important;
  }

  /* drag: col 1, spans 2 righe */
  #tblRighe tr.riga-prodotto > td:nth-child(1) {
    grid-column: 1; grid-row: 1 / span 2;
    display: flex; align-items: center; justify-content: center;
  }
  /* img: col 2, spans 2 righe */
  #tblRighe tr.riga-prodotto > td:nth-child(2) {
    grid-column: 2; grid-row: 1 / span 2;
    display: flex; align-items: center;
  }
  /* desc: col 3, spans 2 righe */
  #tblRighe tr.riga-prodotto > td:nth-child(3) {
    grid-column: 3; grid-row: 1 / span 2;
  }
  /* qty: col 4, riga 1 */
  #tblRighe tr.riga-prodotto > td:nth-child(4) { grid-column: 4; grid-row: 1; }
  /* um: col 5, riga 1 */
  #tblRighe tr.riga-prodotto > td:nth-child(5) { grid-column: 5; grid-row: 1; }
  #tblRighe tr.riga-prodotto > td:nth-child(5) input { width: 100% !important; }
  /* prezzo: col 6, riga 1 */
  #tblRighe tr.riga-prodotto > td:nth-child(6) { grid-column: 6; grid-row: 1; }
  /* sconto: col 4, riga 2 */
  #tblRighe tr.riga-prodotto > td:nth-child(7) { grid-column: 4; grid-row: 2; }
  /* iva: cols 5-6, riga 2 */
  #tblRighe tr.riga-prodotto > td:nth-child(8) { grid-column: 5 / span 2; grid-row: 2; }
  /* totale: col 8, spans 2 righe */
  #tblRighe tr.riga-prodotto > td:nth-child(9) {
    grid-column: 8; grid-row: 1 / span 2;
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
    font-size: 1rem;
  }
  /* del: col 9, spans 2 righe */
  #tblRighe tr.riga-prodotto > td:nth-child(10) {
    grid-column: 9; grid-row: 1 / span 2;
    display: flex; align-items: center; justify-content: center;
  }

  /* Etichetta mini sopra ogni campo (thead nascosto) */
  #tblRighe tr.riga-prodotto > td[data-label]::before {
    display: block;
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6c757d;
    margin-bottom: 2px;
  }

  /* Testo e separatore: flex semplice */
  #tblRighe tr.riga-testo,
  #tblRighe tr.riga-separatore {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #fff;
  }
  #tblRighe tr.riga-testo > td,
  #tblRighe tr.riga-separatore > td { border: none !important; padding: 2px 4px !important; }
  #tblRighe tr.riga-testo > td:first-child,
  #tblRighe tr.riga-separatore > td:first-child { flex: 0 0 auto; }
  #tblRighe tr.riga-testo > td:nth-child(2),
  #tblRighe tr.riga-separatore > td:nth-child(2) { flex: 1 1 auto; }
  #tblRighe tr.riga-testo > td:nth-child(3) { flex: 0 0 auto; }
  #tblRighe tr.riga-testo > td:last-child,
  #tblRighe tr.riga-separatore > td:last-child { flex: 0 0 auto; margin-left: auto; }
}

/* ================================================
   RIGHE PRODOTTO MOBILE/TABLET — preventivo_create
   Attivo fino a 991px (include tablet)
   ================================================ */
@media (max-width: 991.98px) {
  /* Il wrapper table-responsive non deve più scorrere */
  #tblRighe-wrap,
  .card-body .table-responsive:has(#tblRighe) { overflow-x: visible !important; }

  /* Nascondi intestazione tabella */
  #tblRighe thead { display: none !important; }

  /* Tabella e tbody diventano blocchi */
  #tblRighe,
  #tblRighe tbody { display: block !important; width: 100%; }

  /* Ogni riga prodotto diventa una card a 3 righe */
  #tblRighe tr.riga-prodotto {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--bs-body-bg, #fff);
    align-items: flex-start;
  }

  /* Rimuovi border e padding di default dalle celle */
  #tblRighe tr.riga-prodotto > td {
    border: none !important;
    padding: 0 !important;
  }

  /* 1 — Drag handle */
  #tblRighe tr.riga-prodotto > td:nth-child(1) {
    order: 1; flex: 0 0 auto;
    display: flex; align-items: center;
  }

  /* 2 — Immagine */
  #tblRighe tr.riga-prodotto > td:nth-child(2) {
    order: 2; flex: 0 0 auto;
    display: flex; align-items: center;
  }

  /* 10 — Bottone elimina: spinge a destra sulla prima riga */
  #tblRighe tr.riga-prodotto > td:nth-child(10) {
    order: 3; flex: 1 1 auto;
    display: flex; justify-content: flex-end; align-items: center;
  }

  /* Descrizione: piena larghezza */
  #tblRighe tr.riga-prodotto > td:nth-child(3) {
    order: 4; flex: 0 0 100%;
  }

  /* Label sopra ogni campo numerico */
  #tblRighe tr.riga-prodotto > td[data-label]::before {
    display: block;
    content: attr(data-label);
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: #6c757d; margin-bottom: 3px;
  }

  /* Riga 3: Q.tà | U.M. | Prezzo — Riga 4: Sc.% | IVA | Totale */
  #tblRighe tr.riga-prodotto > td:nth-child(4),
  #tblRighe tr.riga-prodotto > td:nth-child(5),
  #tblRighe tr.riga-prodotto > td:nth-child(6),
  #tblRighe tr.riga-prodotto > td:nth-child(7),
  #tblRighe tr.riga-prodotto > td:nth-child(8),
  #tblRighe tr.riga-prodotto > td:nth-child(9) {
    flex: 0 0 calc(33.333% - 6px);
    min-width: 0; box-sizing: border-box;
  }

  #tblRighe tr.riga-prodotto > td:nth-child(4) { order: 5; }
  #tblRighe tr.riga-prodotto > td:nth-child(5) { order: 6; }
  #tblRighe tr.riga-prodotto > td:nth-child(5) input { width: 100% !important; }
  #tblRighe tr.riga-prodotto > td:nth-child(6) { order: 7; }
  #tblRighe tr.riga-prodotto > td:nth-child(7) { order: 8; }
  #tblRighe tr.riga-prodotto > td:nth-child(8) { order: 9; }
  #tblRighe tr.riga-prodotto > td:nth-child(9) {
    order: 10; text-align: left !important;
    font-size: 1rem; font-weight: 700;
  }

  /* ── RIGA TESTO ── */
  #tblRighe tr.riga-testo {
    display: flex !important; flex-wrap: wrap; gap: 6px;
    border: 1px solid #dee2e6; border-radius: 10px;
    margin-bottom: 12px; padding: 8px 10px;
    background: var(--bs-body-bg, #fff); align-items: center;
  }
  #tblRighe tr.riga-testo > td { border: none !important; padding: 0 !important; }
  #tblRighe tr.riga-testo > td:nth-child(1) { order: 1; flex: 0 0 auto; }
  #tblRighe tr.riga-testo > td:nth-child(2) { order: 2; flex: 1 1 auto; }
  #tblRighe tr.riga-testo > td:nth-child(3) { display: none !important; }
  #tblRighe tr.riga-testo > td:nth-child(4) { order: 3; flex: 0 0 auto; }

  /* ── RIGA SEPARATORE ── */
  #tblRighe tr.riga-separatore {
    display: flex !important; gap: 6px;
    border: 1px solid #dee2e6; border-radius: 10px;
    margin-bottom: 12px; padding: 8px 10px;
    background: var(--bs-body-bg, #fff); align-items: center;
  }
  #tblRighe tr.riga-separatore > td { border: none !important; padding: 0 !important; }
  #tblRighe tr.riga-separatore > td:nth-child(1) { flex: 0 0 auto; }
  #tblRighe tr.riga-separatore > td:nth-child(2) { flex: 1 1 auto; }
  #tblRighe tr.riga-separatore > td:nth-child(3) { flex: 0 0 auto; }

  /* Bottoni aggiungi riga: wrap su schermi stretti */
  .card-header .btn-group { flex-wrap: wrap; gap: 4px; }
}

/* ================================================
   RACK CONFIGURATOR
   ================================================ */
.rack-enclosure {
  background: #f8fafc;
  border: 3px solid #475569;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0,0,0,.15);
  user-select: none;
  max-width: 300px;
}
.rack-enc-top {
  background: #334155;
  color: #e2e8f0;
  font-size: 9px;
  font-weight: 700;
  padding: 5px 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 2px solid #1e293b;
}
.rack-body-wrap {
  display: flex;
  align-items: stretch;
}
.rack-rail {
  width: 11px;
  background: linear-gradient(to bottom, #94a3b8, #7c8fa0, #94a3b8);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
  flex-shrink: 0;
}
.rack-hole {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #475569;
  margin: 4px 0;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.5);
  flex-shrink: 0;
}
.rack-slots-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
}
.rack-slot {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  cursor: pointer;
  position: relative;
  min-height: 26px;
  font-size: 11px;
  transition: filter .1s;
  border-bottom: 1px solid rgba(0,0,0,.07);
  overflow: hidden;
}
.rack-slot-empty {
  background: #f1f5f9;
  color: #94a3b8;
}
.rack-slot-empty:hover { background: #dbeafe; color: #3b82f6; }
.rack-slot-occ:hover { filter: brightness(1.08); }
.rack-u-label {
  font-size: 8px;
  font-weight: 700;
  min-width: 14px;
  opacity: .7;
  font-variant-numeric: tabular-nums;
  color: inherit;
  flex-shrink: 0;
}
.rack-dev-name {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rack-dev-type {
  font-size: 8px;
  opacity: .8;
  white-space: nowrap;
}
.rack-empty-label { font-size: 9px; }
.rack-enc-bottom {
  background: #334155;
  height: 8px;
  border-top: 2px solid #1e293b;
}
.rack-del-btn {
  position: absolute;
  right: 3px;
  top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.25) !important;
  border: none !important;
  color: #fff !important;
  width: 16px; height: 16px;
  border-radius: 3px;
  font-size: 10px; line-height: 1;
  cursor: pointer; opacity: 0;
  padding: 0 !important;
  display: flex; align-items: center; justify-content: center;
}
.rack-slot-occ:hover .rack-del-btn { opacity: 1; }
@media (max-width: 991.98px) {
  .rack-del-btn { opacity: .7 !important; }
}

/* Evita zoom su input iOS (font-size ≥ 16px) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }
}
