/* ============================================================
   BluAu Inventory — style.css
   Vanilla CSS: sidebar, dashboard, accordion inventory, modals,
   toasts, orders, DDT print layout.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

* {
  font-family: "Poppins", sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.material-symbols-outlined {
  font-family: "Material Symbols Outlined" !important;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

:root {
  --body-color: #eef1f6;
  --sidebar-color: #ffffff;
  --surface: #ffffff;
  --primary: #695cfe;
  --primary-light: #f6f5ff;
  --primary-dark: #5549e0;
  --toggle-color: #dddddd;
  --text-color: #4b5563;
  --muted: #9aa3af;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --row-hover: #f3f4f8;
  --tran-02: all 0.2s ease;
  --tran-03: all 0.3s ease;
}

body.dark {
  --body-color: #18191a;
  --sidebar-color: #242526;
  --surface: #242526;
  --primary: #5a52e6;
  --primary-light: #2e2f30;
  --primary-dark: #7c76f2;
  --toggle-color: #3a3b3c;
  --text-color: #d4d6da;
  --muted: #8a8f98;
  --border: #3a3b3c;
  --success-bg: #173a24;
  --danger-bg: #442020;
  --warning-bg: #3d3313;
  --row-hover: #2b2c2e;
}

html,
body {
  height: 100%;
}

body {
  background: var(--body-color);
  color: var(--text-color);
  transition: var(--tran-02);
  font-size: 15px;
}

button {
  cursor: pointer;
  font-size: 14px;
  border: none;
  background: none;
  color: inherit;
}

input,
select,
textarea {
  font-size: 14px;
  color: var(--text-color);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: var(--tran-02);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(105, 92, 254, 0.15);
}

.hidden {
  display: none !important;
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 250px;
  padding: 12px 14px;
  background: var(--sidebar-color);
  transition: var(--tran-03);
  z-index: 100;
  border-right: 1px solid var(--border);
}

.sidebar.close {
  width: 88px;
}

.sidebar.close .text {
  opacity: 0;
  pointer-events: none;
}

/* Collapsed sidebar: hide the sun/moon icons too (only the switch stays) */
.sidebar.close .mode .moon-sun {
  opacity: 0;
  pointer-events: none;
}

.sidebar header {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar .image {
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar .image img {
  width: 44px;
  border-radius: 8px;
}

.sidebar .header-text {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}

.sidebar .header-text .name {
  font-weight: 600;
  color: var(--text-color);
}

.sidebar .header-text .profession {
  font-weight: 300;
  font-size: 12px;
  color: var(--muted);
}

.sidebar header .toggle {
  position: absolute;
  top: 50%;
  right: -26px;
  transform: translateY(-50%);
  height: 25px;
  width: 25px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.sidebar.close header .toggle {
  transform: translateY(-50%) rotate(180deg);
}

.sidebar .menu-bar {
  height: calc(100% - 60px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-top: 20px;
}

.sidebar li {
  height: 50px;
  list-style: none;
  display: flex;
  align-items: center;
  margin-top: 8px;
}

.sidebar li a {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-color);
  border-radius: 8px;
  transition: var(--tran-02);
  padding-left: 5px;
}

.sidebar li a:hover {
  background: var(--primary-light);
}

/* Current page: highlight the link inside the active nav item */
.sidebar li.active a {
  background: var(--primary);
  color: #fff;
}

.sidebar li.active a .icon,
.sidebar li.active a .text {
  color: #fff;
}

.sidebar li .icon {
  min-width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.sidebar .text {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--tran-03);
}

.menu-bar .mode {
  border-radius: 8px;
  background: var(--primary-light);
  position: relative;
}

.menu-bar .mode .moon-sun {
  height: 50px;
  width: 60px;
  position: relative;
  transition: var(--tran-03);
}

/* Sun and moon occupy the exact same spot: only opacity switches,
   so nothing shifts over the mode text. */
.menu-bar .mode .moon-sun .icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  transition: var(--tran-03);
}

.menu-bar .mode .sun {
  opacity: 0;
}

body.dark .menu-bar .mode .sun {
  opacity: 1;
}

body.dark .menu-bar .mode .moon {
  opacity: 0;
}

.menu-bar .mode .toggle-switch {
  position: absolute;
  right: 0;
  height: 100%;
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--primary-light);
  border-radius: 8px;
}

.toggle-switch .switch {
  position: relative;
  height: 22px;
  width: 44px;
  border-radius: 25px;
  background: var(--toggle-color);
  transition: var(--tran-03);
}

.switch::before {
  content: "";
  position: absolute;
  height: 15px;
  width: 15px;
  border-radius: 50%;
  top: 50%;
  left: 5px;
  transform: translateY(-50%);
  background: #fff;
  transition: var(--tran-03);
}

body.dark .switch::before {
  left: 24px;
}

/* ============ MAIN LAYOUT ============ */
.home {
  position: relative;
  left: 250px;
  width: calc(100% - 250px);
  min-height: 100vh;
  padding: 24px 32px;
  transition: var(--tran-03);
}

.sidebar.close ~ .home {
  left: 88px;
  width: calc(100% - 88px);
}

.page-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title .material-symbols-outlined {
  color: var(--primary);
}

/* ============ TOOLBAR ============ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box .material-symbols-outlined {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 20px;
}

.search-box input {
  width: 100%;
  padding-left: 38px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  transition: var(--tran-02);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-color);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn:active {
  transform: scale(0.97);
}

/* ============ INVENTORY TABLE (accordion) ============ */
.panel {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Shared header style: main grid and nested detail grid */
.inventory-table th,
.nested-table th {
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

/* Main grid columns:
   ID | Nome | Categoria | Fornitore | Barcode | Furgone | Magazzino | Modifica */
.inv-grid > thead > tr > th:nth-child(1) { width: 10%; }
.inv-grid > thead > tr > th:nth-child(2) { width: 18%; }
.inv-grid > thead > tr > th:nth-child(3) { width: 13%; }
.inv-grid > thead > tr > th:nth-child(4) { width: 15%; }
.inv-grid > thead > tr > th:nth-child(5) { width: 13%; }
.inv-grid > thead > tr > th:nth-child(6) { width: 10%; }
.inv-grid > thead > tr > th:nth-child(7) { width: 10%; }
.inv-grid > thead > tr > th:nth-child(8) { width: 11%; }

/* Main grid alignment: barcode + action columns centered, quantities right */
.inv-grid > thead > tr > th:nth-child(5),
.inv-grid > thead > tr > th:nth-child(8) {
  text-align: center;
}

.inv-grid > thead > tr > th:nth-child(6),
.inv-grid > thead > tr > th:nth-child(7) {
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* DDT history table: 5 columns, spacing identical to the inventory grid */
.ddt-history-table > thead > tr > th:nth-child(1) { width: 14%; }
.ddt-history-table > thead > tr > th:nth-child(2) { width: 14%; }
.ddt-history-table > thead > tr > th:nth-child(3) { width: 48%; }
.ddt-history-table > thead > tr > th:nth-child(4) { width: 12%; }
.ddt-history-table > thead > tr > th:nth-child(5) { width: 12%; }

/* All DDT list columns are left-aligned (headers and cells) */
.ddt-history-table > thead > tr > th,
.ddt-history-table > tbody > tr > td {
  text-align: left;
}

/* Keep the action icon aligned with the text column edge */
.ddt-history-table .row-actions {
  justify-content: flex-start;
}

.ddt-history-table > tbody > tr {
  transition: var(--tran-02);
}

.ddt-history-table > tbody > tr:hover td {
  background: var(--row-hover);
}

.product-row {
  cursor: pointer;
  transition: var(--tran-02);
}

.product-row:hover td {
  background: var(--row-hover);
}

/* Shared cell style: applies to every .inventory-table variant
   (inventory grid, DDT history, ...) plus the nested detail grid */
.inventory-table > tbody > tr > td,
.nested-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-row .p-name {
  font-weight: 500;
}

.product-row .p-supplier {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.badge-none {
  background: var(--toggle-color);
  color: var(--muted);
}

.qty-cell {
  text-align: right;
  font-weight: 600;
}

/* Split quantity cells: van (Furgone) + in-house (Magazzino), inline editable */
.qty-split {
  padding: 6px 8px;
}

.qty-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: right;
  padding: 4px 6px;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: var(--tran-02);
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-input:hover {
  border-color: var(--border);
  background: var(--surface);
}

.qty-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* ============ CATEGORY CELL + MULTI-SELECT PICKER ============ */
.cat-cell {
  cursor: pointer;
  position: relative;
}

.cat-cell-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.cat-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
}

.cat-chip {
  display: inline-block;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
}

.cat-chip-more {
  background: var(--toggle-color);
  color: var(--muted);
  flex-shrink: 0;
}

.cat-empty {
  color: var(--muted);
  font-size: 13px;
}

.cat-cell-icon {
  font-size: 18px;
  color: var(--muted);
  flex-shrink: 0;
  transition: var(--tran-02);
}

.cat-cell:hover .cat-cell-icon {
  color: var(--primary);
}

.cat-picker {
  position: fixed;
  z-index: 350;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
}

.cat-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.cat-picker-close {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.cat-picker-close .material-symbols-outlined {
  font-size: 18px;
}

.cat-picker-search,
.cat-new-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
}

.cat-picker-list {
  overflow-y: auto;
  max-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--tran-02);
}

.cat-option:hover {
  background: var(--primary-light);
}

.cat-option.renaming {
  background: var(--primary-light);
  cursor: default;
}

.cat-option-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  transition: var(--tran-02);
}

.cat-option:hover .cat-option-actions,
.cat-option.renaming .cat-option-actions {
  opacity: 1;
}

.cat-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--muted);
  transition: var(--tran-02);
}

.cat-mini-btn .material-symbols-outlined {
  font-size: 16px;
}

.cat-mini-btn:hover {
  background: var(--surface);
  color: var(--primary);
}

.cat-mini-btn.danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.cat-mini-btn.ok:hover {
  color: var(--success);
}

.cat-rename-input {
  flex: 1;
  min-width: 0;
  padding: 3px 8px;
  font-size: 13px;
}

.cat-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.cat-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-picker-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.cat-picker-new {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.cat-new-btn {
  padding: 6px 10px;
  flex-shrink: 0;
}

.cat-new-btn .material-symbols-outlined {
  font-size: 18px;
}

.qty-zero {
  color: var(--danger);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  transition: var(--tran-02);
}

.icon-btn:hover {
  background: var(--primary);
  color: #fff;
}

.icon-btn.minus {
  background: var(--warning-bg);
  color: var(--warning);
}

.icon-btn.minus:hover {
  background: var(--warning);
  color: #fff;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

/* Accordion detail row: only the direct wrapper cell gets the panel
   background and vertical-only padding; nested cells keep the shared
   12px 14px cell padding. */
.detail-row > td {
  background: var(--primary-light) !important;
  padding: 10px 0 16px !important;
}

/* The nested grid columns are exactly as wide as the parent's first five
   columns, laid out consecutively (no spacer column):
   N. fattura ↔ ID (10%), Data Acquisto ↔ Nome Prodotto (18%),
   Prezzo Unitario ↔ Categoria (13%), Q.tà Iniziale ↔ Fornitore (15%),
   Q.tà Residua ↔ Codice a Barre (13%). Total span: 69% of the table. */
.nested-table {
  width: 69%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Widths scaled from 10 / 18 / 13 / 15 / 13 over their sum (69). */
.nested-table th:nth-child(1) { width: 14.493%; }
.nested-table th:nth-child(2) { width: 26.087%; }
.nested-table th:nth-child(3) { width: 18.841%; }
.nested-table th:nth-child(4) { width: 21.739%; }
.nested-table th:nth-child(5) { width: 18.841%; }

/* Cell text alignment mirrors the parent column it sits under:
   ID / Nome Prodotto / Category / Fornitore are left-aligned,
   Codice a Barre is centered. */
.nested-table th,
.nested-table td {
  text-align: left;
}

.nested-table th:nth-child(5),
.nested-table td:nth-child(5) {
  text-align: center;
}

.nested-table tbody tr:last-child td {
  border-bottom: none;
}

.nested-table .residual-empty {
  color: var(--success);
  font-weight: 600;
}

/* Legacy (invoice-less) stock rows */
.legacy-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--warning-bg);
  color: var(--warning);
}

.nested-table .nested-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: none;
}

/* Nested batch table only: every font is 2pt smaller than in the parent table.
   13px = 9.75pt → 7.75pt  ·  15px = 11.25pt → 9.25pt  ·  11px = 8.25pt → 6.25pt */
.nested-table th {
  font-size: 7.75pt;
}

.nested-table td,
.nested-table .nested-empty {
  font-size: 9.25pt;
}

.nested-table .legacy-badge {
  font-size: 6.25pt;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 4px 0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-sm .material-symbols-outlined {
  font-size: 18px;
}

.modal-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.45;
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state .material-symbols-outlined {
  font-size: 42px;
  margin-bottom: 10px;
  color: var(--toggle-color);
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: modal-in 0.18s ease;
}

.modal.modal-lg {
  max-width: 720px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  font-size: 22px;
  color: var(--muted);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--muted);
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
}

/* Pairing modal product list */
.pair-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.pair-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--tran-02);
  text-align: left;
}

.pair-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.pair-item .info {
  flex: 1;
  min-width: 0;
}

.pair-item .name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pair-item .sub {
  font-size: 12px;
  color: var(--muted);
}

/* ============ TOASTS ============ */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 400;
}

.toast {
  min-width: 280px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast .material-symbols-outlined {
  font-size: 22px;
}

.toast.success .material-symbols-outlined { color: var(--success); }
.toast.error .material-symbols-outlined { color: var(--danger); }
.toast.warning .material-symbols-outlined { color: var(--warning); }

/* ============ ORDERS (invoices) ============ */
.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: var(--tran-02);
  position: relative;
  overflow: hidden;
}

.order-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--muted);
}

.order-card.completed::before {
  background: var(--success);
}

.order-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.order-card .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.order-card .inv-number {
  font-weight: 600;
  font-size: 16px;
}

.status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.status-pill.active {
  background: var(--toggle-color);
  color: var(--muted);
}

.status-pill.completed {
  background: var(--success-bg);
  color: var(--success);
}

.order-card .supplier {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.order-card .bottom {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

/* Supplier cards: same card as Ordini, plus a switch and row actions */
.order-card.external::before {
  background: var(--warning);
}

.order-card.supplier-card {
  cursor: default;
}

.supplier-card .top {
  align-items: flex-start;
  gap: 8px;
}

.supplier-card .inv-number {
  line-height: 1.3;
}

.supplier-card .status-pill {
  flex: none;
  white-space: nowrap;
}

.order-card.supplier-card.excluded::before {
  background: var(--warning);
}

.status-pill.external {
  background: var(--warning-bg);
  color: var(--warning);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.card-icons {
  display: flex;
  gap: 2px;
}

.inv-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--muted);
}

.inv-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.inv-switch .inv-slider {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--toggle-color);
  transition: var(--tran-02);
}

.inv-switch .inv-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: var(--tran-02);
}

.inv-switch input:checked + .inv-slider {
  background: var(--success);
}

.inv-switch input:checked + .inv-slider::after {
  transform: translateX(16px);
}

.inv-switch input:focus-visible + .inv-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.inv-switch .inv-switch-text {
  font-weight: 600;
  color: var(--text-color);
}

.inv-switch.inv-switch-block {
  margin-top: 4px;
}

.muted-dash {
  color: var(--muted);
}

.inv-note {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 13px;
}

/* Invoice detail table */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.detail-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-table td {
  padding: 8px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.detail-table tr:last-child td {
  border-bottom: none;
}

/* Invoice line inline editing */
.invoice-lines .edit-col {
  width: 44px;
  text-align: center;
}

.invoice-lines tr.editing td {
  background: var(--primary-light);
  vertical-align: middle;
}

.invoice-lines .line-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 13px;
}

.invoice-lines .line-qty {
  width: 72px;
}

.invoice-lines .unit-preview {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.invoice-lines .row-actions {
  gap: 4px;
}

.invoice-lines .icon-btn {
  width: 28px;
  height: 28px;
}

.invoice-lines .icon-btn .material-symbols-outlined {
  font-size: 17px;
}

.invoice-lines .save-line {
  background: var(--success-bg);
  color: var(--success);
}

.invoice-lines .save-line:hover {
  background: var(--success);
  color: #fff;
}

.invoice-lines .cancel-line:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============ DDT PRINT DOCUMENT (A4, 4-column grid) ============ */
.ddt-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

/* Screen preview: A4 proportions at 96 dpi */
.ddt-a4 {
  background: #fff;
  color: #111;
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  padding: 30px 32px;
  font-size: 8pt; /* minimum readable size per spec */
  line-height: 1.25;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.ddt-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1.5px solid #111;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.ddt-box {
  min-width: 0;
}

.ddt-box-title {
  font-weight: 700;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.ddt-company {
  font-weight: 700;
}

/* Causale starts at 50%, exactly under the Destinatario block */
.ddt-meta {
  display: grid;
  grid-template-columns: 30% 20% 1fr;
  margin-bottom: 8px;
}

/* Bold labels / company name */
.ddt-company,
.ddt-meta strong {
  font-weight: 700;
}

/* 2 parallel product tables side by side, separated by a small gap */
.ddt-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 8px;
  margin: 6px 0;
}

/* Each table is a self-contained grid with light gray (#CCCCCC) grid lines */
.ddt-col {
  min-width: 0;
  border: 1px solid #CCCCCC;
}

.ddt-col-head,
.ddt-col-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 24px;
}

.ddt-col-head {
  font-weight: 700;
  border-bottom: 1px solid #CCCCCC;
}

/* 2px cell padding + vertical grid lines between columns.
   Cell content is vertically centred inside each row. */
.ddt-col-head span,
.ddt-col-row span {
  padding: 2px;
  border-right: 1px solid #CCCCCC;
  display: flex;
  align-items: center;
  min-height: 15px;
}

.ddt-col-head span:last-child,
.ddt-col-row span:last-child {
  border-right: none;
}

.ddt-col-head span:nth-child(2),
.ddt-col-head span:nth-child(3),
.ddt-col-row .ddt-qty,
.ddt-col-row .ddt-um {
  justify-content: center;
}

/* Body text is 1pt smaller than the table headers */
.ddt-col-row {
  font-size: 7pt;
}

/* product name keeps its ellipsis while staying vertically centred */
.ddt-col-row .ddt-product {
  display: block;
  align-self: center;
}

/* Horizontal grid lines between rows */
.ddt-col-row {
  border-bottom: 1px solid #CCCCCC;
}

.ddt-col-row:last-child {
  border-bottom: none;
}

.ddt-product {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ddt-signatures {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-top: 16px;
  padding-top: 10px;
  font-size: 8pt;
}

/* Print: exact A4, minimal margins, single page */
@media print {
  .ddt-a4 {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
    font-size: 8pt;
  }
}

/* ============ PLACEHOLDER PAGE ============ */
.placeholder-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.placeholder-card .material-symbols-outlined {
  font-size: 44px;
  margin-bottom: 12px;
  color: var(--toggle-color);
}

/* ============ LOGIN PAGE ============ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.login-card img.logo {
  display: block;
  width: 84px;
  margin: 0 auto 18px;
  border-radius: 12px;
}

.login-card h1 {
  font-size: 20px;
  text-align: center;
  font-weight: 600;
  margin-bottom: 20px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
}

.login-card .alt {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.login-card .alt a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
  text-align: center;
}

/* ============ RESPONSIVE ============ */

/* ---------- Mobile top bar + drawer scrim (only < 768px) ---------- */
.mobile-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--sidebar-color);
  border-bottom: 1px solid var(--border);
  z-index: 120;
}

.mobile-bar .mb-menu {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-color);
}

.mobile-bar .mb-menu:hover {
  background: var(--primary-light);
}

.mobile-bar .mb-title {
  font-weight: 600;
  font-size: 15px;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 110;
}

.sidebar-scrim.show {
  display: block;
}

/* The horizontal scroll wrapper is transparent on large screens */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile-only "Dettagli / Lotti" chevron (rendered but hidden on desktop) */
.mobile-details {
  display: none;
}

.mobile-details .material-symbols-outlined {
  transition: transform 0.2s ease;
}

.mobile-details.open .material-symbols-outlined {
  transform: rotate(180deg);
}

/* ---------- ≤ 1300px: tighten the table so 8 columns still breathe ---------- */
@media (max-width: 1300px) {
  .home,
  .sidebar.close ~ .home {
    padding: 20px;
  }

  .inventory-table th,
  .nested-table th {
    padding: 10px 10px;
    font-size: 12px;
    letter-spacing: 0.03em;
  }

  .inventory-table > tbody > tr > td,
  .nested-table td {
    padding: 10px;
    font-size: 14px;
  }

  .inv-grid > thead > tr > th:nth-child(6),
  .inv-grid > thead > tr > th:nth-child(7) {
    font-size: 10px;
  }

  .product-row .p-supplier {
    font-size: 12px;
  }

  .qty-split {
    padding: 4px 4px;
  }

  .qty-input {
    font-size: 14px;
    padding: 4px 2px;
  }
}

/* ---------- 768px – 1200px: icon rail + scrollable table with sticky
              primary columns (ID + Nome Prodotto) ---------- */
@media (max-width: 1200px) and (min-width: 768px) {
  .sidebar,
  .sidebar.close {
    width: 78px;
    padding: 12px 8px;
    overflow: hidden;
  }

  .sidebar .text,
  .sidebar.close .text {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar .mode .moon-sun,
  .sidebar.close .mode .moon-sun {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar .image {
    min-width: 54px;
  }

  .sidebar header .toggle {
    display: none;
  }

  .home,
  .sidebar.close ~ .home {
    left: 78px;
    width: calc(100% - 78px);
    padding: 18px 16px;
  }

  /* fixed widths so the sticky offsets stay exact while scrolling */
  .inv-grid {
    width: 998px;
    min-width: 998px;
  }

  .inv-grid > thead > tr > th:nth-child(1) { width: 104px; }
  .inv-grid > thead > tr > th:nth-child(2) { width: 210px; }
  .inv-grid > thead > tr > th:nth-child(3) { width: 160px; }
  .inv-grid > thead > tr > th:nth-child(4) { width: 134px; }
  .inv-grid > thead > tr > th:nth-child(5) { width: 130px; }
  .inv-grid > thead > tr > th:nth-child(6) { width: 90px; }
  .inv-grid > thead > tr > th:nth-child(7) { width: 100px; }
  .inv-grid > thead > tr > th:nth-child(8) { width: 70px; }

  /* the nested grid keeps mirroring the first five columns (104+210+160+134+130) */
  .nested-table {
    width: 738px;
  }

  .nested-table th:nth-child(1) { width: 14.092%; }
  .nested-table th:nth-child(2) { width: 28.455%; }
  .nested-table th:nth-child(3) { width: 21.680%; }
  .nested-table th:nth-child(4) { width: 18.157%; }
  .nested-table th:nth-child(5) { width: 17.616%; }

  .inv-grid > thead > tr > th:nth-child(1),
  .inv-grid .product-row > td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
  }

  .inv-grid > thead > tr > th:nth-child(2),
  .inv-grid .product-row > td:nth-child(2) {
    position: sticky;
    left: 104px;
    z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }

  .inv-grid > thead > tr > th:nth-child(1),
  .inv-grid > thead > tr > th:nth-child(2) {
    z-index: 3;
  }

  .inv-grid .product-row:hover > td:nth-child(1),
  .inv-grid .product-row:hover > td:nth-child(2) {
    background: var(--row-hover);
  }

  /* DDT history: never squeeze below a readable width */
  .ddt-history-table {
    min-width: 560px;
  }

  /* DDT preview keeps its A4 proportions and scrolls inside the page */
  #ddt-doc {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- < 768px: stacked product cards + slide-over drawer ---------- */
@media (max-width: 767px) {
  .mobile-bar {
    display: flex;
  }

  .sidebar,
  .sidebar.close,
  .sidebar.drawer-open {
    top: 58px;
    height: calc(100% - 58px);
    width: 264px;
    padding: 12px 14px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
    z-index: 115;
  }

  .sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  }

  .sidebar .text,
  .sidebar.close .text,
  .sidebar .mode .moon-sun,
  .sidebar.close .mode .moon-sun {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar header .toggle {
    display: none;
  }

  .home,
  .sidebar.close ~ .home {
    left: 0;
    width: 100%;
    padding: 74px 14px 28px;
  }

  .page-title {
    font-size: 21px;
    margin-bottom: 14px;
  }

  /* toolbar stacks, touch-friendly buttons */
  .toolbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .search-box {
    min-width: 100%;
    order: -1;
  }

  .search-box input {
    height: 44px;
  }

  .toolbar-actions {
    width: 100%;
    gap: 8px;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
  }

  .panel {
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .table-scroll {
    overflow: visible;
  }

  /* ---- table → cards ---- */
  .inv-grid {
    display: block;
    border-collapse: separate;
  }

  .inv-grid > thead {
    display: none;
  }

  .inv-grid > tbody {
    display: block;
  }

  .inv-grid > tbody[data-product] {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
  }

  .inv-grid tr.product-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 6px;
    padding: 14px;
    align-items: start;
  }

  .inv-grid .product-row > td {
    padding: 0;
    border: 0;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    min-width: 0;
  }

  .inv-grid .product-row > td::before {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
  }

  /* header: name (full width, padded clear of the action buttons) + ID */
  .inv-grid .product-row > td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-right: 100px;
  }

  .inv-grid .product-row > td:nth-child(1) { grid-column: 1 / -1; grid-row: 2; }
  .inv-grid .product-row > td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .inv-grid .product-row > td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .inv-grid .product-row > td:nth-child(5) { grid-column: 1 / -1; grid-row: 5; }
  .inv-grid .product-row > td:nth-child(6) { grid-column: 1; grid-row: 6; }
  .inv-grid .product-row > td:nth-child(7) { grid-column: 2; grid-row: 6; }

  /* action buttons float in the card's top-right corner */
  .inv-grid .product-row > td:nth-child(8) {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
  }

  .inv-grid .product-row > td:nth-child(2) .p-name {
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.25;
  }

  .inv-grid .product-row > td:nth-child(1) {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 500;
  }

  .inv-grid .product-row > td:nth-child(3)::before { content: "Categorie"; }
  .inv-grid .product-row > td:nth-child(4)::before { content: "Fornitore"; }
  .inv-grid .product-row > td:nth-child(5)::before { content: "Codice a barre"; }
  .inv-grid .product-row > td:nth-child(6)::before { content: "Furgone"; }
  .inv-grid .product-row > td:nth-child(7)::before { content: "Magazzino"; }

  .inv-grid .product-row > td:nth-child(4),
  .inv-grid .product-row > td:nth-child(6),
  .inv-grid .product-row > td:nth-child(7) {
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }

  .inv-grid .product-row > td:nth-child(5) {
    text-align: left !important;
  }

  .inv-grid .product-row > td:nth-child(5) .badge {
    font-size: 11.5px;
  }

  /* quantity controls: 44px tap targets, no iOS zoom */
  .qty-split {
    padding: 0 !important;
    text-align: left;
  }

  .qty-input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
    border-color: var(--border);
    background: var(--surface);
    text-align: left;
    padding: 6px 10px;
  }

  .cell-actions .row-actions {
    gap: 4px;
  }

  .cell-actions .icon-btn,
  .mobile-details {
    width: 44px;
    height: 44px;
  }

  .mobile-details {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* accordion inside the card */
  .inv-grid .detail-row {
    display: block;
  }

  .inv-grid .detail-row > td {
    display: block;
    padding: 0 14px 14px !important;
    background: transparent !important;
  }

  .inv-grid .detail-row [data-detail-body] {
    overflow: visible;
  }

  .nested-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nested-table {
    width: 100%;
    min-width: 540px;
  }

  .nested-table th {
    font-size: 9px;
    letter-spacing: 0.01em;
    padding: 8px 6px;
  }

  .nested-table td,
  .nested-table .nested-empty {
    font-size: 11.5px;
    padding: 8px 6px;
  }

  .nested-table .legacy-badge {
    font-size: 10px;
  }

  .detail-actions {
    padding: 10px 0 0;
  }

  .detail-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* ---- DDT history: table → cards ---- */
  .ddt-history-table {
    display: block;
    min-width: 0;
  }

  .ddt-history-table > thead {
    display: none;
  }

  .ddt-history-table > tbody {
    display: block;
  }

  .ddt-history-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num    actions"
      "date   actions"
      "dest   dest"
      "units  units";
    row-gap: 6px;
    column-gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
  }

  .ddt-history-table > tbody > tr:hover td {
    background: transparent;
  }

  .ddt-history-table > tbody > tr > td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: left;
  }

  .ddt-history-table > tbody > tr > td::before {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
  }

  .ddt-history-table .ddt-num {
    grid-area: num;
    font-size: 15.5px;
  }

  .ddt-history-table .ddt-date {
    grid-area: date;
    color: var(--muted);
    font-size: 13px;
  }

  .ddt-history-table .ddt-dest {
    grid-area: dest;
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }

  .ddt-history-table .ddt-dest::before {
    content: "Destinatario";
  }

  .ddt-history-table .ddt-units {
    grid-area: units;
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-weight: 600;
  }

  .ddt-history-table .ddt-units::before {
    content: "Unità";
    display: inline;
    margin: 0;
  }

  .ddt-history-table .ddt-actions {
    grid-area: actions;
  }

  .ddt-history-table .ddt-actions .icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ---- DDT document: A4 preview reflows to a single column ---- */
  #ddt-doc {
    overflow: visible;
  }

  .ddt-toolbar {
    gap: 8px;
    margin-bottom: 14px;
  }

  .ddt-toolbar .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
  }

  .ddt-a4 {
    width: 100%;
    min-height: 0;
    padding: 18px 16px;
    box-shadow: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 9pt;
  }

  .ddt-top {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  .ddt-meta {
    grid-template-columns: 1fr;
    row-gap: 4px;
  }

  .ddt-columns {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  .ddt-col-head,
  .ddt-col-row {
    grid-template-columns: minmax(0, 1fr) 40px 26px;
  }

  .ddt-col-head span,
  .ddt-col-row span {
    min-height: 22px;
  }

  .ddt-col-row {
    font-size: 8pt;
  }

  .ddt-product {
    white-space: normal;
    text-overflow: clip;
  }

  .ddt-signatures {
    flex-direction: column;
    gap: 14px;
  }
}

/* ============ PRINT ============ */
@media print {
  body {
    background: #fff !important;
  }

  .sidebar,
  .home > .page-title,
  .ddt-toolbar,
  .toast-stack,
  .modal-backdrop {
    display: none !important;
  }

  .home {
    left: 0 !important;
    width: 100% !important;
    padding: 0 !important;
  }

  @page {
    size: A4;
    margin: 8mm;
  }
}

/* Printing from a narrow viewport must still produce the A4 document,
   so these rules win over the mobile reflow above. */
@media print {
  .ddt-a4 {
    width: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-size: 8pt !important;
  }

  .ddt-top {
    grid-template-columns: 1fr 1fr !important;
    row-gap: 0 !important;
  }

  .ddt-meta {
    grid-template-columns: 30% 20% 1fr !important;
    row-gap: 0 !important;
  }

  .ddt-columns {
    grid-template-columns: repeat(2, 1fr) !important;
    row-gap: 0 !important;
  }

  .ddt-col-head,
  .ddt-col-row {
    grid-template-columns: minmax(0, 1fr) 36px 24px !important;
  }

  .ddt-col-head span,
  .ddt-col-row span {
    min-height: 15px !important;
  }

  .ddt-col-row {
    font-size: 7pt !important;
  }

  .ddt-product {
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }

  .ddt-signatures {
    flex-direction: row !important;
    gap: 40px !important;
  }

  #ddt-doc {
    overflow: visible !important;
  }
}