/* ==========================================================================
   Editor PDF en línea — TerraWorks
   Paleta calcada del editor de referencia: verde #00bb88, azul herramienta #0282e5
   ========================================================================== */
/* Tipografía de marca: Plus Jakarta Sans (autoalojada) */
@font-face { font-family: "Plus Jakarta Sans"; src: url("../../fonts/ui/PlusJakartaSans-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../../fonts/ui/PlusJakartaSans-500.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../../fonts/ui/PlusJakartaSans-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../../fonts/ui/PlusJakartaSans-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../../fonts/ui/PlusJakartaSans-800.ttf") format("truetype"); font-weight: 800; font-display: swap; }
:root {
  /* Paleta TerraWorks (terraworks.cl) */
  --azul: #2D8BF2;
  --azul-2: #1A6FD9;
  --azul-3: #4FA9FB;
  --navy: #103F7C;
  --cielo: #EFF7FF;
  --cielo-2: #DCEEFF;
  --verde: #15803D;
  --green: var(--azul);
  --green-dark: var(--azul-2);
  --green-light: var(--cielo);
  --blue: var(--azul);
  --blue-dark: var(--navy);
  --blue-light: var(--cielo-2);
  --blue-hover: var(--cielo);
  --text: #0F172A;
  --muted: #5B6B82;
  --dim: #8A97AB;
  --border: #DCE4EE;
  --bg: #fff;
  --canvas-bg: #F4F7FB;
  --danger: #E5322D;
  --warning-bg: #fff6e0;
  --radius: 8px;
  --shadow: 0 2px 10px rgba(16,63,124,.10);
  --shadow-lg: 0 14px 40px rgba(16,63,124,.22);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --toolbar-h: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 700; margin: 0; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; vertical-align: -0.15em; stroke-width: 1.8; }
i[data-icon], .icon { display: inline-flex; line-height: 1; }
i.rot45 svg { transform: rotate(-45deg); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.text-danger { color: var(--danger); font-size: 12px; margin-top: 6px; }
.pull-right { margin-left: auto; }
code { background: #f3f4f6; padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* ---------- Cabecera ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: relative; z-index: 20; }
.topbar-inner { max-width: 1380px; margin: 0 auto; display: flex; align-items: center; gap: 22px; padding: 12px 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; filter: brightness(0); display: block; }
.brand-sep { width: 1px; height: 22px; background: var(--border); }
.brand-product { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--text); padding: 7px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.topnav a:hover { background: var(--cielo); text-decoration: none; }
.topnav a.active { background: var(--cielo-2); color: var(--navy); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-cta { border-radius: 10px; }

/* ---------- Títulos ---------- */
.page-title { text-align: center; font-size: 32px; font-weight: 800; margin-top: 26px; letter-spacing: -0.02em; color: var(--text); }
.page-title .beta { font-size: 10px; font-weight: 700; color: var(--azul); vertical-align: super; margin-left: 6px; letter-spacing: 1px; font-family: var(--mono); }
.page-subtitle { text-align: center; color: var(--muted); font-size: 20px; margin: 6px 0 0; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-family: inherit; font-size: 14px; line-height: 1.2; padding: 8px 14px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; background: #fff; color: var(--text); white-space: nowrap; user-select: none; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--azul-3), var(--azul-2)); color: #fff; font-weight: 700; border-radius: 10px; box-shadow: 0 8px 24px rgba(45,139,242,.30); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 28px rgba(45,139,242,.38); }
.btn-secondary { border-color: var(--azul); color: var(--navy); background: #fff; border-radius: 10px; font-weight: 600; }
.btn-secondary:hover { background: var(--blue-hover); }
.btn-light { background: var(--canvas-bg); border-color: var(--border); color: var(--text); border-radius: 10px; font-weight: 600; }
.btn-light:hover { background: var(--cielo-2); }
.btn-link { background: transparent; color: var(--blue); padding: 4px 6px; }
.btn-link:hover { text-decoration: underline !important; }
.btn-tertiary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius); color: var(--blue-dark); }
.btn-tertiary:hover { background: var(--blue-hover); text-decoration: none; }
.btn-xs { padding: 6px 12px; font-size: 13px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 18px; }
.btn-medium { padding: 11px 22px; font-size: 16px; }
.btn.wide { min-width: 160px; }
.btn-group { position: relative; display: inline-flex; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.btn-group > .btn:not(:last-of-type) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group .dropdown-toggle { padding-left: 10px; padding-right: 10px; }
.btn-group .dropdown-toggle.has-label { padding-right: 8px; }
.caret svg { width: .9em; height: .9em; }
.btn-tool { border-color: #BFDDFB; color: var(--navy); background: #fff; padding: 6px 11px; font-size: 14px; font-weight: 600; }
.btn-tool:hover { background: var(--blue-hover); }
.btn-tool.active, .btn-tool.open { background: var(--cielo-2); border-color: var(--azul); }
.btn-tool svg { color: var(--blue); }

/* ---------- Desplegables ---------- */
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 190px; background: #fff; border: 1px solid #d5d8dc; border-radius: 4px; box-shadow: var(--shadow); padding: 5px 0; margin: 0; list-style: none; display: none; text-align: left; }
.dropdown-menu.open { display: block; }
.dropdown-menu.right { left: auto; right: 0; }
.dropdown-menu > li > a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 14px; color: var(--text); white-space: nowrap; }
.dropdown-menu > li > a > span { display: inline-flex; align-items: center; gap: 8px; }
.dropdown-menu > li > a:hover { background: #f3f4f6; text-decoration: none; }
.dropdown-menu > li > a.active { background: var(--blue-light); }
.dropdown-menu .divider { height: 1px; background: #e5e7eb; margin: 5px 0; }
.dropdown-menu .text-divider { font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); background: #f7f8f9; padding: 5px 14px; margin: 3px 0; }
.dropdown-menu .menu-list { padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.dropdown-menu .menu-list a { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 4px; color: var(--text); }
.dropdown-menu .menu-list a:hover { background: #f3f4f6; text-decoration: none; }
.dropdown-menu .menu-row { display: flex; align-items: center; gap: 4px; padding: 6px 12px; }
.dropdown-menu .menu-row .spacer { flex: 1; }
.dropdown-menu .menu-row a.icon-only { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text); font-size: 17px; font-weight: 700; }
.dropdown-menu .menu-row a.icon-only:hover, .dropdown-menu .menu-row a.icon-only.active { background: var(--blue-light); text-decoration: none; }
.dropdown-menu .menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 4px 12px; min-width: 300px; }
.dropdown-menu .menu-grid a { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 4px; color: var(--text); }
.dropdown-menu .menu-grid a:hover { background: #f3f4f6; text-decoration: none; }
.dropdown-menu .menu-grid a.wide { grid-column: 1 / -1; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.menu-images { min-width: 240px; }
.image-list, .signature-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 8px; max-height: 260px; overflow: auto; }
.image-list:empty, .signature-list:empty { display: none; }
.image-entry, .signature-entry { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 4px; cursor: pointer; position: relative; }
.image-entry:hover, .signature-entry:hover { background: var(--blue-hover); }
.image-entry img, .signature-entry img { max-width: 150px; max-height: 44px; object-fit: contain; }
.image-entry .close, .signature-entry .close { margin-left: auto; }
.upload-menu li a { gap: 10px; justify-content: flex-start; }

/* ---------- Pantalla inicio ---------- */
.screen-home { padding-bottom: 60px; }
.upload-hero { position: relative; margin: 28px auto 0; padding: 60px 20px 40px; background: radial-gradient(760px 520px at 72% 28%, rgba(79,169,251,.22), transparent 62%), radial-gradient(560px 460px at 15% 85%, rgba(45,139,242,.10), transparent 60%), linear-gradient(180deg, var(--cielo), #fff 40%); border-radius: 0; text-align: center; overflow: hidden; }
.upload-hero::before { content: ""; position: absolute; inset: -70px 0 auto 0; height: 140px; background: #fff; border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.upload-actions { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.upload-group .btn-lg { box-shadow: 0 10px 28px rgba(45,139,242,.35); }
.upload-group .dropdown-menu { min-width: 260px; }
.link-blank { color: var(--azul-2); font-size: 14px; font-weight: 600; }
.upload-note { position: relative; color: #444; margin: 30px 0 8px; font-size: 14px; line-height: 1.55; }
.upload-legal { position: relative; font-size: 12px; }
.upload-legal a { color: #444; text-decoration: underline; }
.drop-overlay { position: absolute; inset: 0; background: rgba(45,139,242,.10); border: 3px dashed var(--azul); display: none; align-items: center; justify-content: center; z-index: 5; }
.drop-overlay-inner { background: #fff; padding: 20px 36px; border-radius: 8px; font-size: 18px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); color: var(--navy); }
body.dragging .drop-overlay { display: flex; }
.recent { max-width: 720px; margin: 24px auto 0; padding: 0 20px; }
.recent h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.recent ul { list-style: none; padding: 0; margin: 8px 0 0; }
.recent li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.howto { max-width: 1000px; margin: 60px auto 0; padding: 0 24px; }
.howto h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; text-align: center; margin-bottom: 14px; margin-top: 40px; }
.howto-lead { text-align: center; color: var(--muted); max-width: 760px; margin: 0 auto 30px; }
.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px 32px; }
.howto-grid article h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; color: var(--navy); }
.howto-grid article p { margin: 0; color: #444; }

/* ---------- Editor ---------- */
.screen-editor { display: flex; flex-direction: column; min-height: calc(100vh - 52px); }
.editor-head { padding-bottom: 14px; }
.editor-shell { flex: 1; display: flex; background: var(--canvas-bg); position: relative; min-height: 600px; }
.editor-side-left { width: 52px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; }
.side-btn { width: 32px; height: 32px; border: 1px solid var(--blue); background: #fff; border-radius: 4px; color: var(--blue); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.side-btn:hover, .side-btn.active { background: var(--blue-light); }
.editor-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.toolbar-wrap { position: sticky; top: 0; z-index: 55; padding: 12px 12px 8px; background: var(--canvas-bg); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.toolbar .btn-group { position: relative; }
body.mode-fillsign .hide-in-fillsign { display: none !important; }
.pages { flex: 1; padding: 10px 12px 120px; display: flex; flex-direction: column; align-items: center; gap: 0; }
.apply-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 14px; pointer-events: none; z-index: 40; background: linear-gradient(to top, rgba(244,247,251,.96), rgba(244,247,251,0)); }
.apply-bar .btn { pointer-events: auto; box-shadow: 0 0 0 10px rgba(79,169,251,.30), 0 8px 24px rgba(45,139,242,.30); font-size: 17px; }
.apply-bar .btn svg { stroke-width: 2.4; }

/* Página */
.page-block { display: flex; flex-direction: column; align-items: center; width: 100%; }
.page-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 0 8px; width: var(--page-w, auto); }
.page-num { color: var(--blue); font-size: 26px; font-weight: 300; min-width: 26px; text-align: right; margin-right: 6px; cursor: grab; user-select: none; }
.page-toolbar .btn-group .btn { padding: 4px 9px; font-size: 13px; }
.page-toolbar .insert-link { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--blue); color: var(--blue-dark); border-radius: 4px; padding: 4px 10px; font-size: 13px; background: #fff; cursor: pointer; margin-left: 4px; }
.page-toolbar .insert-link:hover { background: var(--blue-hover); text-decoration: none; }
.page-toolbar .insert-link svg { color: var(--blue); }
.page { position: relative; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); overflow: hidden; user-select: none; }
.page.deleted { display: none; }
.page-block.deleted { display: none; }
.page canvas.page-canvas { display: block; }
.page .textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; --scale-factor: 1; }
.page .textLayer { user-select: text; -webkit-user-select: text; }
.page .textLayer span, .page .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; -webkit-user-select: text; }
.page .textLayer span.hl-match { background: rgba(255, 220, 0, .55); color: transparent; }
.page .textLayer span.hl-current { background: rgba(255, 140, 0, .6); }
.page .textLayer ::selection { background: rgba(0, 120, 255, .35); }
.page .textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }
.page .textLayer.selecting .endOfContent { top: 0; }
body.tool-text .page .textLayer span:hover { outline: 1px dashed var(--blue); outline-offset: 2px; cursor: text; background: rgba(2,130,229,.06); }
body.tool-text .page .textLayer { z-index: 4; }
body.tool-strike .page .textLayer, body.tool-highlight .page .textLayer, body.tool-underline .page .textLayer { z-index: 5; cursor: text; }
body.tool-strike .page .textLayer span, body.tool-highlight .page .textLayer span, body.tool-underline .page .textLayer span { pointer-events: auto; }
.page .annotLayer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.page .annotLayer.hidden-annots > * { display: none; }
.page .objLayer { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.page .drawLayer { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
body.tool-draw .page .drawLayer, body.tool-freehighlight .page .drawLayer, body.tool-shape .page .drawLayer, body.tool-whiteout .page .drawLayer, body.tool-link .page .drawLayer { pointer-events: auto; cursor: crosshair; }
body.tool-text .page { cursor: text; }
body.tool-symbol .page, body.tool-field .page, body.tool-image .page, body.tool-sign .page { cursor: copy; }
body.tool-deleteimage .page .imgHitLayer { pointer-events: auto; }
.page .imgHitLayer { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.page .imgHit { position: absolute; border: 2px dashed var(--danger); background: rgba(217,83,79,.12); cursor: pointer; }
.page .imgHit:hover { background: rgba(217,83,79,.3); }
.page .imgHit.removed { background: repeating-linear-gradient(45deg, rgba(255,255,255,.9), rgba(255,255,255,.9) 6px, rgba(217,83,79,.25) 6px, rgba(217,83,79,.25) 12px); border-style: solid; }
.page .fieldLayer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.page .fieldLayer > * { pointer-events: auto; }
.page .link-hit { position: absolute; border: 1px dashed rgba(2,130,229,.7); background: rgba(2,130,229,.08); cursor: pointer; z-index: 5; }
.page .link-hit:hover { background: rgba(2,130,229,.2); }
.page .link-hit.removed { display: none; }
body:not(.tool-link) .page .link-hit { display: none; }

/* Objetos */
.obj { position: absolute; pointer-events: auto; box-sizing: border-box; }
.obj.selected { outline: 1px solid var(--blue); outline-offset: 0; z-index: 10; }
.obj:hover:not(.selected):not(.editing) { outline: 1px dashed rgba(2,130,229,.7); }
.obj .handle { position: absolute; width: 9px; height: 9px; background: #fff; border: 1px solid var(--blue); border-radius: 2px; z-index: 11; display: none; }
.obj.selected .handle { display: block; }
.obj .handle.nw { left: -5px; top: -5px; cursor: nwse-resize; } .obj .handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.obj .handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; } .obj .handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.obj .handle.e { right: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; } .obj .handle.w { left: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
.obj .handle.n { top: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; } .obj .handle.s { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.obj .handle.p1, .obj .handle.p2 { border-radius: 50%; width: 11px; height: 11px; cursor: move; }
.obj-text { cursor: move; min-width: 8px; min-height: 12px; }
.obj-text .text-content { outline: none; white-space: pre-wrap; word-break: break-word; cursor: text; min-width: 6px; line-height: 1.15; padding: 0; }
.obj-text .text-content:empty::before { content: attr(data-placeholder); color: #999; }
.obj-text.placeholder .text-content { color: #999 !important; }
.obj-text.editing { outline: 1px solid var(--blue); cursor: text; }
.obj-text.editing .handle { display: none; }
.obj-text .cover { position: absolute; z-index: -1; }
.obj-image img, .obj-signature img, .obj-stamp img { width: 100%; height: 100%; display: block; object-fit: fill; pointer-events: none; }
.obj-image, .obj-signature, .obj-stamp, .obj-whiteout, .obj-shape, .obj-field, .obj-symbol, .obj-link, .obj-highlight, .obj-underline, .obj-strike, .obj-freehand { cursor: move; }
.obj-whiteout { background: #fff; }
.obj-shape svg, .obj-freehand svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.obj-freehand { cursor: pointer; }
.obj-symbol { display: flex; align-items: center; justify-content: center; font-weight: 700; line-height: 1; }
.obj-link { border: 1px solid rgba(2,130,229,.8); background: rgba(2,130,229,.12); }
.obj-link .link-label { position: absolute; left: 0; top: 100%; font-size: 11px; background: var(--blue); color: #fff; padding: 1px 6px; border-radius: 0 0 3px 3px; white-space: nowrap; display: none; }
.obj-link.selected .link-label { display: block; }
.obj-annot-rect { position: absolute; }
.obj-highlight .obj-annot-rect { mix-blend-mode: multiply; }
.obj-field { background: rgba(2,130,229,.10); border: 1px solid rgba(2,130,229,.6); }
.obj-field .field-name { position: absolute; left: 0; top: 100%; font-size: 10px; background: var(--blue); color: #fff; padding: 0 5px; border-radius: 0 0 3px 3px; white-space: nowrap; display: none; }
.obj-field.selected .field-name { display: block; }
.obj-field .field-inner { width: 100%; height: 100%; display: flex; align-items: center; padding: 0 3px; font-family: Helvetica, Arial, sans-serif; overflow: hidden; color: #222; }
.obj-field input, .obj-field select, .obj-field textarea { width: 100%; height: 100%; border: none; background: transparent; font-family: Helvetica, Arial, sans-serif; padding: 0 3px; outline: none; resize: none; }
.obj-field.kind-checkbox .field-inner, .obj-field.kind-radio .field-inner { justify-content: center; font-size: 80%; }
.obj-field.kind-radio { border-radius: 50%; }
.obj-field.kind-signature .field-inner { font-size: 11px; color: #666; font-style: italic; justify-content: center; }
body.form-fill-mode .obj-field { background: rgba(2,130,229,.06); cursor: default; }
/* Campos existentes del PDF */
.pdf-field { position: absolute; background: rgba(2,130,229,.10); border: 1px solid rgba(2,130,229,.5); font-family: Helvetica, Arial, sans-serif; }
.pdf-field input, .pdf-field select, .pdf-field textarea { width: 100%; height: 100%; border: none; background: transparent; padding: 0 3px; outline: none; font-family: inherit; resize: none; }
.pdf-field input[type=checkbox], .pdf-field input[type=radio] { width: 100%; height: 100%; margin: 0; }
.pdf-field.focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(2,130,229,.3); }
body.form-edit-mode .pdf-field { pointer-events: auto; cursor: pointer; }
body.form-edit-mode .pdf-field input, body.form-edit-mode .pdf-field select, body.form-edit-mode .pdf-field textarea { pointer-events: none; }
.pdf-field.removed { display: none; }
.pdf-field .pdf-field-del { position: absolute; right: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 11px; display: none; align-items: center; justify-content: center; cursor: pointer; }
body.form-edit-mode .pdf-field:hover .pdf-field-del { display: inline-flex; }

/* Dibujo temporal */
.drawLayer svg { width: 100%; height: 100%; display: block; }

/* Barra flotante del objeto */
.obj-toolbar { position: absolute; z-index: 50; display: flex; gap: 0; background: #fff; border: 1px solid var(--blue); border-radius: 4px; box-shadow: var(--shadow); padding: 0; }
.obj-toolbar .btn { border-radius: 0; border: none; border-right: 1px solid #dbe9f5; padding: 6px 9px; color: var(--blue-dark); background: #fff; font-size: 13px; position: relative; }
.obj-toolbar .btn:last-child { border-right: none; }
.obj-toolbar .btn:hover { background: var(--blue-hover); }
.obj-toolbar .btn.active { background: var(--blue-light); }
.obj-toolbar .btn svg { color: var(--blue); width: 15px; height: 15px; }
.obj-toolbar .btn .swatch { width: 14px; height: 14px; }
.obj-toolbar .btn .val { font-size: 12px; min-width: 18px; }
.obj-toolbar .dropdown-menu { top: calc(100% + 2px); min-width: 140px; max-height: 300px; overflow: auto; }
.obj-toolbar .dropdown-menu a { padding: 5px 12px; }
.obj-toolbar .dropdown-menu a.selected { background: var(--blue-light); }
.obj-toolbar .font-preview { font-size: 14px; }
.obj-toolbar .btn .caret { margin-left: 2px; }
.obj-toolbar .btn-danger svg { color: var(--danger); }
.obj-toolbar .group { display: flex; }

/* Selector de color (menú) */
.color-menu { padding: 8px !important; min-width: 190px !important; }
.color-grid { display: grid; grid-template-columns: repeat(8, 20px); gap: 4px; }
.color-grid span { width: 20px; height: 20px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); cursor: pointer; }
.color-grid span:hover { transform: scale(1.15); }
.color-grid span.selected { outline: 2px solid var(--blue); outline-offset: 1px; }
.cp-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.cp-row label { font-size: 12px; color: var(--muted); }
.cp-row input[type=text] { width: 90px; }
.cp-row input[type=color] { width: 30px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 3px; background: none; }
.color-btn { display: inline-block; width: 22px; height: 22px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); cursor: pointer; vertical-align: middle; }

/* Navegador de páginas */
.page-navigator { position: sticky; top: 0; align-self: flex-start; width: 210px; height: calc(100vh - 52px); background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 35; }
.page-navigator-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 700; }
.page-navigator-list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.nav-thumb { border: 2px solid transparent; border-radius: 4px; padding: 4px; cursor: pointer; text-align: center; background: #f7f8fa; }
.nav-thumb:hover { border-color: #b9dbf5; }
.nav-thumb.current { border-color: var(--blue); }
.nav-thumb.dragover { border-color: var(--azul-2); }
.nav-thumb canvas, .nav-thumb img { max-width: 100%; box-shadow: 0 1px 3px rgba(0,0,0,.3); background: #fff; }
.nav-thumb .nav-num { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Resultado ---------- */
.screen-result { padding-bottom: 60px; }
.result-card { max-width: 520px; margin: 34px auto 0; text-align: center; background: linear-gradient(160deg, var(--cielo), #fff); border: 1px solid var(--border); border-radius: 16px; padding: 36px 30px; box-shadow: var(--shadow); }
.result-icon svg { width: 54px; height: 54px; color: var(--azul); }
.result-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 6px; }
.result-file { margin: 0 0 18px; word-break: break-all; }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.result-note { color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ---------- Overlay de proceso ---------- */
.processing { position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 200; display: flex; align-items: center; justify-content: center; }
.processing-box { background: #fff; padding: 26px 40px; border-radius: 8px; box-shadow: var(--shadow-lg); text-align: center; font-size: 16px; }
.spinner { width: 38px; height: 38px; border: 4px solid var(--cielo-2); border-top-color: var(--azul); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: none; align-items: flex-start; justify-content: center; overflow: auto; padding: 30px 12px; }
.modal.open { display: flex; }
.modal-dialog { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; }
.modal-dialog.modal-sm { width: 420px; }
.modal-dialog.modal-lg { width: 640px; }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--cielo); border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.modal-header.warning { background: var(--warning-bg); }
.modal-header.error { background: #fde8e8; }
.modal-title { font-size: 15px; font-weight: 600; flex: 1; }
.modal-header .close, .close { border: none; background: none; font-size: 22px; line-height: 1; color: #888; cursor: pointer; padding: 0 4px; }
.close:hover { color: #333; }
.modal-body { padding: 18px 16px; }
.modal-body p { margin: 0 0 10px; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-footer { padding: 12px 16px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 8px; }
.modal-footer.center { justify-content: center; }
.form-control { width: 100%; padding: 7px 10px; font-family: inherit; font-size: 14px; border: 1px solid #cfd4da; border-radius: 4px; outline: none; }
.form-control:focus { border-color: var(--azul); box-shadow: 0 0 0 3px rgba(45,139,242,.18); }
.modal-body .form-control + .form-control { margin-top: 8px; }
label.checkbox { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; }
label.checkbox.pull-right { margin: 0; }
.modal-draggable .modal-header { cursor: move; }
.undo-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; }
.undo-list label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 4px; }
.undo-list label:hover { background: #f3f4f6; }
.undo-list:empty + #undo-empty { display: block; }
.undo-list:not(:empty) + #undo-empty { display: none; }

/* Firma */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid #e5e7eb; margin-bottom: 14px; }
.tabs .tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; color: var(--azul-2); font-weight: 600; border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0; margin-bottom: -1px; }
.tabs .tab:hover { text-decoration: none; background: #f7f8fa; }
.tabs .tab.active { color: var(--text); background: #fff; border-color: #e5e7eb; }
.small-tabs .tab { padding: 6px 10px; font-size: 13px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.sig-name { max-width: 300px; margin: 6px auto 12px; display: block; text-align: center; }
.sig-colors { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
.sig-colors span { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; box-sizing: content-box; border: 2px solid transparent; }
.sig-colors span.selected { border-color: #333; }
.sig-fonts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
.sig-fonts .sig-font { padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 28px; line-height: 1.2; border: 2px solid transparent; min-width: 120px; text-align: center; white-space: nowrap; }
.sig-fonts .sig-font:hover { background: #f3f4f6; }
.sig-fonts .sig-font.selected { background: var(--cielo); border-color: #BFDDFB; }
.sig-canvas-wrap { position: relative; border: 1px dashed #c7ccd1; border-radius: 6px; background: #fff; }
.sig-canvas-wrap canvas { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
.sig-clear { position: absolute; right: 6px; top: 6px; }
.sig-versions { margin-top: 14px; }
.sig-version-grid { display: flex; gap: 12px; }
.sig-version-grid label { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px solid #e5e7eb; padding: 8px; border-radius: 6px; cursor: pointer; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; }
.sig-version-grid label:has(input:checked) { border-color: var(--azul); }
.sig-version-grid img { max-width: 100%; max-height: 90px; }
.sig-camera { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sig-camera video { width: 100%; max-height: 300px; background: #111; border-radius: 6px; }
.sig-preview-inline { max-height: 80px; }

/* Sello */
.stamp-form label { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stamp-form label > span:first-child, .stamp-form label { font-size: 13px; }
.stamp-form .form-control { flex: 1; }
.stamp-preview { margin-top: 10px; display: flex; justify-content: center; padding: 14px; background: #f7f8fa; border-radius: 6px; }
.stamp-box { border: 3px solid; border-radius: 6px; padding: 8px 18px; text-align: center; font-family: Helvetica, Arial, sans-serif; font-weight: 700; display: inline-block; }
.stamp-box .stamp-subject { font-size: 26px; letter-spacing: 1px; text-transform: uppercase; }
.stamp-box .stamp-meta { font-size: 12px; font-weight: 400; margin-top: 2px; }

/* Adjuntos */
.attachment-list { list-style: none; padding: 0; margin: 0 0 12px; }
.attachment-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.attachment-list li .grow { flex: 1; word-break: break-all; }

/* Orden de pestañas */
.tab-order-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.tab-order-opts .btn { flex-direction: column; gap: 6px; font-size: 12px; white-space: normal; }
.tab-order-opts .btn.active { border-color: var(--blue); background: var(--blue-light); }
.mini-grid { font-family: monospace; font-size: 11px; line-height: 1.2; color: var(--muted); }
.tab-order-list { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; border: 1px solid #eee; border-radius: 4px; }
.tab-order-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #f0f0f0; cursor: grab; font-size: 13px; background: #fff; }
.tab-order-list li.dragging { opacity: .4; }
.tab-order-list li .idx { color: var(--muted); width: 22px; }

/* Propiedades de campo / enlace */
.field-props label, .link-props label { display: block; margin-bottom: 10px; font-size: 13px; }
.field-props label.inline { display: flex; align-items: center; gap: 8px; }
.field-props label.inline .form-control { width: 90px; }
.field-props .form-control { margin-top: 3px; }

/* ---------- Pie de página ---------- */
.site-footer { background: var(--text); color: rgba(255,255,255,.75); display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px 24px; font-size: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--azul-3); }
.footer-logo { height: 18px; width: auto; opacity: .9; }
body:has(#screen-editor:not([hidden])) .site-footer { display: none; }

/* Toast y tooltip */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 400; font-size: 14px; box-shadow: var(--shadow-lg); max-width: 90vw; }
.tooltip { position: fixed; z-index: 500; background: var(--text); color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 4px; pointer-events: none; max-width: 280px; white-space: normal; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .topbar-inner { padding: 8px 12px; gap: 10px; }
  .page-title { font-size: 24px; }
  .page-subtitle { font-size: 16px; }
  .editor-side-left { display: none; }
  .brand-sep, .brand-product { display: none; }
  .brand-logo { height: 22px; }
  .toolbar .btn-tool { font-size: 12px; padding: 5px 8px; }
  .modal-dialog { width: 100%; }
  .tab-order-opts { grid-template-columns: repeat(2, 1fr); }
}
