:root {
  color-scheme: light;
  --ink: #183d5c;
  --muted: #607d95;
  --accent: #c8e7fb;
  --accent-hover: #afd9f5;
  --accent-ink: #225b84;
  --soft: #edf7ff;
  --line: #dcebf7;
  --label-width: 100mm;
  --label-height: 60mm;
  --label-margin: 3mm;
  --number-size: 20pt;
  --code-width: 90mm;
  --code-height: 40mm;
  --preview-scale: 1;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #f2f8fe;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: not-allowed; }
button:focus-visible, a:focus-visible { outline: 3px solid #79b9e8; outline-offset: 4px; }
[hidden] { display: none !important; }
.topbar { min-height: 72px; padding: 0 max(24px, calc((100vw - 1100px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: #fbfdff; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 25px; font-weight: 750; letter-spacing: -.9px; }
.brand-dot { color: #68b2e6; }
.brand-icon { width: 36px; height: 36px; border-radius: 11px; background: #bce1f9; display: grid; place-items: center; }
.brand-icon svg { width: 24px; fill: var(--ink); }
.brand-icon circle { fill: #bce1f9; }
.connection { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.status-dot, .live-badge span { width: 7px; height: 7px; background: #bacbd8; border-radius: 50%; flex: 0 0 auto; }
.connection.connected .status-dot { background: #58a6dd; box-shadow: 0 0 0 4px #e6f3ff; }
.connection.failed .status-dot { background: #c45145; }
.workspace { max-width: 1100px; margin: 0 auto; padding: 32px 24px 20px; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow, .small-label { font-size: 10px; letter-spacing: 1.5px; font-weight: 700; }
.eyebrow { color: var(--accent-ink); margin: 0 0 9px; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.2; font-weight: 650; letter-spacing: -1px; margin: 0; }
.intro-copy { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 12px 0 0; }
.paper-badge { display: flex; align-items: center; gap: 12px; border: 1px solid #d4e7f7; border-radius: 12px; padding: 15px 18px; background: #eaf6ff; flex: 0 0 auto; }
.paper-badge svg, .paper-fixed svg { width: 25px; height: 25px; stroke: #539bcd; stroke-width: 1.5; fill: none; flex: 0 0 auto; }
.paper-badge strong, .paper-fixed strong { display: block; font-size: 16px; font-weight: 650; }
.paper-badge span, .paper-fixed span { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
.message { padding: 13px 16px; border-radius: 10px; border: 1px solid #cce5f8; background: #eaf6ff; color: #235f8a; font-size: 12px; line-height: 1.7; margin: 0 0 20px; }
.message.error { color: #9e362b; border-color: #efd2cc; background: #fff1ed; }
.message.warning { color: #846125; border-color: #edddb6; background: #fff8e7; }
.editor-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr); gap: 22px; align-items: start; }
.controls-column { display: grid; gap: 20px; min-width: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 4px 16px #377dbb05; min-width: 0; }
.generation-card, .batch-card, .preview-card { padding: 23px; }
.section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.step { font-size: 10px; font-weight: 700; border: 1px solid #d6e8f6; color: #5a8aae; background: #f0f8ff; width: 29px; height: 29px; flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; }
h2 { font-size: 16px; line-height: 1.35; letter-spacing: -.3px; margin: 2px 0 0; font-weight: 650; }
.section-heading p { font-size: 11px; color: var(--muted); margin: 5px 0 0; line-height: 1.5; }
.counter-card { background: #f0f8ff; border: 1px solid #dcecf9; border-radius: 10px; padding: 13px 15px; margin-bottom: 19px; }
.counter-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.small-label { color: #6085a3; font-size: 9px; letter-spacing: .7px; }
.readonly-badge { font-size: 9px; color: #7191a9; }
.counter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 0; }
.counter-row strong { font-size: 31px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; min-width: 0; }
.icon-button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid #d0e3f2; background: #f8fcff; color: #4b87b1; display: grid; place-items: center; flex: 0 0 auto; }
.icon-button:hover:not(:disabled) { background: #e4f2fc; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
label { display: block; font-size: 12px; font-weight: 600; color: #50728e; margin-bottom: 8px; }
input { display: block; width: 100%; min-width: 0; height: 46px; border: 1px solid #d3e3ef; border-radius: 8px; background: #fff; color: var(--ink); padding: 0 12px; outline: none; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: #80b9e3; box-shadow: 0 0 0 3px #74b9ec18; }
input:disabled { background: #f4f9fd; }
.generate-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.generate-row input { font-size: 18px; font-weight: 600; }
.button { min-height: 46px; border-radius: 8px; padding: 0 17px; border: 1px solid transparent; font-size: 12px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background .15s; }
.button.primary { background: var(--accent); border-color: #b9dcf4; color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { border-color: #d4e3ef; color: #50718c; background: #f8fbfe; }
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.field-help { font-size: 10px; color: var(--muted); line-height: 1.7; margin: 9px 0 0; }
.reservation-note { display: flex; align-items: flex-start; gap: 9px; font-size: 10px; line-height: 1.7; color: #6b87a0; border-top: 1px solid #eaf2f9; padding-top: 15px; margin-top: 16px; }
.reservation-note svg { width: 17px; height: 19px; flex-shrink: 0; fill: none; stroke: #79aacd; stroke-width: 1.4; }
.preview-heading, .batch-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.preview-heading .section-heading { margin-bottom: 18px; }
.settings-trigger { background: #e9f5fe; border-color: #cfe6f7; }
.settings-trigger svg { width: 22px; height: 22px; }
.format-summary-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.format-summary-row strong { font-size: 22px; font-weight: 600; letter-spacing: -.5px; }
.format-state { background: #eef7ff; border: 1px solid #dcecf9; color: #6089a8; font-size: 10px; border-radius: 5px; padding: 5px 8px; }
.format-state.temporary { color: #865e25; background: #fff7e7; border-color: #efddb6; }
.format-details { font-size: 11px; color: #6d88a0; line-height: 1.7; margin: 8px 0 17px; }
.preview-stage { background-color: #edf6fd; background-image: radial-gradient(#bed8ed 1px, transparent 1px); background-size: 13px 13px; border: 1px solid #dceaf6; border-radius: 10px; padding: 40px 18px 36px; position: relative; overflow: hidden; }
.dimension { position: absolute; left: 50%; transform: translateX(-50%); font-size: 10px; color: #81a0b8; letter-spacing: .3px; white-space: nowrap; }
.dimension-top { top: 14px; }
.dimension-bottom { bottom: 12px; }
#preview-label { width: calc(var(--label-width) * var(--preview-scale)); height: calc(var(--label-height) * var(--preview-scale)); margin: 0 auto; }
#preview-label .label { transform: scale(var(--preview-scale)); transform-origin: top left; box-shadow: 0 6px 18px #28659212; border-radius: 2px; }
.preview-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; font-size: 10px; color: #6d88a0; line-height: 1.7; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #d8eaf8; border-radius: 20px; padding: 5px 9px; font-size: 9px; color: #6c96b6; background: #f3faff; white-space: nowrap; }
.live-badge span { width: 5px; height: 5px; background: #79b5e0; }
.preview-notes { border-top: 1px solid #eaf2f9; padding-top: 13px; margin-top: 16px; }
.preview-notes p { color: #7893aa; font-size: 10px; line-height: 1.7; margin: 0; }
.preview-notes p + p { margin-top: 6px; }
.batch-heading { margin-bottom: 18px; align-items: center; }
.batch-heading .eyebrow { font-size: 9px; margin-bottom: 5px; }
.batch-empty { display: grid; justify-items: center; text-align: center; padding: 9px 4px 18px; }
.empty-icon { width: 40px; height: 40px; background: #eff8ff; border: 1px solid #daebf8; border-radius: 11px; display: grid; place-items: center; color: #8db9d8; font-size: 23px; margin-bottom: 12px; }
.batch-empty strong { font-size: 12px; font-weight: 600; }
.batch-empty p { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 6px 0 0; }
.batch-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.batch-summary strong { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.batch-summary span { color: #5a8aae; background: #edf7ff; padding: 5px 8px; border-radius: 5px; font-size: 10px; }
.batch-samples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.batch-samples span { border: 1px solid #dceaf6; background: #f5faff; border-radius: 5px; padding: 6px 10px; color: #5d87a7; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.batch-actions { border-top: 1px solid #eaf2f9; padding-top: 12px; margin-top: 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #829aaf; font-size: 9px; line-height: 1.6; }
.text-button { background: none; border: 0; padding: 3px 0; color: var(--accent-ink); font-size: 10px; font-weight: 600; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }
.print-tip { border: 1px solid #dcecf9; background: #f1f9ff; padding: 12px 13px; border-radius: 8px; margin-top: 16px; }
.print-tip strong { font-size: 10px; color: #567e9e; font-weight: 650; }
.print-tip p { font-size: 10px; color: #7892a8; line-height: 1.7; margin: 5px 0 0; }
.validation-error { color: #a53f32; font-size: 11px; line-height: 1.7; margin: 14px 0 0; }
.footer { display: flex; justify-content: space-between; gap: 16px; font-size: 9px; color: #8aa1b5; padding: 23px 0 6px; line-height: 1.7; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Modal: solo cambia el contenido, nunca el tamaño del papel. */
.modal-open { overflow: hidden; }
.settings-dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #d4e7f6; border-radius: 16px; background: #fff; color: var(--ink); box-shadow: 0 24px 80px #20456430; overflow-y: auto; overscroll-behavior: contain; }
.settings-dialog::backdrop { background: #1c416363; backdrop-filter: blur(4px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 23px; border-bottom: 1px solid #eaf2f9; background: #fff; position: sticky; top: 0; z-index: 1; }
.modal-header .eyebrow { font-size: 9px; margin-bottom: 6px; }
.modal-header h2 { font-size: 21px; }
.modal-body { padding: 20px 23px; }
.paper-fixed { display: flex; align-items: center; gap: 11px; background: #eef8ff; border: 1px solid #d7ebf9; border-radius: 9px; padding: 13px 14px; margin-bottom: 16px; }
.paper-fixed strong { font-size: 13px; }
.modal-description { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 0 0 21px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-group-title { font-size: 10px; text-transform: uppercase; letter-spacing: .9px; color: #7797af; margin-bottom: 14px; font-weight: 600; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 44px; appearance: textfield; -moz-appearance: textfield; }
.input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #8ba4b8; font-size: 12px; pointer-events: none; }
.code-group { border-top: 1px solid #eaf2f9; padding-top: 19px; margin-top: 21px; }
.settings-dialog input { height: 48px; font-size: 16px; }
.settings-base-note { font-size: 10px; color: #7d97ad; margin: 18px 0 0; line-height: 1.7; padding: 11px; background: #f2f9ff; border-radius: 7px; }
.modal-footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 23px; border-top: 1px solid #eaf2f9; background: #fff; }
.modal-footer .text-button { font-size: 11px; min-height: 44px; }
.modal-actions { display: flex; gap: 8px; }

/* La etiqueta llena una página de 100 × 60 mm; el azul pertenece solo a la interfaz. */
@page { size: 100mm 60mm; margin: 0; }
.label { width: 100mm; height: 60mm; padding: var(--label-margin); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3mm; background: #fff; color: #000; overflow: hidden; flex: 0 0 auto; }
.label-number { font-family: Arial, Helvetica, sans-serif; font-size: var(--number-size); font-weight: 700; line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; max-width: 100%; flex: 0 0 auto; }
.label-code { width: var(--code-width); height: var(--code-height); flex: 0 0 auto; }
.label-code svg { display: block; width: 100%; height: 100%; }
#print-area { display: none; }

@media (max-width: 980px) {
  .editor-grid { grid-template-columns: minmax(300px, .9fr) minmax(0, 1.1fr); gap: 18px; }
  .generation-card, .batch-card, .preview-card { padding: 19px; }
  h1 { font-size: 29px; }
}
@media (max-width: 760px) {
  .topbar { min-height: 66px; padding: 0 20px; }
  .workspace { padding: 25px 20px 18px; }
  .intro { align-items: flex-start; }
  .paper-badge { padding: 12px 14px; }
  .paper-badge strong { font-size: 14px; }
  .editor-grid { display: flex; flex-direction: column; gap: 17px; }
  .controls-column { display: contents; }
  .editor-grid .card { width: 100%; }
  .generation-card { order: 1; }
  .preview-card { order: 2; }
  .batch-card { order: 3; }
  input { font-size: 16px; min-height: 48px; }
  .button { font-size: 13px; min-height: 48px; }
  .text-button { min-height: 44px; font-size: 11px; }
}
@media (max-width: 520px) {
  .workspace { padding: 23px 16px 17px; }
  .topbar { padding: 0 16px; }
  .brand { font-size: 23px; }
  .connection { font-size: 10px; }
  .intro { flex-direction: column; gap: 15px; margin-bottom: 20px; }
  h1 { font-size: 28px; }
  .intro-copy { font-size: 12px; margin-top: 9px; }
  .paper-badge { padding: 9px 12px; width: 100%; }
  .paper-badge div { display: flex; align-items: center; justify-content: space-between; flex: 1; gap: 10px; }
  .paper-badge span { margin: 0; }
  .paper-badge svg { width: 21px; height: 21px; }
  .preview-stage { padding: 36px 11px 32px; }
  .field-help, .print-tip p, .preview-notes p { font-size: 11px; }
  .reservation-note { font-size: 11px; }
  .preview-caption { font-size: 10px; }
  .footer { flex-direction: column; gap: 5px; }
  .settings-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 13px; }
  .modal-header { padding: 16px 18px; }
  .modal-header h2 { font-size: 19px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 12px 18px; flex-wrap: wrap; gap: 5px; }
  .modal-footer > .text-button { width: 100%; text-align: center; }
  .modal-actions { width: 100%; }
  .modal-actions .button { flex: 1; min-width: 0; padding: 0 9px; font-size: 12px; }
  .settings-dialog .field-grid { gap: 16px 12px; }
}
@media (max-width: 360px) {
  .connection { max-width: 100px; font-size: 9px; }
  .small-label { font-size: 8px; }
  .counter-heading { gap: 5px; }
  .batch-heading { flex-wrap: wrap; }
  .batch-heading .button { width: 100%; }
  .settings-dialog .field-grid { grid-template-columns: 1fr; }
}
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  #app-shell, .settings-dialog { display: none !important; }
  #print-area { display: block !important; width: 100mm; margin: 0; padding: 0; }
  #print-area .label { width: 100mm !important; height: 60mm !important; margin: 0 !important; transform: none !important; border: none; border-radius: 0; box-shadow: none; break-inside: avoid; break-after: page; page-break-after: always; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #print-area .label:last-child { break-after: auto; page-break-after: auto; }
}
