:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --accent: #176b87;
  --accent-strong: #0f5268;
  --danger: #ad343e;
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 260px),
    var(--bg);
}

body.dragging-element {
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover,
.button-link:hover,
.import-btn:hover {
  border-color: var(--accent);
}

.button-link {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  width: 100%;
}

.danger.light {
  background: #fff;
  color: var(--danger);
}

.topbar {
  min-height: 76px;
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

/* Logo idêntico ao da landing page */
.topbar .lp-logo {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 35px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.topbar .lp-logo .ic {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  color: var(--accent);
  flex-shrink: 0;
}

.topbar .lp-logo:hover {
  color: var(--accent);
}

.topbar h1,
.topbar p,
h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  letter-spacing: 0;
}

.topbar p,
.muted {
  color: var(--muted);
}

.small-note {
  font-size: 12px;
  line-height: 1.35;
  margin: 10px 0 0;
}

.top-actions,
.file-actions,
.format-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.toggle-row input[type="checkbox"] {
  width: auto;
}

.file-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.file-actions-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 60px;
  flex-shrink: 0;
}

.file-actions .button-link,
.file-actions .import-btn,
.file-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  margin: 0;
  box-sizing: border-box;
  white-space: nowrap;
}

/* .plan-select removido — planSelect eliminado por segurança */

.clerk-auth {
  display: flex;
  align-items: center;
}

.clerk-signin-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.clerk-signin-btn:hover {
  background: var(--accent-strong);
}

.clerk-user-fallback {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}
.clerk-user-fallback:hover { opacity: 0.85; }

.clerk-plan-tag {
  font-size: 14px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-decoration: none;
}
.clerk-plan-tag--upgrade {
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.clerk-plan-tag--upgrade:hover {
  background: var(--accent-strong);
  padding-right: 22px;
}
.clerk-plan-tag--upgrade::after {
  content: ' ⬆';
  position: absolute;
  right: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 10px;
}
.clerk-plan-tag--upgrade:hover::after {
  opacity: 1;
}

/* Botão de demonstração */
.demo-showcase-btn {
  background: linear-gradient(135deg, #0f766e 0%, #0369a1 100%) !important;
  color: #fff !important;
  border-color: transparent !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  letter-spacing: 0.01em;
  transition: opacity 0.15s;
}
.demo-showcase-btn:hover { opacity: 0.88; }

/* Banner demo mode — bloco antes do sheet, fora da grid */
.demo-mode-banner {
  display: block;
  background: rgba(15,118,110,0.92);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  padding: 8px 18px;
  margin: 0 auto 12px;
  border-radius: 8px;
  pointer-events: none;
  text-align: center;
  width: fit-content;
}

/* Secção bloqueada para free (sobreposição) */
.section-plan-lock {
  position: relative;
}
.section-plan-lock::after {
  content: "Disponível no plano Iniciante";
  position: absolute;
  inset: 0;
  background: rgba(248,250,252,0.82);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border-radius: 6px;
  pointer-events: none;
  z-index: 10;
  text-align: center;
  padding: 8px;
}

.clerk-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 180px;
  padding: 10px 0;
  z-index: 9999;
}
.clerk-user-menu-name {
  padding: 4px 14px;
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
}
.clerk-user-menu-plan {
  padding: 0 14px 4px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.clerk-user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 14px;
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
}
.clerk-user-menu-item:hover { background: #f8fafc; }
.clerk-upgrade-btn {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent) !important;
  text-decoration: none;
  cursor: pointer;
}
.clerk-upgrade-btn:hover { background: #f0fdfa; }

.icon-btn {
  width: auto;
  padding: 7px 9px;
  line-height: 1;
  flex-shrink: 0;
}

.layout-field {
  margin: 0;
  flex-shrink: 0;
  padding: 7px 8px;
}

#layoutSelectTop {
  width: 180px;
  flex: none;
}

#layoutNameInput {
  width: 180px;
}

[data-locked="true"] {
  position: relative;
  opacity: 0.68;
}

[data-locked="true"]::after {
  content: "bloqueado";
  display: inline-block;
  margin-left: 6px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.workflow-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-row-file {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.toolbar-spacer {
  margin-left: auto;
}

.toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--line);
}

.workflow-nav button {
  white-space: nowrap;
}

.workflow-nav button.active {
  border-color: var(--accent);
  background: #eef7fa;
  color: var(--accent-strong);
  font-weight: 700;
}

.workflow-nav .secondary-step {
  color: var(--muted);
}

.workflow-nav .history-btn {
  background: #f8fafc;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  padding: 8px 14px;
}

.workflow-nav .history-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workflow-nav button.has-step-warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.more-menu {
  position: relative;
}

.more-menu > summary {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.more-menu > summary::-webkit-details-marker {
  display: none;
}

.more-menu > summary::after {
  content: " ▾";
}

.more-menu:hover > summary,
.more-menu[open] > summary {
  border-color: var(--accent);
}

.more-menu[open] > summary {
  background: #eef7fa;
  color: var(--accent-strong);
}

.more-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

.more-menu-panel button,
.more-menu-panel .import-btn {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-size: 14px;
  padding: 8px 10px;
}

.workflow-warning {
  margin: 10px 14px 0;
  padding: 9px 11px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  line-height: 1.35;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(420px, 1fr) minmax(300px, 360px);
  grid-template-areas: "products preview tools";
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 128px);
}

.app-shell[data-active-step="products"] [data-step]:not([data-step~="products"]),
.app-shell[data-active-step="layout"] [data-step]:not([data-step~="layout"]),
.app-shell[data-active-step="database"] [data-step]:not([data-step~="database"]) {
  display: none;
}

.app-shell[data-active-step="database"] {
  grid-template-columns: 1fr;
  grid-template-areas: "products";
}

.sidebar,
.workspace {
  min-width: 0;
}

.app-shell > .sidebar:first-child {
  grid-area: tools;
}

.app-shell > .workspace {
  grid-area: preview;
}

.app-shell > .sidebar:last-child {
  grid-area: products;
}

section,
.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.04);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar section {
  overflow: hidden;
  padding: 0;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.panel-title::after {
  content: "▾";
  color: var(--muted);
  font-size: 13px;
}

.panel-collapsed .panel-title::after {
  content: "▸";
}

.panel-body {
  padding: 0 14px 14px;
}

.panel-collapsed .panel-body {
  display: none;
}

h3 {
  margin: 4px 0 8px;
  color: #344054;
  font-size: 13px;
}

label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #344054;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input[type="color"] {
  min-height: 38px;
  padding: 3px;
}

input[readonly],
textarea[readonly] {
  background: #eef2f6;
  color: var(--muted);
  cursor: default;
}

.layout-group {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.layout-group h3 {
  margin-top: 0;
}

.layout-group .grid-2:last-child,
.layout-group label:last-child {
  margin-bottom: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}

.check input {
  width: auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: 8px;
}

.search-grid {
  margin-bottom: 10px;
}

.search-grid input {
  min-width: 0;
}

.search-grid-compact {
  display: grid;
  grid-template-columns: 0.7fr 1.6fr 1fr;
  gap: 6px;
}

.search-main {
  margin-bottom: 8px;
}

.search-main input {
  width: 100%;
  font-weight: 600;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.tool-grid button,
.tool-grid .import-btn {
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
}

.tool-grid .import-btn.compact {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-grid button {
  position: relative;
}

.tool-grid button.tile-active,
.tool-grid button.template-active {
  border-color: var(--accent);
  background: #eef7fa;
  color: var(--accent-strong);
  font-weight: 700;
}

.tool-grid button.tool-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tool-grid button.tool-marked-remove {
  border-color: #d92d20;
  background: #fef3f2;
  color: #d92d20;
  outline: 2px solid #d92d20;
  outline-offset: -2px;
}

.tool-grid button.template-active {
  background: #eef2f6;
  color: #344054;
}

.tool-order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -2px 0 12px;
}

.panel-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-subhead h3 {
  margin: 10px 0 8px;
}

.mini-actions {
  display: inline-flex;
  gap: 4px;
}

.mini-actions button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.template-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -2px 0 12px;
}

.tile-count {
  position: absolute;
  top: 5px;
  right: 7px;
  min-width: 24px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
}

.workspace {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 14px;
  height: calc(150vh - 210px);
  overflow: hidden;
}

.workspace-sheet-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

.sheet-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable both-edges;
}

.sheet-center {
  min-width: min-content;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.1);
}

.zoom-controls button {
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-controls span {
  font-size: 12px;
  font-weight: 600;
  min-width: 38px;
  text-align: center;
  color: #344054;
}

.zoom-level-input {
  display: flex;
  align-items: center;
  gap: 2px;
}

.zoom-level-input input {
  width: 44px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  color: #344054;
  padding: 0;
  margin: 0;
  -moz-appearance: textfield;
}

.zoom-level-input input::-webkit-outer-spin-button,
.zoom-level-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.zoom-level-input input:focus {
  outline: 1px solid var(--primary, #2563eb);
  border-radius: 4px;
}

.workspace-header {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.workspace-header-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.workspace-search-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  position: relative;
}

.workspace-search-row .search-main {
  flex: 1 1 220px;
  margin-bottom: 0;
}

.workspace-search-row .search-grid-compact {
  flex: 1 1 320px;
  margin-bottom: 0;
}

.workspace-search-row .active-product-summary {
  flex: 1 1 100%;
  margin: 0;
  padding: 14px 16px;
}

.workspace-search-row .active-product-summary strong {
  font-size: 16px;
}

.workspace-search-row .active-product-summary span {
  font-size: 13px;
}

.workspace-search-row .product-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  z-index: 20;
}

.active-product-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 100%;
}

.active-product-line .active-product-summary {
  flex: 1 1 auto;
  margin: 0;
  padding: 10px 14px;
}

.active-product-line #changeProductBtn {
  flex-shrink: 0;
}

.product-search-expanded {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  flex: 1 1 100%;
}

.workspace-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.workspace-title h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 0;
}

#quickPrintBtn {
  font-size: 14px;
  padding: 8px 16px;
  flex-shrink: 0;
}


.sheet {
  --label-width: 120mm;
  --label-height: 80mm;
  --sheet-width: 210mm;
  --sheet-height: 297mm;
  --gap-x: 0mm;
  --gap-y: 0mm;
  --margin-x: 0mm;
  --margin-y: 0mm;
  --cols: 1;
  --rows: 1;
  margin: 26px 0;
  flex-shrink: 0;
  display: grid;
  align-content: start;
  justify-content: start;
  grid-template-columns: repeat(var(--cols), var(--label-width));
  grid-auto-rows: var(--label-height);
  gap: var(--gap-y) var(--gap-x);
  width: var(--sheet-width);
  min-height: var(--sheet-height);
  padding: var(--margin-y) var(--margin-x);
  background: #fff;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.15);
}

.sheet.show-grid {
  background-color: #fff;
  background-image:
    linear-gradient(to right, rgba(23, 107, 135, 0.11) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(23, 107, 135, 0.11) 1px, transparent 1px);
  background-size: 5mm 5mm;
  background-position: 0 0;
}

.sheet.roll-mode {
  grid-template-columns: var(--label-width);
  width: calc(var(--label-width) + 8mm);
  min-height: auto;
  padding: 4mm;
  gap: 3mm;
  background-color: #eef2f6;
}

.sheet.roll-mode.show-grid {
  background-color: #fff;
}

.sheet.roll-mode .label-page {
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.14);
}

.sheet.free-sheet-mode {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  height: var(--sheet-height);
  padding: 0;
}

.sheet.free-sheet-mode .label-page {
  width: 100%;
  height: 100%;
}

.label-page {
  position: relative;
  width: var(--label-width);
  height: var(--label-height);
  overflow: hidden;
  background: #fff;
}

.show-grid .label-page {
  background: transparent;
}

.cut-lines .label-page {
  outline: 1px dashed #98a2b3;
}

.sheet .label-page.primary-label {
  background-color: rgba(37, 99, 235, 0.08);
  outline: 1px solid rgba(37, 99, 235, 0.4);
  outline-offset: -1px;
}

.empty-label::after {
  content: "vazia";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #98a2b3;
  font-size: 10pt;
}

.label-element {
  position: absolute;
  min-width: 24px;
  min-height: 16px;
  padding: 2px 4px;
  cursor: move;
  user-select: none;
  white-space: pre-wrap;
  overflow: hidden;
}

.element-line {
  min-height: 2px;
  padding: 0;
  overflow: visible;
}

.label-element.element-line.selected {
  outline: none;
  background: transparent;
}

.element-image {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

.element-image img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  display: block;
}

.image-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 9pt;
  text-align: center;
}

.label-element.selected {
  outline: 2px solid var(--accent);
  background: rgba(23, 107, 135, 0.08);
}

.resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.35);
  cursor: nwse-resize;
}

.line-endpoint {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.35);
  cursor: grab;
  touch-action: none;
}

.element-barcode {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: end center;
  gap: 3px;
}

.barcode-svg {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: block;
}

.barcode-text {
  width: 100%;
  text-align: center;
  line-height: 1.05;
}

.barcode-error {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 24px;
  border: 1px dashed var(--danger);
  color: var(--danger);
  font-size: 8pt;
  text-align: center;
}

.barcode-status {
  margin: -2px 0 10px;
  padding: 7px 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.barcode-status.error {
  background: #fff1f2;
  color: var(--danger);
}

.barcode-status.ok {
  background: #ecfdf3;
  color: #027a48;
}

.barcode-status.warn {
  background: #fffaeb;
  color: #b54708;
}

.gs1-details {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.gs1-builder {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.qr-options {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.qr-options input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}

.qr-options #qrLogoRemoveBtn {
  justify-self: start;
}

.gs1-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.gs1-checks .check {
  font-size: 12px;
  margin: 0;
}

.gs1-checks .check.gs1-check-disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.gs1-checks .check.gs1-check-disabled input {
  cursor: not-allowed;
}

.gs1-builder textarea {
  min-height: 74px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.input-with-suffix {
  display: flex;
  align-items: stretch;
}

.input-with-suffix input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: #f1f5f9;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-weight: 600;
}

.barcode-type-label {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
  color: var(--text);
  box-sizing: border-box;
}

.element-variable-info {
  display: grid;
  gap: 6px;
  margin: -2px 0 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
}

.element-variable-info h3 {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.element-variable-info .variable-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.element-variable-info .variable-row span:first-child {
  color: var(--muted);
}

.element-variable-info .variable-row span:last-child {
  font-family: Consolas, "Courier New", monospace;
  text-align: right;
  word-break: break-all;
}

.gs1-ai-chips {
  gap: 5px;
}

.gs1-ai-chips button {
  padding: 5px 7px;
  border-radius: 999px;
  font-size: 11px;
}

.gs1-ai-chips button.chip-active {
  border-color: #98a2b3;
  background: #e4e7ec;
  color: #344054;
}

.gs1-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.gs1-row.error {
  border-color: #fda4af;
  background: #fff1f2;
}

.gs1-ai {
  font-weight: 700;
  color: var(--accent-strong);
}

.gs1-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.gs1-meta strong,
.gs1-meta span {
  overflow-wrap: anywhere;
}

.gs1-meta span {
  color: var(--muted);
  font-size: 12px;
}

.element-box {
  border: 1px solid currentColor;
  min-width: 40px;
  min-height: 28px;
}

.element-box.selected {
  background: transparent;
}

.hidden {
  display: none;
}

.product-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 360px;
  overflow: auto;
}

.product-results {
  margin-top: 10px;
}

.compact-results {
  max-height: 190px;
}

.compact-results .product-item {
  gap: 4px;
  padding: 8px;
}

.compact-results .product-actions {
  margin-top: 2px;
}

.import-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.import-overview > div:first-child {
  display: grid;
  gap: 3px;
}

.import-overview strong {
  font-size: 14px;
}

.import-overview span {
  color: var(--muted);
  font-size: 12px;
}

.import-overview.ok {
  border-color: #86efac;
  background: #ecfdf3;
}

.import-overview.warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.import-overview.error {
  border-color: #fda4af;
  background: #fff1f2;
}

.overview-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 150px;
}

.overview-metrics span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.compact-list {
  max-height: 180px;
}

.product-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.product-item.active {
  border-color: var(--accent);
  background: #eef7fa;
}

.product-item strong {
  font-size: 13px;
}

.product-item span {
  color: var(--muted);
  font-size: 12px;
}

.product-main-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.product-ref {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef7fa;
  color: var(--accent-strong) !important;
  font-weight: 700;
}

.product-code-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.product-code-row span {
  padding: 5px 6px;
  border: 1px solid #e7edf3;
  border-radius: 6px;
  background: #f8fafc;
}

.product-code-row b {
  color: #344054;
}

.product-issue {
  margin-top: 4px;
  padding: 6px 7px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.3;
}

.product-issue.warn {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.product-issue.error {
  border: 1px solid #fda4af;
  background: #fff1f2;
  color: var(--danger);
}

.import-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  cursor: pointer;
}

.import-btn.compact {
  display: grid;
  place-items: center;
  margin: 0;
  text-align: center;
}

.image-upload {
  display: grid;
  place-items: center;
  text-align: center;
}

.import-btn input {
  display: none;
}

.field-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.field-chip {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
}

.product-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.product-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

.queue-empty {
  margin: 0;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

/* ── Adicionar campos section ─────────────────────────────── */
#addFieldsDetails {
  margin-top: 12px;
}

#addFieldsDetails > summary.panel-subhead-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}

#addFieldsDetails > summary.panel-subhead-summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.15s;
}

#addFieldsDetails[open] > summary.panel-subhead-summary::before {
  transform: rotate(90deg);
}

.add-tool-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.add-tool-actions select {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

.add-tool-actions button {
  font-size: 12px;
  padding: 5px 10px;
  white-space: nowrap;
}
/* ── Country searchable dropdown ────────────────────────────── */
.country-select-wrap {
  position: relative;
}

.country-select-wrap input {
  width: 100%;
  box-sizing: border-box;
}

.country-dropdown {
  position: absolute;
  z-index: 200;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(16,24,40,0.12);
  font-size: 13px;
}

.country-dropdown.hidden { display: none; }

.country-option {
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.country-option:hover,
.country-option[aria-selected="true"] {
  background: var(--accent-light, #eff6ff);
}

.country-option .co-code {
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---------- Modais de sobreposição (pré-impressão, bulk download) ----------
   Secção restaurada: o editor.html referencia .print-check-modal /
   .print-check-box mas o CSS não existia — os modais abriam no fundo da
   página, fora do ecrã. */

.print-check-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 16px;
}

.print-check-modal.hidden { display: none; }

.print-check-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.3);
  padding: 20px 22px;
  width: min(540px, 94vw);
  max-height: 82vh;
  overflow: auto;
}

.print-check-box h2 { margin: 0 0 12px; font-size: 1.15rem; }

.print-check-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.validation-panel { display: flex; flex-direction: column; gap: 8px; }

.validation-item { padding: 8px 10px; border-radius: 8px; font-size: 0.88rem; }
.validation-item.error { background: #fdecea; color: #8a1f1f; border: 1px solid #f2b8b5; }
.validation-item.warn { background: #fff7e6; color: #7a5200; border: 1px solid #f2d9a0; }
.validation-item.ok { background: #e8f5ee; color: #14532d; border: 1px solid #bfe3cf; }

.batch-modal-box { width: min(560px, 94vw); }

.batch-name-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  font-size: 0.9rem;
}

.batch-name-row label { display: flex; align-items: center; gap: 5px; }

.batch-skipped-note { color: #7a5200; font-size: 0.85rem; }

/* ==========================================================================
   Impressão — imprimir APENAS a folha de etiquetas (#sheet), na mesma
   posição do preview (topo-esquerda da folha), ao tamanho físico real.
   Sem isto o browser imprime a página inteira; e um simples position:absolute
   falha porque o contentor .workspace-sheet-area (position:relative) fica na
   coluna do meio do grid — "left:0" seria o meio da página. Por isso
   neutralizamos toda a cadeia de contentores e deixamos a folha fluir.
   ========================================================================== */

@media print {
  @page { margin: 0; }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Esconder tudo o que não é a folha */
  .lp-header,
  .sidebar,
  .workspace-header,
  .zoom-controls,
  .workflow-nav,
  .workflow-warning,
  .demo-mode-banner,
  .print-check-modal,
  #batchDownloadModal,
  #cloudLayoutsModal,
  .more-menu,
  footer { display: none !important; }

  /* Neutralizar a cadeia de contentores (grid/flex/sticky/scroll/centragem)
     para a folha fluir a partir do canto superior esquerdo da página */
  .app-shell,
  .app-shell > .workspace,
  .workspace,
  .workspace-sheet-area,
  .sheet-scroll,
  .sheet-center {
    display: block !important;
    position: static !important;
    float: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    overflow: visible !important;
    align-items: flex-start !important;
  }

  /* A folha: posição natural (topo-esquerda), tamanho real, sem decoração */
  #sheet {
    position: static !important;
    margin: 0 !important;
    zoom: 1 !important;
    box-shadow: none !important;
    background-image: none !important;
    background-color: #fff !important;
    min-height: auto !important;
  }

  /* Remover realces só-de-ecrã dentro da folha */
  #sheet.show-grid { background-image: none !important; }
  #sheet .label-page { outline: none !important; background: #fff !important; }
  #sheet .label-page.primary-label { background-color: #fff !important; outline: none !important; }
  #sheet .cut-lines .label-page,
  #sheet.cut-lines .label-page { outline: none !important; }
  #sheet .label-element.selected { outline: none !important; }
  #sheet .resize-handle { display: none !important; }
}

/* Bulk download — campos extra do modal */
.batch-intro { color: var(--muted, #667085); font-size: 0.9rem; margin: 0 0 12px; }
.batch-field { margin: 10px 0; }
.batch-field label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.batch-field select { padding: 7px 9px; border: 1px solid var(--line, #d7dde5); border-radius: 8px; font: inherit; }
.batch-dim-note { color: var(--muted, #667085); font-size: 0.85rem; margin: 8px 0 4px; }
.batch-invalid { margin: 6px 0; font-size: 0.85rem; }
.batch-invalid summary { cursor: pointer; color: #7a5200; }
.batch-invalid ul { margin: 8px 0 0; padding-left: 18px; max-height: 160px; overflow: auto; }
.batch-invalid li { color: var(--muted, #667085); }

/* Aviso de ecrã pequeno no editor de etiquetas (fluxo de desktop) */
.mobile-editor-notice { display: none; }
@media (max-width: 820px) {
  .mobile-editor-notice {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; background: rgba(15, 23, 42, 0.6);
  }
  .mobile-editor-notice.dismissed { display: none; }
  .mobile-editor-notice-box {
    background: #fff; border-radius: 14px; padding: 26px 22px;
    max-width: 360px; text-align: center;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
  }
  .mobile-editor-notice-box strong { display: block; font-size: 1.05rem; margin-bottom: 8px; color: var(--text, #17202a); }
  .mobile-editor-notice-box p { color: var(--muted, #667085); font-size: 0.9rem; margin: 0 0 18px; }
  .mobile-editor-notice-box button {
    border: 0; border-radius: 9px; padding: 10px 18px; cursor: pointer;
    background: var(--accent, #176b87); color: #fff; font: inherit; font-weight: 600;
  }
}
