/* ===========================
   Gestor - Components CSS
   =========================== */

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  height: var(--control-h);
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: var(--font);
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { height: auto; resize: vertical; min-height: 100px; }

/* Password field: eye toggle + strength meter */
.pw-wrap { position: relative; }
.pw-wrap > .form-control { padding-right: 42px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; color: var(--text-muted);
  padding: 6px; display: flex; align-items: center; border-radius: var(--radius-sm);
}
.pw-eye:hover { color: var(--text); }
.pw-eye svg { width: 18px; height: 18px; }
.pw-meter { margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.pw-meter-track { flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.pw-meter-fill { height: 100%; width: 0; border-radius: 99px; transition: width .25s ease, background-color .25s ease; }
.pw-meter-label { font-size: .72rem; font-weight: 700; min-width: 54px; text-align: right; }
.pw-match-msg { font-size: .75rem; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.pw-match-msg svg { width: 14px; height: 14px; }
.pw-match-msg.is-ok  { color: var(--success); }
.pw-match-msg.is-bad { color: var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-full { grid-column: 1 / -1; }

/* Switcher / Toggle */
.switcher { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switcher input { display: none; }
.switcher-track {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.switcher-track::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switcher input:checked + .switcher-track { background: var(--primary); }
.switcher input:checked + .switcher-track::after { transform: translateX(20px); }
.switcher-label { font-size: .875rem; font-weight: 500; color: var(--text); }

/* File Upload */
.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.file-upload-zone:hover, .file-upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.file-upload-icon { margin-bottom: 8px; line-height: 0; color: var(--text-light); }
.file-upload-icon svg { width: 40px; height: 40px; }
.file-upload-text { font-size: .875rem; color: var(--text-muted); }
.file-upload-text strong { color: var(--primary); }
.file-upload-hint { font-size: .75rem; color: var(--text-light); margin-top: 4px; }

/* Select */
.form-select {
  width: 100%;
  height: var(--control-h);
  padding: 9px 36px 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  font-family: var(--font);
}
.form-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--focus-ring); }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 14px 16px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }

.table-actions { display: flex; gap: 4px; justify-content: flex-end; }
/* Action column (last) right-aligned in every list, so buttons/headers line up consistently */
table th:last-child, table td:last-child { text-align: right; }
/* Exception: tables whose last column is data (text/time), not actions */
table.last-col-data th:last-child, table.last-col-data td:last-child { text-align: left; }

/* Assignment tables (collaborator detail): fixed equal columns so the 3 tables line up vertically */
.assign-tbl { table-layout: fixed; }
.assign-tbl th:nth-child(1), .assign-tbl td:nth-child(1) { width: 30%; }
.assign-tbl th:nth-child(2), .assign-tbl td:nth-child(2) { width: 24%; }
.assign-tbl th:nth-child(3), .assign-tbl td:nth-child(3) { width: 24%; }
.assign-tbl th:nth-child(4), .assign-tbl td:nth-child(4) { width: 22%; }
.assign-tbl td a, .assign-tbl td code { overflow: hidden; text-overflow: ellipsis; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-success  { background: var(--success-bg);  color: #065F46; }
.badge-warning  { background: var(--warning-bg);  color: #92400E; }
.badge-danger   { background: var(--danger-bg);   color: #991B1B; }
.badge-info     { background: var(--info-bg);     color: #1E40AF; }
.badge-default  { background: #F3F4F6; color: var(--text-muted); }
.badge-purple   { background: var(--primary-light); color: var(--primary); }

/* ── Alerts ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: var(--danger-bg);  color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-bg); color: #92400E; border: 1px solid #FDE68A; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;                 /* modal centred via margin:auto */
  overflow-y: auto;             /* the OVERLAY scrolls, not the modal */
  overflow-x: hidden;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  margin: auto;   /* centres in the flex overlay; degrades to top-aligned (no clip) when tall */
  /* No max-height/overflow/transform here: the modal must not clip its own popups
     (date picker / searchable select). The overlay scrolls instead. */
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 800px; }

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  /* No sticky/background here: the overlay scrolls (not the modal), and a header
     background would paint over the modal's rounded top corners. */
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.modal-body { padding: 20px 24px; }
/* Some forms (departments/collaborators/users) wrap themselves in a .card so they
   also work as a standalone page. Inside a modal that produces a redundant
   card-in-card; flatten it so it matches the other modals. */
.modal-body > .card { border: none; box-shadow: none; background: transparent; max-width: none !important; }
.modal-body > .card > .card-body { padding: 0; }

/* ── Timeline Notes ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content:''; position:absolute; left:8px; top:0; bottom:0; width:2px; background:var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content:''; position:absolute;
  left: -20px; top: 6px;
  width: 10px; height: 10px;
  background: var(--primary); border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-meta { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.timeline-body {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .875rem;
  color: var(--text);
}

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  padding: 0 10px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.page-btn.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state svg { width: 64px; height: 64px; color: var(--border); margin: 0 auto 16px; display: block; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 8px; }
.empty-state p { font-size: .875rem; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar .form-control,
.filter-bar .form-select,
.filter-bar .ss { width: auto; flex: 1; min-width: 160px; max-width: 260px; }
.filter-bar .ss { flex: 0 1 260px; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Detail View ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 4px; }
.detail-value { font-size: .9rem; color: var(--text); font-weight: 500; }

/* ── 2FA Setup ── */
.qr-container { text-align: center; padding: 20px; background: var(--bg); border-radius: var(--radius-lg); margin: 16px 0; }
.qr-container img, .qr-container canvas { max-width: 200px; }

/* Responsive: blocos @media movidos para o FIM do ficheiro (senão as regras base
   definidas mais abaixo venciam-nos por ordem de origem — mesma especificidade). */

/* ── Utilities ── */
.btn-xs { height: auto; padding: 2px 8px; font-size: .72rem; }
.form-actions { display:flex; gap:12px; justify-content:flex-end; align-items:center; margin-top:24px; padding-top:16px; border-top:1px solid var(--border); }
.detail-layout { display:grid; grid-template-columns: 1fr 320px; gap:24px; align-items:start; }
.two-col { display:grid; grid-template-columns: 1fr 1fr; gap:24px; }
.avatar { width:40px; height:40px; border-radius:50%; background:var(--primary); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-weight:700; line-height:1; flex-shrink:0; }
.avatar-lg { width:64px; height:64px; font-size:1.25rem; }
.avatar-sm { width:28px; height:28px; font-size:.72rem; }
.card-title { font-size:1.05rem; font-weight:600; margin-bottom:16px; }

/* ── Searchable Select (progressive enhancement of .form-select) ── */
.ss { position: relative; width: 100%; }
/* native <select> kept in the DOM for submission, visually hidden */
.ss-native { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); border:0; opacity:0; pointer-events:none; }
.ss-toggle {
  width:100%; text-align:left; cursor:pointer; min-height:var(--control-h);
  padding:9px 36px 9px 14px;
  border:1.5px solid var(--border); border-radius:var(--radius);
  font-size:.9rem; color:var(--text); background:var(--surface); font-family:var(--font);
  display:flex; align-items:center; flex-wrap:wrap; gap:4px;
  transition:border-color var(--transition), box-shadow var(--transition);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center;
}
.ss-toggle:focus { outline:none; }
.ss.open .ss-toggle, .ss-toggle:focus-visible { border-color:var(--border-focus); box-shadow:0 0 0 3px var(--focus-ring); }
.ss-toggle.is-placeholder { color:var(--text-light); }
.ss-tag { background:var(--primary-light); color:var(--primary); border-radius:99px; padding:2px 8px; font-size:.72rem; font-weight:600; }
.ss-panel {
  display:none; position:absolute; left:0; right:0; top:calc(100% + 4px); z-index:1100;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow-lg); overflow:hidden;
}
.ss-panel.open { display:block; }
.ss-search { padding:8px; border-bottom:1px solid var(--border); }
.ss-search input {
  width:100%; padding:8px 12px; border:1.5px solid var(--border); border-radius:var(--radius-sm);
  font-size:.85rem; outline:none; color:var(--text); background:var(--surface); font-family:var(--font);
}
.ss-search input:focus { border-color:var(--border-focus); box-shadow:0 0 0 3px var(--focus-ring); }
.ss-options { max-height:240px; overflow-y:auto; padding:4px; }
.ss-option {
  padding:8px 12px; border-radius:var(--radius-sm); font-size:.875rem; color:var(--text);
  cursor:pointer; display:flex; align-items:center; gap:8px;
}
.ss-option:hover, .ss-option.active { background:var(--primary-light); color:var(--primary); }
.ss-option[aria-selected="true"] { font-weight:600; color:var(--primary); }
.ss:not(.ss--multi) .ss-option[aria-selected="true"]::after { content:'✓'; margin-left:auto; font-weight:700; }
.ss-check { width:16px; height:16px; border:1.5px solid var(--border); border-radius:4px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center; font-size:.7rem; color:transparent; }
.ss-option[aria-selected="true"] .ss-check { background:var(--primary); border-color:var(--primary); color:#fff; }
.ss-empty { padding:14px 12px; text-align:center; color:var(--text-light); font-size:.82rem; }

/* ── Date Picker (calendar) ── */
.dp { position:relative; width:100%; }
.dp-native { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); border:0; }
.dp-field {
  width:100%; height:var(--control-h); display:flex; align-items:center; gap:8px; cursor:pointer;
  padding:9px 12px 9px 14px; border:1.5px solid var(--border); border-radius:var(--radius);
  background:var(--surface); color:var(--text); font-size:.9rem; font-family:var(--font);
  transition:border-color var(--transition), box-shadow var(--transition);
}
.dp.open .dp-field { border-color:var(--border-focus); box-shadow:0 0 0 3px var(--focus-ring); }
.dp-field .dp-icon { color:var(--text-muted); flex-shrink:0; display:flex; }
.dp-field .dp-icon svg { width:16px; height:16px; }
.dp-input { flex:1; min-width:0; border:none; outline:none; background:none; font:inherit; color:var(--text); padding:0; }
.dp-input::placeholder { color:var(--text-light); }
.dp-clear { border:none; background:none; cursor:pointer; color:var(--text-light); font-size:1.1rem; line-height:1; padding:0 2px; display:none; }
.dp-clear:hover { color:var(--danger); }
.dp.has-value .dp-clear { display:block; }
.dp-panel {
  display:none; position:absolute; left:0; top:calc(100% + 4px); z-index:1100;
  width:300px; max-width:92vw; padding:14px;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
}
.dp-panel.open { display:block; }
.dp-head { display:flex; align-items:center; gap:6px; margin-bottom:10px; }
.dp-selects { display:flex; gap:6px; flex:1; min-width:0; }
.dp-selects .ss { flex:1; min-width:0; }
/* compact the searchable-dropdown toggle inside the calendar header */
.dp-selects .ss-toggle { min-height:34px; padding:6px 30px 6px 10px; font-size:.85rem; font-weight:600; }
/* No search box for the month/year dropdowns inside the date picker (only here) */
.dp-selects .ss-search { display:none; }
.dp-nav { width:30px; height:30px; border:none; background:none; border-radius:var(--radius-sm); cursor:pointer; color:var(--text-muted); display:flex; align-items:center; justify-content:center; }
.dp-nav:hover { background:var(--bg); color:var(--text); }
.dp-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.dp-wd { text-align:center; font-size:.7rem; font-weight:700; color:var(--text-light); padding:4px 0; text-transform:uppercase; }
.dp-day { aspect-ratio:1; display:flex; align-items:center; justify-content:center; border-radius:50%; cursor:pointer; font-size:.85rem; color:var(--text); }
.dp-day:hover { background:var(--primary-light); color:var(--primary); }
.dp-day.empty { visibility:hidden; cursor:default; }
.dp-day.today { background:var(--danger); color:#fff; font-weight:600; }
.dp-day.selected { background:var(--primary); color:#fff; font-weight:700; }

/* ── Matrícula (estilo chapa portuguesa) ───────────────── */
.plate {
  display: inline-flex; align-items: stretch; height: 40px;
  background: #fff; border: 2px solid #111; border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.18); vertical-align: middle; line-height: 1;
}
.plate-eu { height: 100%; width: auto; display: block; }
.plate-num {
  display: flex; align-items: center; justify-content: center; padding: 0 14px; white-space: nowrap;
  min-width: 112px; /* largura fixa: não encolhe/cresce com o conteúdo */
  font-family: 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800; font-size: 22px; letter-spacing: 1.5px; color: #111;
}
.plate-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #F4B400; color: #111; padding: 0 7px; min-width: 28px;
  font-family: Arial, sans-serif; font-weight: 800; font-size: 10px; line-height: 1.1;
}
.plate-date span:first-child { border-bottom: 1.5px solid #111; padding-bottom: 1px; }
.plate-date span:last-child  { padding-top: 1px; }
/* Variante pequena (tabelas/listas) */
.plate-sm { height: 30px; border-width: 1.5px; border-radius: 5px; }
.plate-sm .plate-num  { font-size: 16px; padding: 0 9px; letter-spacing: 1px; min-width: 84px; }
.plate-sm .plate-date { font-size: 8px; min-width: 21px; padding: 0 4px; }
/* Variante grande (pré-visualização em formulários) */
.plate-lg { height: 54px; border-width: 2.5px; border-radius: 8px; }
.plate-lg .plate-num  { font-size: 30px; padding: 0 18px; letter-spacing: 2px; min-width: 168px; }
.plate-lg .plate-date { font-size: 13px; min-width: 36px; padding: 0 9px; }

/* ── Animações de entrada (substituem o GSAP) ───────────── */
@keyframes pt-fade  { from { opacity: 0 } to { opacity: 1 } }
@keyframes pt-pop   { from { opacity: 0; transform: translateY(24px) scale(.96) } to { opacity: 1; transform: none } }
@keyframes pt-slide { from { opacity: 0; transform: translateY(-12px) } to { opacity: 1; transform: none } }
.stat-card, .card        { animation: pt-fade .35s ease both; }      /* entrada opacity-only (não desloca layout) */
.modal-overlay.open .modal { animation: pt-pop .28s cubic-bezier(.2,.8,.2,1) both; }
.timeline-item.pt-new    { animation: pt-slide .3s ease both; }
.alert.pt-hide           { opacity: 0; transition: opacity .25s ease; }
@media (prefers-reduced-motion: reduce) { .stat-card, .card, .modal-overlay.open .modal, .timeline-item.pt-new { animation: none } }

/* ── Etiqueta de equipamento (.lbl) — usada no detalhe e na impressão em lote ── */
/* Etiqueta 50×30 mm (compacta) */
.lbl{width:50mm;height:30mm;background:#fff;color:#1A1A2E;border:1.2px solid #000;border-radius:2.5px;overflow:hidden;font-family:'Inter',sans-serif;text-align:left;display:flex;flex-direction:column}
.lbl-head{display:flex;align-items:center;gap:4px;padding:1.5mm 2mm 1mm;border-bottom:1px solid #000}
.lbl-head img{height:3.2mm;max-width:14mm;object-fit:contain}
.lbl-head .co{font-size:5px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;line-height:1.05;color:#1A1A2E;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lbl-body{flex:1;display:flex;align-items:center;gap:2mm;padding:1.5mm 2mm;min-height:0}
.lbl-info{flex:1;min-width:0;overflow:hidden}
.lbl-name{font-size:8px;font-weight:800;line-height:1.1;margin-bottom:1.5mm;word-break:break-word;color:#1A1A2E;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.lbl-inv{display:inline-block;background:#000;color:#fff;font-family:'SFMono-Regular',ui-monospace,monospace;font-weight:700;font-size:7px;letter-spacing:.02em;padding:1px 5px;border-radius:2px}
.lbl-qr{flex-shrink:0;line-height:0}
.lbl-qr img,.lbl-qr canvas{display:block;width:18mm;height:18mm}
.lbl-foot{display:none}   /* sem rodapé nesta medida */
.lbl, .lbl-inv, .lbl-head{ -webkit-print-color-adjust:exact; print-color-adjust:exact; }

/* Folha de impressão em lote (grelha A4) */
#labels-print{ display:none; }
#labels-sheet{ display:flex; flex-wrap:wrap; gap:5mm; align-content:flex-start; }
#labels-sheet .lbl{ break-inside:avoid; page-break-inside:avoid; }
@media print{
  body.printing-labels > *:not(#labels-print){ display:none !important; }
  /* padding garante margem em volta do A4 mesmo se o diálogo estiver em "Margens: Nenhuma" */
  body.printing-labels #labels-print{ display:block !important; padding:12mm !important; }
}

/* Popup de seleção de etiquetas */
.lblpick{ max-height:52vh; overflow:auto; border:1px solid var(--border); border-radius:var(--radius); }
.lblpick label{ display:flex; align-items:center; gap:10px; padding:9px 12px; border-bottom:1px solid var(--border); cursor:pointer; font-size:.875rem; }
.lblpick label:last-child{ border-bottom:none; }
.lblpick label:hover{ background:var(--bg); }
.lblpick input[type=checkbox]{ width:16px; height:16px; flex-shrink:0; }
.lblpick .inv{ font-family:ui-monospace,monospace; font-size:.8rem; color:var(--text-muted); flex-shrink:0; }
.lblpick label > span:last-child{ min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ── Responsive (no fim: vencem as regras base por ordem de origem) ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: translateX(0); --sidebar-w: 240px; width: 240px; }
  .main-content { margin-left: 0; }
  #sidebar-overlay.active { display: block !important; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-layout, .two-col { grid-template-columns: 1fr; }
  .page-body { padding: 20px 16px; }
  .top-header { padding: 0 16px; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .modal, .modal-sm, .modal-lg { max-width: calc(100vw - 24px); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .form-select,
  .filter-bar .ss { min-width: 0; max-width: none; width: 100%; }
  .filter-bar .btn { width: 100%; justify-content: center; }
  .file-upload-zone { padding: 18px 14px !important; }
  .dp-panel { width: auto; left: 0; right: 0; max-width: 100%; }
  .plate-lg { height: 42px; }
  .plate-lg .plate-num  { font-size: 20px; min-width: 120px; padding: 0 12px; }
  .plate-lg .plate-date { font-size: 10px; min-width: 26px; }
  .assign-tbl { table-layout: auto; min-width: 480px; }
}
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
}
