:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fbfbfc;
  --text: #1f2937;
  --muted: #667085;
  --border: #e5e7eb;
  --primary: #b91c1c;
  --primary-dark: #7f1d1d;
  --primary-soft: #fee2e2;
  --blue: #60a5fa;
  --red: #f87171;
  --green: #4ade80;
  --shadow: 0 16px 42px rgba(15, 23, 42, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.login-page { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at top, #fff 0, #f6f7fb 48%, #eef1f6 100%); }
.login-shell { width: min(440px, calc(100vw - 32px)); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); text-align: center; }
.brand { color: var(--primary); font-weight: 800; font-size: 36px; letter-spacing: .04em; margin-bottom: 18px; }
.login-card h1 { font-size: 24px; margin: 0 0 22px; }
.login-form { display: grid; gap: 16px; text-align: left; }
.login-form span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, button { font: inherit; }
.login-form input, .header-actions input, .header-actions select { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #fff; color: var(--text); outline: none; }
.login-form input:focus, .header-actions input:focus, .header-actions select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
button { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; }
button:hover { background: var(--primary-dark); }
.login-error { margin-top: 18px; padding: 12px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { background: #f0f0f2; border-right: 1px solid var(--border); padding: 24px 18px; position: sticky; top: 0; height: 100vh; }
.side-title { color: var(--primary); font-weight: 800; font-size: 28px; margin: 0 0 26px 6px; }
.nav-link { display: block; padding: 12px 14px; border-radius: 12px; color: #374151; margin-bottom: 8px; }
.nav-link.active, .nav-link:hover { background: #fff; color: var(--primary); box-shadow: 0 8px 20px rgba(15,23,42,.06); }
.side-user { position: absolute; left: 18px; right: 18px; bottom: 20px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px; max-width: 1920px; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 20px; }
.page-header h1 { flex: 1 1 auto; color: var(--primary); text-align: center; font-size: clamp(28px, 3vw, 44px); margin: 0; }
.header-actions { display: grid; grid-template-columns: minmax(180px, 280px) minmax(150px, 220px) auto; gap: 10px; align-items: center; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid.charts { grid-template-columns: 420px minmax(0, 1fr); margin-top: 18px; align-items: stretch; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel h2, .panel-head h2 { font-size: 18px; margin: 0; }
.panel-head span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; max-height: 640px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1120px; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; height: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
th { position: sticky; top: 0; background: #f8fafc; z-index: 1; color: #344054; font-weight: 800; }
tbody tr:nth-child(even) { background: #fcfcfd; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #fff1f2; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-weight: 700; font-size: 12px; }
.detail-panel { position: sticky; top: 24px; }
.empty-detail { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; }
.detail-card { display: grid; gap: 12px; }
.detail-title { font-size: 18px; font-weight: 800; color: var(--primary); }
.detail-subtitle { color: var(--muted); white-space: pre-line; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.metric { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.metric strong { font-size: 20px; }
.chart-card { min-height: 360px; }
.small-chart canvas { max-height: 300px; }
.wide-chart { min-height: 860px; }
.wide-chart canvas { max-height: 800px; }
.loading, .error-box { padding: 18px; text-align: center; color: var(--muted); }
.error-box { color: var(--primary-dark); background: var(--primary-soft); border-radius: 14px; font-weight: 700; }
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .grid.two, .grid.charts { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .wide-chart { min-height: 520px; }
  .wide-chart canvas { max-height: 500px; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 5; display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 10px; }
  .side-title { margin: 0 10px 0 0; font-size: 22px; }
  .nav-link { margin: 0; flex: 0 0 auto; }
  .side-user { display: none; }
  .content { padding: 14px; }
  .page-header { display: grid; }
  .page-header h1 { text-align: left; }
  .header-actions { grid-template-columns: 1fr; }
  .panel { padding: 12px; border-radius: 14px; }
  .metrics { grid-template-columns: 1fr; }
  .chart-card { min-height: 320px; }
}
.small-link { display:inline-block; margin-top:14px; color:var(--primary); font-weight:700; }
.login-success, .notice.success { margin-top:18px; padding:12px; border-radius:12px; background:#ecfdf3; color:#027a48; font-weight:700; }
.reset-link-box { margin-top:14px; padding:12px; border-radius:12px; background:#f8fafc; border:1px solid var(--border); text-align:left; word-break:break-all; font-size:13px; }
.button-link { display:inline-flex; align-items:center; justify-content:center; border-radius:12px; padding:12px 16px; background:var(--primary); color:#fff; font-weight:800; }
.button-link:hover { background:var(--primary-dark); }
.button-link.secondary { background:#f2f4f7; color:#344054; }
.content.narrow { max-width:980px; }
.notice { margin-bottom:16px; padding:12px 14px; border-radius:12px; font-weight:700; }
.notice.error { background:var(--primary-soft); color:var(--primary-dark); }
.actions-cell { display:flex; align-items:center; gap:8px; }
.actions-cell form { margin:0; }
.small-button { display:inline-flex; align-items:center; justify-content:center; border:0; border-radius:10px; padding:8px 10px; background:#f2f4f7; color:#344054; font-weight:800; font-size:13px; cursor:pointer; }
.small-button.danger { background:#fee4e2; color:#b42318; }
.edit-form { display:grid; gap:16px; max-width:640px; }
.edit-form label span { display:block; color:var(--muted); font-size:13px; font-weight:700; margin-bottom:6px; }
.edit-form input, .edit-form select { width:100%; border:1px solid var(--border); border-radius:12px; padding:12px 14px; background:#fff; color:var(--text); }
.edit-form input:focus, .edit-form select:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
.edit-form .check { display:flex; align-items:center; gap:10px; }
.edit-form .check input { width:auto; }
.edit-form .check span { margin:0; }
.form-actions { display:flex; gap:10px; flex-wrap:wrap; }
@media (max-width: 820px) {
  .button-link, .small-button, button { min-height:42px; }
  .actions-cell { flex-wrap:wrap; }
}

.estado-cell { font-weight: 800; }
.status-pill { border: 1px solid transparent; }
.status-concluida { background: #dcfce7 !important; color: #166534 !important; border-color: #86efac !important; }
.status-em-curso { background: #fef9c3 !important; color: #854d0e !important; border-color: #fde047 !important; }
.status-nova-encomenda { background: #dbeafe !important; color: #1d4ed8 !important; border-color: #93c5fd !important; }
.status-planeada, .status-planeado { background: #f3f4f6 !important; color: #374151 !important; border-color: #d1d5db !important; }
.status-em-atraso { background: #fee2e2 !important; color: #991b1b !important; border-color: #fca5a5 !important; }
.status-sem-estado { background: #f1f5f9 !important; color: #475569 !important; border-color: #cbd5e1 !important; }

.actions-print { text-align: center; }
.print-labels-btn,
.print-labels-detail {
  background: #111827;
  color: #fff;
  white-space: nowrap;
}
.print-labels-btn:hover,
.print-labels-detail:hover {
  background: #374151;
}
.print-labels-detail {
  width: 100%;
  margin-top: 4px;
}

/* Ecrã dedicado à impressão de etiquetas */
.labels-content { max-width: none; }
.labels-content .page-header { align-items: start; flex-wrap: wrap; }
.labels-content .page-header h1 { text-align: left; min-width: 280px; }
.labels-actions {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(170px, 220px) auto;
  width: min(820px, 100%);
  margin-left: auto;
}
.labels-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(380px, 520px);
  gap: 18px;
  align-items: start;
}
.labels-table-wrap { max-height: calc(100vh - 210px); overflow: auto; }
.labels-table { min-width: 980px; table-layout: auto; }
.labels-table th,
.labels-table td { max-width: none; padding: 9px 10px; }
.labels-table th:nth-child(4),
.labels-table td:nth-child(4) { min-width: 210px; max-width: 320px; white-space: normal; line-height: 1.25; }
.labels-table th:nth-child(2),
.labels-table td:nth-child(2) { min-width: 170px; }
.labels-table th:nth-child(9),
.labels-table td:nth-child(9) { min-width: 120px; }
.label-print-panel { position: sticky; top: 24px; }
.label-selected-info {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 14px;
  word-break: break-word;
}
.label-preview-wrap {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 12px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.rgvs-label-preview { color: #000; background: #fff; max-width: 100%; }
.empty-label-preview { min-height: 160px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.label-print-controls {
  display: grid;
  grid-template-columns: minmax(120px, .8fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}
.label-print-controls label span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.label-print-controls input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; min-height: 42px; }
.label-print-controls .small-button { width: 100%; min-height: 42px; padding: 10px 12px; white-space: normal; line-height: 1.15; text-align: center; }
.label-print-controls .print-labels-btn { grid-column: span 1; }
.primary-print { background: var(--primary) !important; color: #fff !important; }

 .excel-label {
  position: relative;
  width: 390px;
  height: 455px;
  border: 2px solid #000;
  background-color: #fff;
  background-image:
    linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000),
    linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000),
    linear-gradient(#000,#000), linear-gradient(#000,#000), linear-gradient(#000,#000);
  background-repeat: no-repeat;
  background-size:
    100% 2px, 100% 2px, 100% 2px, 100% 2px, 100% 2px,
    100% 2px, 100% 2px, 100% 2px, 100% 2px, 100% 2px,
    2px 314px, 2px 29px, 2px 17px;
  background-position:
    0 141px, 0 183px, 0 196px, 0 236px, 0 252px,
    0 287px, 0 308px, 0 324px, 0 426px, 0 439px,
    170px 141px, 280px 426px, 170px 307px;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
  flex: 0 0 auto;
}
.excel-label > * { position: absolute; }
.lbl-origin { top: 3px; left: 0; right: 0; text-align: center; font-size: 7px; font-weight: 900; line-height: 1; }
.lbl-company { top: 20px; left: 0; right: 0; text-align: center; font-size: 26px; font-weight: 900; letter-spacing: .35px; line-height: 1; }
.lbl-address { top: 54px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 900; line-height: 1.25; }
.lbl-contact { top: 86px; left: 0; right: 0; text-align: center; font-size: 8.2px; font-weight: 900; line-height: 1; }
.lbl-caption { font-size: 7px; font-weight: 900; text-align: center; line-height: 1; }
.ref-caption { top: 101px; left: 0; right: 0; }
.lbl-ref { top: 115px; left: 4px; right: 4px; text-align: center; font-size: 23px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-head { font-size: 7px; font-weight: 900; line-height: 1; }
.lote-head { top: 144px; left: 2px; }
.data-head { top: 144px; left: 172px; }
.lbl-lote { top: 158px; left: 0; width: 170px; text-align: center; font-size: 17px; line-height: 1; }
.lbl-data { top: 158px; left: 170px; width: 220px; text-align: center; font-size: 17px; line-height: 1; }
.encomenda-caption { top: 186px; left: 0; right: 0; }
.lbl-encomenda { top: 205px; left: 4px; right: 4px; text-align: center; font-size: 25px; font-weight: 900; line-height: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-encomenda span { font-weight: 900; }
.refcli-caption { top: 239px; left: 0; right: 0; }
.lbl-refcli { top: 260px; left: 4px; right: 4px; text-align: center; font-size: 25px; font-weight: 900; line-height: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-design { top: 291px; left: 4px; right: 4px; text-align: center; font-size: 12px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qtd-head { top: 311px; left: 2px; }
.tamanho-head { top: 311px; left: 170px; width: 220px; text-align: center; }
.lbl-qtd { top: 348px; left: 0; width: 170px; text-align: center; font-size: 62px; font-weight: 900; line-height: 1; }
.lbl-tamanho { top: 332px; left: 170px; width: 220px; text-align: center; font-size: 89px; font-weight: 900; line-height: 1; }
.cor-head { top: 429px; left: 2px; }
.lbl-cor { top: 442px; left: 4px; width: 270px; font-size: 9px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-counter { top: 442px; right: 12px; font-size: 16px; line-height: 1; }

@media (max-width: 1500px) {
  .labels-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 470px); }
}
@media (max-width: 1280px) {
  .labels-layout { grid-template-columns: 1fr; }
  .label-print-panel { position: static; }
  .labels-table-wrap { max-height: 520px; }
}
@media (max-width: 820px) {
  .labels-actions { grid-template-columns: 1fr; margin-left: 0; }
  .labels-layout { gap: 12px; }
  .label-print-controls { grid-template-columns: 1fr 1fr; }
  .label-print-controls label { grid-column: span 2; }
  .label-print-controls .print-labels-btn { grid-column: span 1; }
  .label-preview-wrap { padding: 8px; justify-content: flex-start; }
  .excel-label { transform: scale(.82); transform-origin: top left; margin-right: -62px; margin-bottom: -72px; }
}
@media (max-width: 430px) {
  .content { padding: 10px; }
  .page-header h1 { font-size: 28px; }
  .panel { padding: 10px; }
  .label-print-controls { grid-template-columns: 1fr; }
  .label-print-controls label,
  .label-print-controls .print-labels-btn { grid-column: auto; }
  .excel-label { transform: scale(.72); margin-right: -96px; margin-bottom: -112px; }
}

/* Menu lateral auto-hide / hamburger */
:root { --sidebar-collapsed: 76px; --sidebar-expanded: 248px; }
.app-shell { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); transition: grid-template-columns .18s ease; }
body.menu-expanded .app-shell,
body.menu-hover-expanded .app-shell { grid-template-columns: var(--sidebar-expanded) minmax(0, 1fr); }
.sidebar {
  width: var(--sidebar-collapsed);
  overflow: hidden;
  transition: width .18s ease, box-shadow .18s ease, transform .18s ease;
  z-index: 20;
}
body.menu-expanded .sidebar,
body.menu-hover-expanded .sidebar { width: var(--sidebar-expanded); box-shadow: 12px 0 30px rgba(15,23,42,.08); }
.menu-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  gap: 0;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0 0 18px 0;
  box-shadow: 0 8px 20px rgba(15,23,42,.06);
}
.menu-toggle:hover { background: var(--primary-soft); }
.menu-toggle span { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 999px; margin: 2px 0; }
.side-title {
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .16s ease, transform .16s ease;
  margin-bottom: 18px;
}
body.menu-expanded .side-title,
body.menu-hover-expanded .side-title { opacity: 1; transform: none; }
.nav-link {
  position: relative;
  min-height: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  padding-left: 14px;
}
body.menu-collapsed:not(.menu-hover-expanded) .nav-link {
  width: 42px;
  color: transparent;
  padding: 12px 0;
  text-align: center;
}
body.menu-collapsed:not(.menu-hover-expanded) .nav-link::first-letter { color: var(--primary); font-weight: 900; }
body.menu-collapsed:not(.menu-hover-expanded) .nav-link.active,
body.menu-collapsed:not(.menu-hover-expanded) .nav-link:hover { color: transparent; }
.side-user { opacity: 0; transition: opacity .16s ease; }
body.menu-expanded .side-user,
body.menu-hover-expanded .side-user { opacity: 1; }
.content { padding: 18px 18px 22px; max-width: none; }
.page-header { margin-bottom: 14px; gap: 12px; }
.page-header h1 { font-size: clamp(24px, 2.4vw, 38px); }
.panel { padding: 14px; }
.panel-head { margin-bottom: 9px; }
.table-wrap { max-height: calc(100vh - 190px); }
th, td { padding: 7px 8px; height: 32px; font-size: 13px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 14px; }
.grid.charts { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.chart-card { min-height: 300px; }
.small-chart canvas { max-height: 250px; }
.wide-chart { min-height: 560px; }
.wide-chart canvas { max-height: 520px; }
.labels-layout { grid-template-columns: minmax(560px, 1fr) minmax(340px, 460px); gap: 14px; }
.labels-table-wrap { max-height: calc(100vh - 178px); }
.label-print-panel { top: 18px; }
.label-selected-info { padding: 9px 10px; line-height: 1.35; margin-bottom: 10px; }
.label-preview-wrap { padding: 8px; }
.label-print-controls { gap: 8px; margin-top: 10px; }
.label-print-controls .small-button { white-space: nowrap; }
.excel-label { transform: scale(.88); transform-origin: top center; margin-top: -24px; margin-bottom: -40px; }
.menu-overlay { display: none; }

@media (max-width: 1500px) {
  .labels-layout { grid-template-columns: minmax(0, 1fr) minmax(330px, 420px); }
  .labels-table { min-width: 900px; }
  .excel-label { transform: scale(.78); margin-top: -42px; margin-bottom: -78px; }
}
@media (max-width: 1280px) {
  .grid.two, .grid.charts, .labels-layout { grid-template-columns: 1fr; }
  .detail-panel, .label-print-panel { position: static; }
  .labels-table-wrap, .table-wrap { max-height: 520px; }
  .excel-label { transform: scale(.9); margin-top: -18px; margin-bottom: -30px; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    width: min(82vw, 290px);
    max-width: 290px;
    transform: translateX(-105%);
    padding: 18px;
    display: block;
    overflow-y: auto;
    box-shadow: 18px 0 50px rgba(15,23,42,.18);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.38);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
    z-index: 15;
  }
  body.menu-open .menu-overlay { opacity: 1; visibility: visible; }
  .menu-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 30;
    margin: 0;
  }
  .side-title { opacity: 1; transform: none; margin: 54px 0 18px 6px; }
  .nav-link { width: auto !important; color: #374151 !important; text-align: left !important; padding: 12px 14px !important; margin-bottom: 8px; }
  .side-user { opacity: 1; display: block; position: static; margin-top: 24px; }
  .content { padding: 62px 10px 14px; }
  .page-header { grid-template-columns: 1fr; align-items: stretch; }
  .page-header h1 { font-size: 25px; }
  .header-actions, .labels-actions { grid-template-columns: 1fr; width: 100%; }
  .panel { padding: 10px; border-radius: 14px; }
  .table-wrap, .labels-table-wrap { max-height: none; }
  table { min-width: 760px; }
  th, td { padding: 6px 7px; height: 30px; font-size: 12px; }
  .labels-table { min-width: 0; width: 100%; }
  .labels-table thead { display: none; }
  .labels-table, .labels-table tbody, .labels-table tr, .labels-table td { display: block; }
  .labels-table tr { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; padding: 8px; background: #fff; }
  .labels-table td { border: 0; height: auto; max-width: none; padding: 2px 0; white-space: normal; font-size: 12px; }
  .labels-table td:nth-child(1) { font-weight: 900; color: var(--primary); }
  .labels-table td:nth-child(2), .labels-table td:nth-child(3) { display: inline-block; margin-right: 10px; }
  .labels-table td:nth-child(4) { line-height: 1.2; }
  .labels-table td:nth-child(5)::before { content: 'Qtd.: '; font-weight: 800; }
  .labels-table td:nth-child(6)::before { content: 'Qtd. Emb.: '; font-weight: 800; }
  .labels-table td:nth-child(7)::before { content: 'Etiq.: '; font-weight: 800; }
  .labels-table td:nth-child(8)::before { content: 'Entrega: '; font-weight: 800; }
  .label-print-controls { grid-template-columns: 1fr 1fr; }
  .label-print-controls .small-button { white-space: normal; }
  .label-preview-wrap { justify-content: center; overflow: hidden; }
  .excel-label { transform: scale(.78); transform-origin: top center; margin-top: -42px; margin-bottom: -78px; }
}
@media (max-width: 430px) {
  .content { padding-left: 8px; padding-right: 8px; }
  .page-header h1 { font-size: 23px; }
  .excel-label { transform: scale(.68); margin-top: -64px; margin-bottom: -124px; }
  .label-print-controls { grid-template-columns: 1fr; }
}

/* Etiquetas: grelha real com bordas, sem linhas desenhadas por background.
   Mantém preview e impressão com o mesmo layout e evita sobreposição de linhas/texto. */
.excel-label {
  position: relative !important;
  width: 390px !important;
  height: 455px !important;
  border: 2px solid #000 !important;
  background: #fff !important;
  background-image: none !important;
  color: #000 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  display: grid !important;
  grid-template-rows: 142px 40px 55px 72px 126px 18px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
}
.excel-label > * { position: relative !important; }
.xl-section { border-top: 2px solid #000; min-width: 0; overflow: hidden; }
.xl-section:first-child { border-top: 0; }
.xl-top { text-align: center; padding-top: 3px; }
.xl-origin { font-size: 6px; font-weight: 900; line-height: 1; }
.xl-company { font-size: 24px; font-weight: 900; letter-spacing: .3px; line-height: 1; margin-top: 15px; white-space: nowrap; }
.xl-place, .xl-address { font-size: 12.5px; font-weight: 900; line-height: 1.05; }
.xl-place { margin-top: 10px; }
.xl-contact { font-size: 8px; font-weight: 900; line-height: 1; margin-top: 6px; white-space: nowrap; }
.xl-caption, .xl-row-caption, .xl-cell-caption { font-size: 6.5px; font-weight: 900; line-height: 1; text-transform: uppercase; }
.xl-caption { margin-top: 5px; }
.xl-main-ref { font-size: 23px; font-weight: 900; line-height: 1; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-two { display: grid; grid-template-columns: 170px 1fr; }
.xl-cell { position: relative; min-width: 0; overflow: hidden; }
.xl-cell + .xl-cell { border-left: 2px solid #000; }
.xl-cell-caption { position: absolute; top: 3px; left: 3px; }
.xl-centered-caption { left: 0; right: 0; text-align: center; }
.xl-cell-value { position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; font-size: 16px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-encomenda, .xl-refcli-block { text-align: center; }
.xl-row-caption { position: absolute; top: 3px; left: 0; right: 0; text-align: center; }
.xl-encomenda-value { position: absolute; left: 4px; right: 4px; top: 18px; font-size: 25px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-refcli-value { position: absolute; left: 4px; right: 4px; top: 15px; font-size: 24px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-design-value { position: absolute; left: 4px; right: 4px; top: 45px; font-size: 12px; font-weight: 900; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-big-value { position: absolute; left: 0; right: 0; top: 40px; text-align: center; font-size: 59px; font-weight: 900; line-height: 1; }
.xl-size-value { position: absolute; left: 0; right: 0; top: 21px; text-align: center; font-size: 88px; font-weight: 900; line-height: 1; }
.xl-footer { display: grid; grid-template-columns: 280px 1fr; }
.xl-footer-cor { position: relative; border-right: 2px solid #000; min-width: 0; }
.xl-cor-value { position: absolute; left: 3px; right: 3px; bottom: 2px; font-size: 8.5px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xl-footer-counter { display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1; }

@media (max-width: 1100px) {
  .label-preview-box .excel-label { transform: scale(.82) !important; transform-origin: top center !important; margin-bottom: -78px !important; }
}
@media (max-width: 720px) {
  .label-preview-box .excel-label { transform: scale(.72) !important; transform-origin: top center !important; margin-bottom: -126px !important; }
}

/* Final RGVS fixes: estado colors, readable tables and Excel-like labels without overlapping CSS background lines. */
.status-nova-encomenda { background: #ede9fe !important; color: #5b21b6 !important; border-color: #8b5cf6 !important; }
.status-planeada, .status-planeado { background: #dbeafe !important; color: #1d4ed8 !important; border-color: #3b82f6 !important; }
.status-em-curso { background: #fef3c7 !important; color: #92400e !important; border-color: #f59e0b !important; }
.status-concluida { background: #dcfce7 !important; color: #166534 !important; border-color: #22c55e !important; }
.status-em-atraso { background: #fee2e2 !important; color: #991b1b !important; border-color: #ef4444 !important; }
.status-sem-estado { background: #f1f5f9 !important; color: #475569 !important; border-color: #94a3b8 !important; }

.table-wrap { max-height: calc(100vh - 220px); }
th, td { padding: 7px 8px; height: 34px; font-size: 13px; }
.labels-table { min-width: 980px; }
.labels-layout { display: grid; grid-template-columns: minmax(680px, 1fr) minmax(360px, 430px); gap: 18px; align-items: start; }
.label-print-panel { position: sticky; top: 16px; }
.label-print-controls { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 8px; align-items: end; }
.label-print-controls button { min-width: 0; white-space: normal; line-height: 1.15; padding: 10px 12px; }
.label-print-controls .print-labels-btn { grid-column: span 1; }
.label-print-controls .primary-print { background: var(--primary); color: #fff; }
.label-print-controls label span { display:block; font-size:12px; color:var(--muted); font-weight:700; margin-bottom:4px; }
.label-print-controls input { width:100%; border:1px solid var(--border); border-radius:10px; padding:9px 8px; }
.label-preview-wrap { display:flex; justify-content:center; align-items:flex-start; overflow:auto; padding:12px; border:1px dashed var(--border); border-radius:14px; background:#fff; }

.label-preview-box .excel-label, .rgvs-label-preview .excel-label, .excel-label {
  position: relative !important;
  width: 90mm !important;
  height: 105mm !important;
  border: .45mm solid #000 !important;
  background: #fff !important;
  color: #000 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  display: grid !important;
  grid-template-rows: 32.6mm 8.9mm 12.8mm 16.6mm 29.1mm 5mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  transform: none !important;
  margin: 0 !important;
}
.excel-label > * { position: relative !important; }
.xl-section { border-top: .35mm solid #000 !important; min-width: 0 !important; overflow: hidden !important; }
.xl-section:first-child { border-top: 0 !important; }
.xl-top { text-align: center !important; padding-top: .55mm !important; }
.xl-origin { font-size: 1.15mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-company { font-size: 5.25mm !important; font-weight: 900 !important; letter-spacing: .08mm !important; line-height: 1 !important; margin-top: 3.4mm !important; white-space: nowrap !important; }
.xl-place, .xl-address { font-size: 2.65mm !important; font-weight: 900 !important; line-height: 1.05 !important; }
.xl-place { margin-top: 2.2mm !important; }
.xl-contact { font-size: 1.72mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: 1.25mm !important; white-space: nowrap !important; }
.xl-caption, .xl-row-caption, .xl-cell-caption { font-size: 1.38mm !important; font-weight: 900 !important; line-height: 1 !important; text-transform: uppercase !important; }
.xl-caption { margin-top: 1.08mm !important; }
.xl-main-ref { font-size: 5mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: .75mm !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-two { display: grid !important; grid-template-columns: 37.8mm 1fr !important; }
.xl-cell { position: relative !important; min-width: 0 !important; overflow: hidden !important; }
.xl-cell + .xl-cell { border-left: .35mm solid #000 !important; }
.xl-cell-caption { position: absolute !important; top: .55mm !important; left: .6mm !important; }
.xl-centered-caption { left: 0 !important; right: 0 !important; text-align: center !important; }
.xl-cell-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 3.25mm !important; text-align: center !important; font-size: 3.65mm !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-encomenda, .xl-refcli-block { text-align: center !important; }
.xl-row-caption { position: absolute !important; top: .75mm !important; left: 0 !important; right: 0 !important; text-align: center !important; }
.xl-encomenda-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 4.8mm !important; font-size: 5.8mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-refcli-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 3.8mm !important; font-size: 5.3mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-design-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 10.4mm !important; font-size: 2.6mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-big-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 10mm !important; text-align: center !important; font-size: 13.6mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-size-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 5.2mm !important; text-align: center !important; font-size: 20.2mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-footer { display: grid !important; grid-template-columns: 63.5mm 1fr !important; }
.xl-footer-cor { position: relative !important; border-right: .35mm solid #000 !important; min-width: 0 !important; }
.xl-cor-value { position: absolute !important; left: .6mm !important; right: .6mm !important; top: 2.35mm !important; font-size: 1.8mm !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-footer-counter { display: flex !important; align-items: center !important; justify-content: center !important; font-size: 3.4mm !important; line-height: 1 !important; }

@media (max-width: 1500px) {
  .labels-layout { grid-template-columns: minmax(620px, 1fr) minmax(330px, 390px); gap: 14px; }
  .label-preview-wrap .excel-label { transform: scale(.88) !important; transform-origin: top center !important; margin-bottom: -12mm !important; }
}
@media (max-width: 1150px) {
  .labels-layout { grid-template-columns: 1fr; }
  .label-print-panel { position: static; }
  .label-preview-wrap .excel-label { transform: scale(.92) !important; transform-origin: top center !important; margin-bottom: -8mm !important; }
}
@media (max-width: 720px) {
  .labels-content { padding: 10px !important; }
  .labels-actions { grid-template-columns: 1fr !important; }
  .labels-table-wrap { max-height: calc(100vh - 360px); }
  .label-print-controls { grid-template-columns: 1fr 1fr; }
  .label-print-controls label { grid-column: 1 / -1; }
  .label-print-controls button { width: 100%; }
  .label-preview-wrap { padding: 8px; }
  .label-preview-wrap .excel-label { transform: scale(.74) !important; transform-origin: top center !important; margin-bottom: -27mm !important; }
}

/* RGVS final corrections 2026-05: solid estado chart colors and Excel-label proportions. */
.label-preview-box .excel-label,
.rgvs-label-preview .excel-label,
.excel-label {
  width: 90mm !important;
  height: 105mm !important;
  border: .45mm solid #000 !important;
  background: #fff !important;
  background-image: none !important;
  display: grid !important;
  grid-template-rows: 32.8mm 9.6mm 12mm 16.7mm 27.6mm 6.3mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  color: #000 !important;
}
.excel-label > * { position: relative !important; }
.xl-section { border-top: .35mm solid #000 !important; overflow: hidden !important; min-width: 0 !important; }
.xl-section:first-child { border-top: 0 !important; }
.xl-top { text-align: center !important; padding-top: .55mm !important; }
.xl-origin { font-size: 1.15mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-company { font-size: 5.2mm !important; font-weight: 900 !important; letter-spacing: .08mm !important; line-height: 1 !important; margin-top: 3.35mm !important; white-space: nowrap !important; }
.xl-place, .xl-address { font-size: 2.55mm !important; font-weight: 900 !important; line-height: 1.08 !important; }
.xl-place { margin-top: 2.15mm !important; }
.xl-contact { font-size: 1.68mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: 1.15mm !important; white-space: nowrap !important; }
.xl-caption, .xl-row-caption, .xl-cell-caption { font-size: 1.35mm !important; font-weight: 900 !important; line-height: 1 !important; text-transform: uppercase !important; }
.xl-caption { margin-top: 1mm !important; }
.xl-main-ref { font-size: 5.05mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: .75mm !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-two { display: grid !important; grid-template-columns: 39mm 1fr !important; }
.xl-cell { position: relative !important; min-width: 0 !important; overflow: hidden !important; }
.xl-cell + .xl-cell { border-left: .35mm solid #000 !important; }
.xl-cell-caption { position: absolute !important; top: .55mm !important; left: .6mm !important; }
.xl-centered-caption { left: 0 !important; right: 0 !important; text-align: center !important; }
.xl-cell-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 4.05mm !important; text-align: center !important; font-size: 3.85mm !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-row-caption { position: absolute !important; top: .72mm !important; left: 0 !important; right: 0 !important; text-align: center !important; }
.xl-encomenda-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 4.35mm !important; font-size: 5.9mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-refcli-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 2.75mm !important; font-size: 5.6mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-design-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 10mm !important; font-size: 2.6mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-big-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 9mm !important; text-align: center !important; font-size: 14.8mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-size-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 4.8mm !important; text-align: center !important; font-size: 21.5mm !important; font-weight: 900 !important; line-height: 1 !important; }
.xl-footer { display: grid !important; grid-template-columns: 64mm 1fr !important; }
.xl-footer-cor { position: relative !important; border-right: .35mm solid #000 !important; min-width: 0 !important; }
.xl-cor-value { position: absolute !important; left: .6mm !important; right: .6mm !important; top: 2.75mm !important; font-size: 1.85mm !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.xl-footer-counter { display: flex !important; align-items: center !important; justify-content: center !important; font-size: 3.55mm !important; line-height: 1 !important; }

/* Final RGVS corrections: estado solid colors, label grid with real borders/no overlap. */
.status-nova-encomenda { background: #ede9fe !important; color: #5b21b6 !important; border-color: #c4b5fd !important; }
.status-planeada, .status-planeado { background: #dbeafe !important; color: #1d4ed8 !important; border-color: #93c5fd !important; }
.status-em-curso { background: #fef3c7 !important; color: #92400e !important; border-color: #fbbf24 !important; }
.status-concluida { background: #dcfce7 !important; color: #166534 !important; border-color: #86efac !important; }
.status-em-atraso { background: #fee2e2 !important; color: #991b1b !important; border-color: #fca5a5 !important; }
.chart-card canvas { filter: none !important; opacity: 1 !important; background: transparent !important; }

.rgvs-label-preview .excel-label,
.label-preview-wrap .excel-label,
.excel-label {
  width: 90mm !important;
  height: 105mm !important;
  border: .55mm solid #000 !important;
  background: #fff !important;
  background-image: none !important;
  color: #000 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  display: grid !important;
  grid-template-rows: 32.6mm 9.8mm 12.2mm 16.9mm 26.9mm 6.6mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
}
.excel-label > * { position: relative !important; min-width: 0 !important; overflow: hidden !important; }
.excel-label .xl-section { border-top: .5mm solid #000 !important; }
.excel-label .xl-section:first-child { border-top: 0 !important; }
.excel-label .xl-top { text-align: center !important; padding-top: .55mm !important; }
.excel-label .xl-origin { font-size: 1.15mm !important; font-weight: 900 !important; line-height: 1 !important; }
.excel-label .xl-company { font-size: 5.25mm !important; font-weight: 900 !important; letter-spacing: .06mm !important; line-height: 1 !important; margin-top: 3.35mm !important; white-space: nowrap !important; }
.excel-label .xl-place,
.excel-label .xl-address { font-size: 2.55mm !important; font-weight: 900 !important; line-height: 1.08 !important; }
.excel-label .xl-place { margin-top: 2.1mm !important; }
.excel-label .xl-contact { font-size: 1.68mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: 1.1mm !important; white-space: nowrap !important; }
.excel-label .xl-caption,
.excel-label .xl-row-caption,
.excel-label .xl-cell-caption { font-size: 1.35mm !important; font-weight: 900 !important; line-height: 1 !important; text-transform: uppercase !important; }
.excel-label .xl-caption { margin-top: 1mm !important; }
.excel-label .xl-main-ref { font-size: 5.05mm !important; font-weight: 900 !important; line-height: 1 !important; margin-top: .75mm !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-two { display: grid !important; grid-template-columns: 39mm 1fr !important; }
.excel-label .xl-cell { position: relative !important; min-width: 0 !important; overflow: hidden !important; }
.excel-label .xl-cell + .xl-cell { border-left: .5mm solid #000 !important; }
.excel-label .xl-cell-caption { position: absolute !important; top: .62mm !important; left: .7mm !important; }
.excel-label .xl-centered-caption { left: 0 !important; right: 0 !important; text-align: center !important; }
.excel-label .xl-cell-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 4.25mm !important; text-align: center !important; font-size: 3.75mm !important; font-weight: 700 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-encomenda,
.excel-label .xl-refcli-block { text-align: center !important; }
.excel-label .xl-row-caption { position: absolute !important; top: .82mm !important; left: 0 !important; right: 0 !important; text-align: center !important; }
.excel-label .xl-encomenda-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 4.65mm !important; font-size: 5.75mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-refcli-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 3.15mm !important; font-size: 5.45mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-design-value { position: absolute !important; left: 1mm !important; right: 1mm !important; top: 10.5mm !important; font-size: 2.55mm !important; font-weight: 900 !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-big-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 8.85mm !important; text-align: center !important; font-size: 14.2mm !important; font-weight: 900 !important; line-height: 1 !important; }
.excel-label .xl-size-value { position: absolute !important; left: 0 !important; right: 0 !important; top: 4.35mm !important; text-align: center !important; font-size: 21mm !important; font-weight: 900 !important; line-height: 1 !important; }
.excel-label .xl-footer { display: grid !important; grid-template-columns: 63.8mm 1fr !important; }
.excel-label .xl-footer-cor { position: relative !important; border-right: .5mm solid #000 !important; min-width: 0 !important; }
.excel-label .xl-cor-value { position: absolute !important; left: .7mm !important; right: .7mm !important; top: 2.95mm !important; font-size: 1.85mm !important; line-height: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.excel-label .xl-footer-counter { display: flex !important; align-items: center !important; justify-content: center !important; font-size: 3.35mm !important; line-height: 1 !important; font-weight: 400 !important; }

/* Fix label print buttons: keep text inside the buttons on narrow preview panels */
.label-print-controls {
  grid-template-columns: minmax(82px, 110px) minmax(96px, 1fr) minmax(96px, 1fr) !important;
  align-items: end !important;
}
.label-print-controls .small-button,
.label-print-controls .print-labels-btn,
#prevLabelBtn,
#nextLabelBtn,
#printOneLabelBtn,
#printAllLabelsBtn {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
  line-height: 1.15 !important;
  min-height: 46px !important;
  padding: 10px 12px !important;
  font-size: clamp(12px, 0.82vw, 14px) !important;
}
#prevLabelBtn,
#nextLabelBtn {
  white-space: nowrap !important;
}
#printOneLabelBtn {
  grid-column: 1 / span 2 !important;
}
#printAllLabelsBtn {
  grid-column: 3 / span 1 !important;
}

@media (max-width: 1500px) {
  .label-print-controls {
    grid-template-columns: minmax(76px, 96px) minmax(92px, 1fr) minmax(92px, 1fr) !important;
  }
  .label-print-controls .small-button,
  .label-print-controls .print-labels-btn,
  #printOneLabelBtn,
  #printAllLabelsBtn {
    padding-left: 9px !important;
    padding-right: 9px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 760px) {
  .label-print-controls {
    grid-template-columns: 1fr 1fr !important;
  }
  .label-print-controls label {
    grid-column: 1 / -1 !important;
  }
  #prevLabelBtn,
  #nextLabelBtn {
    grid-column: span 1 !important;
  }
  #printOneLabelBtn,
  #printAllLabelsBtn {
    grid-column: span 1 !important;
    white-space: normal !important;
  }
}

@media (max-width: 420px) {
  #printOneLabelBtn,
  #printAllLabelsBtn {
    grid-column: 1 / -1 !important;
  }
}

/* Mobile navigation fix: hamburger outside the off-canvas sidebar + bottom shortcuts */
.mobile-menu-toggle,
.mobile-bottom-nav { display: none; }

@media (max-width: 820px) {
  body { padding-bottom: 66px; }

  .mobile-menu-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 60;
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .14);
  }
  .mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 2px 0;
    background: currentColor;
    border-radius: 999px;
  }

  .sidebar .menu-toggle {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    z-index: 2 !important;
    width: 40px !important;
    height: 40px !important;
  }

  body.menu-open .mobile-menu-toggle {
    opacity: 0;
    pointer-events: none;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 6px;
    padding: 7px;
    background: rgba(255,255,255,.96);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
    backdrop-filter: blur(10px);
  }
  .mobile-bottom-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: 12px;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    line-height: 1.1;
    white-space: normal;
  }
  .mobile-bottom-link.active {
    background: var(--primary-soft);
    color: var(--primary);
  }

  .content { padding-top: 62px !important; padding-bottom: 16px !important; }
  .page-header { margin-bottom: 10px !important; }
  .page-header h1 { padding-left: 48px; }

  .labels-table td:nth-child(7)::before { content: 'Entrega: '; font-weight: 800; }
  .labels-table td:nth-child(8)::before { content: 'Estado: '; font-weight: 800; }
}

/* References management screen */
.references-content .page-header { align-items: flex-start; }
.references-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.references-form-panel { position: sticky; top: 18px; }
.references-form .form-grid-3,
.references-form .form-grid-2 {
  display: grid;
  gap: 12px;
}
.references-form .form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.references-form .form-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: end; }
.reference-active { min-height: 42px; align-items: center; }
.references-table td,
.references-table th { white-space: nowrap; }
.references-table td:nth-child(2),
.references-table th:nth-child(2) { min-width: 260px; white-space: normal; }

@media (max-width: 1200px) {
  .references-layout { grid-template-columns: 1fr; }
  .references-form-panel { position: static; }
}

@media (max-width: 720px) {
  .references-form .form-grid-3,
  .references-form .form-grid-2 { grid-template-columns: 1fr; }
  .references-table-panel .table-wrap { max-height: none; }
}

/* References config: only query-controlled values are shown here */
.references-form-panel .panel-note {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.references-table td:nth-child(2),
.references-table th:nth-child(2) {
  min-width: 90px;
  white-space: nowrap;
}
