:root {
  color-scheme: dark;
  --shell: oklch(0.155 0.012 160);
  --panel: oklch(0.185 0.012 160);
  --surface: oklch(0.215 0.013 160);
  --surface-raised: oklch(0.25 0.014 160);
  --paper: oklch(0.985 0.004 100);
  --paper-ink: oklch(0.13 0.009 160);
  --ink: oklch(0.925 0.008 155);
  --muted: oklch(0.67 0.014 155);
  --line: oklch(0.29 0.014 160);
  --line-dark: oklch(0.36 0.016 160);
  --accent: oklch(0.76 0.09 158);
  --accent-ink: oklch(0.18 0.025 160);
  --danger: oklch(0.72 0.13 25);
  --sheet-scale: 1;
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--shell);
  color: var(--ink);
  font-family: var(--ui-font);
}

body.dragging,
body.dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

button,
input,
textarea,
select { font: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.appShell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 62px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--shell);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brandMark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--surface);
}

.brandMark img { width: 27px; height: 27px; filter: invert(.9) sepia(.08) saturate(.7); }

.brandCopy strong {
  display: block;
  font-size: 15px;
  font-weight: 750;
  line-height: 1;
}

.stationSwitcher {
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.stationSwitcher:hover { border-color: var(--accent); background: var(--surface-raised); }
.stationSwitcher span { min-width: 112px; }
.stationSwitcher small,
.stationSwitcher strong { display: block; }
.stationSwitcher small { color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stationSwitcher strong { margin-top: 2px; font-size: 10px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbarRight { margin-left: auto; }

/* Search Button before Nova Folha */
.toolButton.searchBtn {
  background: var(--surface-raised);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 800;
  padding: 0 13px;
  gap: 7px;
}

.toolButton.searchBtn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Primary Print Button */
.toolButton.primaryPrint {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
  font-size: 13px;
  padding: 8px 16px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolButton.primaryPrint:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.saveWrap { position: relative; }

.saveChooser {
  width: 238px;
  padding: 13px;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--surface-raised);
  box-shadow: 0 18px 48px oklch(0.04 0.01 160 / .5);
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 60;
}

.saveChooser p { margin: 0 0 10px; color: var(--ink); font-size: 12px; font-weight: 750; }
.saveGroupList { display: grid; gap: 5px; }
.saveGroupButton { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; font-weight: 720; text-align: left; }
.saveGroupButton:hover { border-color: var(--accent); color: var(--accent); }
.saveGroupButton small { color: var(--muted); font-size: 9px; font-weight: 650; }
.chooserCancel { width: 100%; margin-top: 8px; padding: 7px; border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.chooserCancel:hover { color: var(--ink); }

.toolbarDivider {
  width: 1px;
  height: 28px;
  margin: 0 7px;
  background: var(--line);
}

.toolButton {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .16s cubic-bezier(.25, 1, .5, 1), border-color .16s cubic-bezier(.25, 1, .5, 1), color .16s cubic-bezier(.25, 1, .5, 1);
}

.toolButton:hover:not(:disabled) {
  border-color: var(--line-dark);
  background: var(--surface-raised);
}

.toolButton:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.catalogItem:focus-visible,
.groupButton:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolButton:disabled {
  cursor: not-allowed;
  opacity: .35;
}

.toolButton.square { width: 38px; padding: 0; font-size: 20px; }

.toolButton.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.toolButton.primary:hover:not(:disabled) { background: oklch(0.82 0.1 158); }
.toolButton.danger { color: var(--danger); }

.pageCounter {
  min-width: 58px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.studio {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 280px;
}

.sidePanelBackdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: oklch(0.06 0.008 160 / .65);
}
.sidePanelBackdrop[hidden],
.leftPanel[hidden] { display: none; }

.leftPanel,
.inspector {
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
}

.leftPanel {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 31;
  width: min(280px, calc(100vw - 48px));
  border-right: 1px solid var(--line-dark);
  box-shadow: 12px 0 36px oklch(0.03 0.01 160 / .5);
}
.inspector {
  border-left: 1px solid var(--line-dark);
  width: 280px;
  grid-column: 2;
}

.panelSection { padding: 18px; }
.panelSection + .panelSection { border-top: 1px solid var(--line); }
.groupSection { padding-bottom: 14px; }
.catalogSection { min-height: 0; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1,
h2 { margin: 0; font-family: var(--ui-font); }
h1 { font-size: 20px; font-weight: 720; letter-spacing: -.025em; }
h2 { font-size: 18px; font-weight: 720; letter-spacing: -.02em; }

.sectionHeading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.groupList {
  margin-top: 14px;
  display: grid;
  gap: 5px;
}

.groupEntry { min-width: 0; }

.groupButton {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 31px 1fr auto;
  align-items: center;
  gap: 9px;
  text-align: left;
}

.groupButton:hover { border-color: var(--line); background: var(--surface); }
.groupButton.active { border-color: var(--line-dark); background: var(--surface-raised); color: var(--accent); }

.trashNavDivider { height: 1px; margin: 9px 10px 6px; background: var(--line); }
.trashNavButton { color: var(--muted); }
.trashNavButton:hover { color: var(--ink); }
.trashBadge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
}
.trashBadge.hasItems { border-color: oklch(0.56 0.09 25); background: oklch(0.28 0.045 25); color: oklch(0.83 0.08 25); }

.trashIcon,
.trashIconLarge {
  width: 19px;
  height: 21px;
  border: 1.5px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
  display: block;
  position: relative;
}
.trashIcon { margin-left: 3px; }
.trashIcon::before,
.trashIconLarge::before {
  content: "";
  width: calc(100% + 6px);
  height: 1.5px;
  background: currentColor;
  position: absolute;
  left: -3px;
  top: -4px;
}
.trashIcon::after,
.trashIconLarge::after {
  content: "";
  width: 7px;
  height: 3px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  position: absolute;
  left: 4px;
  top: -8px;
}

.folderIcon {
  width: 25px;
  height: 19px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  display: block;
  position: relative;
}

.folderIcon::before {
  content: "";
  width: 12px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  position: absolute;
  left: -2px;
  top: -7px;
}

.groupButton > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.groupName { display: block; font-size: 13px; font-weight: 900; }
.groupCount { display: block; color: var(--muted); font-size: 9px; font-weight: 800; }

.savedPageList { margin: 4px 0 7px 34px; padding-left: 9px; border-left: 1px solid var(--line); display: grid; gap: 3px; }
.savedPageButton { width: 100%; min-height: 34px; padding: 5px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.savedPageButton:hover { background: var(--surface); color: var(--ink); }
.savedPageButton.active { border-color: var(--line-dark); background: var(--surface); color: var(--accent); }
.savedPageButton span { font-size: 10px; font-weight: 720; }
.savedPageButton small { font-size: 9px; font-weight: 650; }
.emptyGroupLabel { margin: 5px 0 9px 44px; color: var(--muted); font-size: 9px; }

.catalogSection h2 { margin-bottom: 12px; }

.catalogTabs {
  margin-bottom: 10px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--shell);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 3px;
}

.catalogTab {
  min-width: 0;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  font-size: 10px;
  font-weight: 850;
}

.catalogTab:hover { color: var(--ink); }
.catalogTab.active { border-color: var(--line-dark); background: var(--surface-raised); color: var(--accent); }
.catalogTab small { min-width: 24px; color: inherit; font-size: 8px; font-weight: 950; text-align: right; }
.catalogTab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.searchBox {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.searchBox > span { font-size: 23px; transform: rotate(-15deg); }
.searchBox input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 13px; font-weight: 700; }
.searchBox kbd { padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; }

.catalogMeta {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.catalogList {
  max-height: calc(100vh - 405px);
  min-height: 140px;
  display: grid;
  align-content: start;
  gap: 4px;
  overflow: auto;
}

.catalogItem {
  width: 100%;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: start;
  gap: 8px;
  text-align: left;
  transition: border-color .13s ease, transform .13s ease;
}

.catalogItem:hover { border-color: var(--line-dark); background: var(--surface); }
.itemCode { font-size: 10px; font-weight: 950; letter-spacing: .02em; }
.itemName { font-size: 11px; font-weight: 800; line-height: 1.3; }

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--shell);
}

.workspaceBar {
  min-height: 57px;
  padding: 9px 17px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.workspaceBarMeta {
  display: flex;
  flex-direction: column;
}

.workspaceBar strong { font-size: 15px; font-weight: 730; }
.workspaceBar .eyebrow { margin-bottom: 1px; }

.paperColorControl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.paperColorLabel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.paperColorLabel i {
  width: 13px;
  height: 13px;
}

.paperColorGroup {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--shell);
  gap: 3px;
}

.paperColorBtn {
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  transition: all .15s ease;
}

.paperColorBtn:hover:not(.active) {
  background: var(--surface);
  color: var(--ink);
}

.paperColorBtn.active {
  border-color: var(--line-dark);
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.colorSwatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.swatchWhite {
  background-color: #FFFFFF;
  border: 1px solid #B0B0B0;
}

.swatchYellow {
  background-color: #FFE600;
  border: 1px solid #CCA000;
}

.swatchRed {
  background-color: #C62828;
  border: 1px solid #8E0000;
}

.workspaceHint { max-width: 420px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 700; text-align: right; }

@media (max-width: 960px) {
  .workspaceHint { display: none; }
}

.workspaceScroll {
  min-width: 0;
  min-height: 0;
  padding: 34px;
  overflow: auto;
  background-color: var(--shell);
  background-image: radial-gradient(var(--line) .8px, transparent .8px);
  background-size: 18px 18px;
}

.sheetScaler { margin: 0 auto; position: relative; }

.sheet,
.printSheet {
  width: 210mm;
  height: 297mm;
  position: relative;
  overflow: hidden;
  background: var(--paper);
  color: var(--paper-ink);
  transform-origin: top left;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  transition: background-color .2s ease, color .2s ease;
}

/* ========================================================
   Paper Colors & High-Contrast Support (White / Yellow / Red)
   ======================================================== */
.sheet[data-paper-color="white"],
.printSheet[data-paper-color="white"] {
  --paper: #FFFFFF;
  --paper-ink: #111827;
  --paper-border: #111827;
  --paper-divider: #111827;
  --paper-watermark: rgba(0, 0, 0, 0.12);
  background-color: #FFFFFF;
  color: #111827;
}

.sheet[data-paper-color="blue"],
.printSheet[data-paper-color="blue"] {
  --paper: #64A8DE;
  --paper-ink: #111827;
  --paper-border: #111827;
  --paper-divider: #111827;
  --paper-watermark: rgba(0, 0, 0, 0.12);
  background-color: #64A8DE !important;
  color: #111827;
}
.swatchBlue { background: #64A8DE; }

.sheet[data-paper-color="yellow"],
.printSheet[data-paper-color="yellow"] {
  --paper: #FFE600;
  --paper-ink: #000000;
  --paper-border: #000000;
  --paper-divider: #000000;
  --paper-watermark: rgba(0, 0, 0, 0.15);
  background-color: #FFE600;
  color: #000000;
}

.sheet[data-paper-color="red"],
.printSheet[data-paper-color="red"] {
  --paper: #C62828;
  --paper-ink: #FFFFFF;
  --paper-border: #FFFFFF;
  --paper-divider: rgba(255, 255, 255, 0.9);
  --paper-watermark: rgba(255, 255, 255, 0.25);
  background-color: #C62828;
  color: #FFFFFF;
}

/* Enforce high contrast for elements on colored paper */
.sheet[data-paper-color="red"] .editorElement,
.printSheet[data-paper-color="red"] .printElement {
  color: #FFFFFF;
}

.sheet[data-paper-color="red"] .editorElement.label,
.printSheet[data-paper-color="red"] .printElement.label {
  border-color: #FFFFFF;
}

.sheet[data-paper-color="red"] .labelDivider,
.printSheet[data-paper-color="red"] .labelDivider {
  border-top-color: rgba(255, 255, 255, 0.9);
}

.sheet[data-paper-color="red"] .labelLogo,
.printSheet[data-paper-color="red"] .labelLogo {
  filter: brightness(0) invert(1);
}

.sheet[data-paper-color="yellow"] .editorElement,
.printSheet[data-paper-color="yellow"] .printElement {
  color: #000000;
}

.sheet[data-paper-color="yellow"] .editorElement.label,
.printSheet[data-paper-color="yellow"] .printElement.label {
  border-color: #000000;
}

.sheet[data-paper-color="yellow"] .labelDivider,
.printSheet[data-paper-color="yellow"] .labelDivider {
  border-top-color: #000000;
}

.sheet[data-paper-color="yellow"] .labelLogo,
.printSheet[data-paper-color="yellow"] .labelLogo {
  filter: none;
}

.sheet {
  transform: scale(var(--sheet-scale));
  box-shadow: 0 18px 60px oklch(0.04 0.01 160 / .55);
}

.sheet.textMode { cursor: crosshair; }

.sheet::after {
  content: "ÁREA A4";
  position: absolute;
  right: 5mm;
  bottom: 4mm;
  color: var(--paper-watermark, oklch(0.78 0.005 100));
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .2em;
  pointer-events: none;
}

.editorElement,
.printElement {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 8mm;
  min-height: 6mm;
  color: var(--paper-ink);
  text-align: center;
  line-height: 1.08;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
  font-family: var(--ui-font);
}

.editorElement.label,
.printElement.label { border: .35mm solid var(--paper-ink); }

.editorElement.selected { outline: 1mm solid var(--accent); outline-offset: 1mm; overflow: visible; z-index: 5; }
.elementInner { width: 100%; padding: 1mm 1.5mm 1.25mm; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6mm; }
.label .elementInner {
  width: 100%;
  height: 100%;
  padding-left: 9mm;
  padding-right: 1.5mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.labelLogoWrap {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.labelLogoWrap:active {
  cursor: grabbing;
}
.editorElement.selected .labelLogoWrap {
  outline: .35mm dashed rgba(16, 21, 18, 0.45);
  outline-offset: .3mm;
}
.editorElement.selected .labelLogoWrap:hover {
  outline-color: var(--accent);
  background: rgba(122, 222, 178, 0.12);
}
.labelLogo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.logoResizeHandle {
  position: absolute;
  right: -1.3mm;
  bottom: -1.3mm;
  width: 2.8mm;
  height: 2.8mm;
  border: .35mm solid var(--paper);
  background: var(--accent);
  border-radius: 50%;
  cursor: nwse-resize;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.labelText {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3mm;
}
.drawerLabel .labelText { align-items: flex-start; text-align: left; }
.labelName { display: block; font-size: calc(1em + 1.5px); font-weight: 800; line-height: 1.1; word-break: break-word; }
.labelSizeP .labelName { font-size: 1em; font-weight: 700; }
.labelSizeP .labelCode { font-weight: 700; }
.standardBoldLabel .labelName,
.standardBoldLabel .labelCode { font-weight: 700; }
.labelDivider {
  display: block;
  align-self: center;
  width: 16mm;
  max-width: 65%;
  height: 0;
  border-top: .3mm solid var(--paper-ink);
  margin: .4mm auto;
  opacity: .85;
  transform: translateX(-3.75mm);
}
.labelCode {
  display: block;
  align-self: center;
  font-size: calc(.65em + 1px);
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.1;
  text-align: center;
  transform: translateX(-3.75mm);
}

.resizeHandle {
  width: 3.2mm;
  height: 3.2mm;
  border: .5mm solid var(--paper);
  background: var(--accent-ink);
  position: absolute;
  z-index: 9;
}

.resizeHandle[data-handle="nw"] { left: -2.2mm; top: -2.2mm; cursor: nwse-resize; }
.resizeHandle[data-handle="n"] { left: calc(50% - 1.6mm); top: -2.2mm; cursor: ns-resize; }
.resizeHandle[data-handle="ne"] { right: -2.2mm; top: -2.2mm; cursor: nesw-resize; }
.resizeHandle[data-handle="e"] { right: -2.2mm; top: calc(50% - 1.6mm); cursor: ew-resize; }
.resizeHandle[data-handle="se"] { right: -2.2mm; bottom: -2.2mm; cursor: nwse-resize; }
.resizeHandle[data-handle="s"] { left: calc(50% - 1.6mm); bottom: -2.2mm; cursor: ns-resize; }
.resizeHandle[data-handle="sw"] { left: -2.2mm; bottom: -2.2mm; cursor: nesw-resize; }
.resizeHandle[data-handle="w"] { left: -2.2mm; top: calc(50% - 1.6mm); cursor: ew-resize; }

.propertiesPanel { padding: 18px 16px; border-bottom: 0; transition: opacity .15s ease; }
.propertiesPanel.noSelection {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.6);
}

/* Lucide Icons */
[data-lucide],
.lucide {
  width: 15px;
  height: 15px;
  stroke-width: 2.2px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.toolButton [data-lucide],
.toolButton .lucide {
  width: 15px;
  height: 15px;
}

.stepButton [data-lucide],
.stepButton .lucide {
  width: 12px;
  height: 12px;
}

.primaryPrint [data-lucide],
.primaryPrint .lucide {
  width: 17px;
  height: 17px;
}

.searchBtn [data-lucide],
.searchBtn .lucide {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.segmented button [data-lucide],
.segmented button .lucide {
  width: 14px;
  height: 14px;
}

.modalClose [data-lucide],
.modalClose .lucide {
  width: 18px;
  height: 18px;
}

.catalogModalIcon [data-lucide],
.catalogModalIcon .lucide {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.field { margin-bottom: 13px; display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .035em; text-transform: uppercase; }
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: normal;
  text-transform: none;
}

.field textarea { min-height: 86px; resize: vertical; }
.fieldRow { display: grid; grid-template-columns: 1fr 1.2fr; gap: 9px; }
.fieldGroupLabel { margin: 2px 0 9px; color: var(--ink); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.measureGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.measureControl { display: flex; align-items: center; border: 1px solid var(--line-dark); border-radius: 6px; background: var(--surface); overflow: hidden; }
.measureControl input { min-width: 0; border: 0; border-radius: 0; background: transparent; }
.measureControl span { padding-right: 9px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: lowercase; }
.segmented { margin-bottom: 14px; display: grid; grid-template-columns: repeat(3, 1fr); }
.segmented button { min-height: 34px; border: 1px solid var(--line-dark); background: var(--surface); color: var(--ink); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.segmented button + button { border-left: 0; }
.segmented button.active { background: var(--accent); color: var(--accent-ink); }
.editSaveBlock {
  margin: 4px 0 14px;
  padding: 10px;
  border: 1px solid color-mix(in oklch, var(--accent) 38%, var(--line));
  border-radius: 8px;
  background: color-mix(in oklch, var(--accent) 7%, var(--surface));
}
.saveElementButton { width: 100%; min-height: 38px; }
.editStatus {
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
}
.editStatus[data-state="dirty"] { color: var(--accent); }
.editStatus[data-state="saved"] { color: var(--ink); }
.elementActions { display: grid; grid-template-columns: 1fr auto; gap: 7px; }

.toast {
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 10px 32px oklch(0.04 0.01 160 / .45);
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  font-size: 12px;
  font-weight: 850;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.printStage { display: none; }

.modalBackdrop {
  padding: 24px;
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: oklch(0.06 0.008 160 / .8);
  backdrop-filter: blur(5px);
}
.modalBackdropTop { z-index: 110; }
.stationBackdrop { z-index: 120; }
.modalPanel {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 1px solid var(--line-dark);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 28px 90px oklch(0.03 0.01 160 / .72);
  overflow: auto;
}
.trashPanel { padding: 22px; }
.passwordPanel { width: min(440px, 100%); padding: 22px; }
.sizeChoicePanel { width: min(560px, 100%); padding: 22px; }
.stationPanel { width: min(560px, 100%); padding: 22px; }
.stationChoiceList { display: grid; gap: 8px; }
.stationChoiceButton {
  width: 100%;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}
.stationChoiceButton:hover,
.stationChoiceButton:focus-visible { border-color: var(--accent); background: var(--surface-raised); outline: none; }
.stationChoiceButton > svg { color: var(--accent); }
.stationChoiceButton strong,
.stationChoiceButton small { display: block; }
.stationChoiceButton strong { font-size: 13px; }
.stationChoiceButton small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.catalogCreatePanel { width: min(500px, 100%); padding: 22px; }
.sizeChoiceList { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sizeChoiceButton {
  min-height: 112px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  cursor: pointer;
  text-align: center;
}
.sizeChoiceButton:hover,
.sizeChoiceButton:focus-visible { border-color: var(--accent); background: var(--surface-raised); outline: none; }
.sizeChoiceNumber { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 950; }
.sizeChoiceButton strong,
.sizeChoiceButton small { display: block; }
.sizeChoiceButton strong { font-size: 13px; }
.sizeChoiceButton small { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 700; }
.catalogModalPanel {
  width: min(860px, 95vw);
  max-height: min(800px, calc(100vh - 48px));
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.catalogModalIcon { font-size: 24px; line-height: 1; }
.catalogModalControls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.catalogModalSearchBox {
  height: 44px;
}
.catalogModalSearchBox input {
  font-size: 14px;
}
.catalogListModal {
  max-height: 460px;
  min-height: 220px;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
  padding: 6px 2px 10px 2px;
}
.catalogListModal .catalogItem {
  min-height: 56px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.catalogListModal .catalogItem:hover {
  border-color: var(--accent);
  background: var(--surface-raised);
  transform: translateY(-1px);
}
.catalogListModal .itemCode {
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
}
.catalogListModal .itemName {
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  color: var(--ink);
}
.catalogEmptyAction {
  min-height: 220px;
  padding: 22px;
  border: 1px dashed var(--line-dark);
  border-radius: 9px;
  grid-column: 1 / -1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}
.catalogEmptyAction > svg { width: 30px; height: 30px; color: var(--accent); }
.catalogEmptyAction strong { color: var(--ink); font-size: 13px; }
.catalogEmptyAction p { margin: 0 0 5px; font-size: 10px; }
.catalogModalFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}
.catalogHint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.modalHeader { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.modalHeader.compact { grid-template-columns: auto 1fr; }
.modalHeader .eyebrow { margin-bottom: 3px; }
.modalHeader h2 { display: flex; align-items: center; gap: 9px; }
.modalIcon { color: var(--danger); }
.trashIconLarge { width: 25px; height: 28px; color: var(--muted); }
.modalCount { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--surface-raised); color: var(--muted); display: inline-grid; place-items: center; font-size: 10px; }
.modalClose { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 24px; line-height: 1; }
.modalClose:hover { border-color: var(--line-dark); color: var(--ink); }
.modalIntro { margin: 16px 0 18px; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.55; }
.trashList { display: grid; gap: 8px; }
.trashEmpty { min-height: 240px; border: 1px dashed var(--line-dark); border-radius: 9px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.trashEmpty strong { margin-top: 16px; color: var(--ink); font-size: 14px; }
.trashEmpty p { margin: 6px 0 0; font-size: 10px; }
.trashItem { padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.trashItemCopy { min-width: 0; }
.trashItemMeta { margin-bottom: 6px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; font-weight: 800; }
.trashItemMeta span { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.trashItem strong { display: block; font-size: 13px; }
.trashItem p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.trashItemActions { display: flex; align-items: center; gap: 6px; }
.restoreButton { color: var(--accent); }
.lockIcon { width: 28px; height: 23px; border: 1.5px solid var(--danger); border-radius: 4px; display: block; position: relative; }
.lockIcon::before { content: ""; width: 14px; height: 13px; border: 1.5px solid var(--danger); border-bottom: 0; border-radius: 9px 9px 0 0; position: absolute; left: 5px; top: -12px; }
.passwordField { margin: 0; }
.formError { margin: 9px 0 0; padding: 9px 10px; border: 1px solid oklch(0.48 0.11 25); border-radius: 6px; background: oklch(0.22 0.04 25); color: oklch(0.85 0.08 25); font-size: 10px; font-weight: 750; line-height: 1.4; }
.modalActions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 7px; }
.toolButton.dangerSolid { border-color: var(--danger); background: var(--danger); color: oklch(0.16 0.035 25); }
.toolButton.dangerSolid:hover:not(:disabled) { background: oklch(0.78 0.14 25); }

@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; }
  .studio {
    grid-template-columns: minmax(280px, 1fr) 270px;
  }
  .inspector {
    width: 270px;
    grid-column: 2;
    border-top: 0;
    border-left: 1px solid var(--line-dark);
  }
}

@media (max-width: 860px) {
  .topbar { position: static; flex-wrap: wrap; gap: 8px; }
  .toolbarRight { margin-left: auto; }
  .studio {
    grid-template-columns: minmax(220px, 1fr) 250px;
    min-width: 620px;
    overflow-x: auto;
  }
  .inspector {
    width: 250px;
    grid-column: 2;
    border-top: 0;
    border-left: 1px solid var(--line-dark);
  }
  .workspaceScroll { padding: 12px; }
  .modalBackdrop { padding: 12px; }
  .modalPanel { max-height: calc(100vh - 24px); }
  .trashItem { grid-template-columns: 1fr; }
  .trashItemActions { justify-content: stretch; }
  .trashItemActions .toolButton { flex: 1; }
}

@media (max-width: 520px) {
  .sizeChoiceList { grid-template-columns: 1fr; }
  .sizeChoiceButton { min-height: 72px; grid-template-columns: auto 1fr; justify-items: start; text-align: left; }
}

.logoHeaderRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
}

.miniButton {
  padding: 2px 7px;
  font-size: 10px;
  height: auto;
  line-height: 1.3;
}

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

.logoStepWrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepButton {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.stepButton:hover {
  background: var(--line);
}

.logoCoordsWrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.miniMeasure {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.miniMeasure input {
  width: 50px;
  padding: 3px 5px;
  font-size: 11px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.checkboxField {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--ink);
  user-select: none;
}

.checkboxField input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Step Row for Size Inputs */
.stepRow {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepRow input {
  flex: 1;
  text-align: center;
  min-width: 75px;
}

.sizeFieldRow { grid-template-columns: minmax(139px, 1fr) minmax(0, 1fr); }

.logoSimpleRow {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hintText {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

/* Advanced Accordion */
.advancedAccordion {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.advancedSummary {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, color .12s;
}

.advancedSummary::-webkit-details-marker { display: none; }

.advancedSummary:hover {
  color: var(--ink);
  background: var(--surface-raised);
}

.advancedBody {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

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

  html,
  body { width: 210mm; min-width: 0; background: transparent !important; }

  .appShell,
  .modalBackdrop,
  .toast { display: none !important; }

  .printStage { display: block !important; }

  .printSheet {
    box-shadow: none;
    page-break-after: always;
    break-after: page;
    width: 210mm;
    height: 297mm;
    position: relative;
    overflow: hidden;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .printSheet:last-child { page-break-after: auto; break-after: auto; }

  .printSheet[data-paper-color="white"] {
    background-color: #FFFFFF !important;
    color: #111827 !important;
  }

  .printSheet[data-paper-color="yellow"] {
    background-color: #FFE600 !important;
    color: #000000 !important;
  }

  .printSheet[data-paper-color="red"] {
    background-color: #C62828 !important;
    color: #FFFFFF !important;
  }

  .printSheet[data-paper-color="red"] .labelLogo {
    filter: brightness(0) invert(1) !important;
  }

  .printSheet[data-paper-color="red"] .printElement.label {
    border-color: #FFFFFF !important;
  }

  .printSheet[data-paper-color="red"] .labelDivider {
    border-top-color: rgba(255, 255, 255, 0.9) !important;
  }

  .printSheet[data-paper-color="yellow"] .printElement.label {
    border-color: #000000 !important;
  }

  .printSheet[data-paper-color="yellow"] .labelDivider {
    border-top-color: #000000 !important;
  }

  .printElement {
    text-rendering: geometricPrecision;
  }

  .logoResizeHandle,
  .resizeHandle {
    display: none !important;
  }

  .labelLogoWrap {
    cursor: default !important;
    outline: none !important;
  }
}

/* Category colors apply equally to saved sheets, drafts and print. */
.sheet[data-group-id="mpp"],
.printSheet[data-group-id="mpp"] {
  --paper: #C62828;
  --paper-ink: #000000;
  --paper-border: #000000;
  --paper-divider: #000000;
  background-color: #C62828 !important;
  color: #000000 !important;
}
.sheet[data-group-id="controlados"],
.printSheet[data-group-id="controlados"] {
  --paper: #FFE600;
  --paper-ink: #000000;
  background-color: #FFE600 !important;
  color: #000000 !important;
}
:is(.sheet, .printSheet):is([data-group-id="mpp"], [data-group-id="controlados"]) :is(.editorElement.label, .printElement.label) {
  color: #000000 !important;
  border-color: #000000 !important;
}
:is(.sheet, .printSheet):is([data-group-id="mpp"], [data-group-id="controlados"]) .labelDivider { border-top-color: #000000 !important; }
.sheet[data-group-id="mpp"] .labelLogo,
.printSheet[data-group-id="mpp"] .labelLogo,
.sheet[data-group-id="controlados"] .labelLogo,
.printSheet[data-group-id="controlados"] .labelLogo { filter: none !important; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
