/* Flagship PDF Editor — Full-Width Workspace */
.pe-shell { width: 100%; margin: 0 auto; color: #0f172a; }

.pe-upload-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px; box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04); }
.pe-drop-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 44px 24px; text-align: center; background: #f8fafc; cursor: pointer; }
.pe-drop-zone:hover, .pe-drop-zone.is-dragover { border-color: #2563eb; background: #eff6ff; }
.pe-upload-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 14px; background: #dbeafe; color: #2563eb; display: flex; align-items: center; justify-content: center; }
.pe-upload-title { margin: 0 0 6px; font-size: 1.2rem; font-weight: 700; color: #0f172a; }
.pe-upload-sub { margin: 0 0 18px; font-size: 0.92rem; color: #475569; }
.pe-browse-btn { background: #2563eb; color: #ffffff; border: none; border-radius: 9px; padding: 11px 22px; font-weight: 600; cursor: pointer; }
.pe-upload-progress { max-width: 340px; margin: 18px auto 0; font-size: 0.85rem; color: #334155; }
.pe-upload-progress-bar { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-bottom: 6px; }
.pe-upload-progress-bar span { display: block; height: 100%; width: 0%; background: #2563eb; transition: width 0.2s ease; }

.pe-workspace { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05); overflow: hidden; }
.pe-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.pe-toolbar-file { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pe-file-badge { background: #dbeafe; color: #1d4ed8; font-size: 0.72rem; font-weight: 800; padding: 4px 8px; border-radius: 6px; }
.pe-file-meta-wrap { display: flex; flex-direction: column; min-width: 0; }
.pe-doc-name { font-size: 0.85rem; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.pe-doc-meta { font-size: 0.72rem; color: #64748b; }

.pe-tool-ribbon, .pe-history-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.pe-tool-btn, .pe-tb-btn {
  border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a;
  font-size: 0.78rem; font-weight: 600; padding: 6px 10px; border-radius: 7px; cursor: pointer;
}
.pe-tool-btn.is-active { background: #2563eb; border-color: #2563eb; color: #ffffff; }
.pe-tb-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pe-tb-danger:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }

.pe-body { display: grid; grid-template-columns: 112px minmax(0, 1fr) 290px; min-height: 640px; }
.pe-thumbs-rail { background: #f8fafc; border-right: 1px solid #e2e8f0; padding: 10px; overflow-y: auto; max-height: 680px; display: flex; flex-direction: column; gap: 8px; }
.pe-rail-item { border: 2px solid #cbd5e1; border-radius: 7px; padding: 4px; background: #ffffff; cursor: pointer; text-align: center; font-size: 0.72rem; font-weight: 600; color: #334155; }
.pe-rail-item.is-active { border-color: #2563eb; background: #eff6ff; }
.pe-rail-canvas { width: 100%; height: auto; display: block; border-radius: 4px; margin-bottom: 3px; }

.pe-stage-col { background: #f1f5f9; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; min-width: 0; }
.pe-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; background: #ffffff; border-bottom: 1px solid #e2e8f0; }
.pe-page-nav, .pe-zoom-nav { display: flex; align-items: center; gap: 6px; }
.pe-nav-btn { width: 28px; height: 28px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; border-radius: 6px; font-weight: 700; cursor: pointer; }
.pe-nav-fit { width: auto; padding: 0 9px; font-size: 0.75rem; }
.pe-page-readout, .pe-zoom-label { font-size: 0.8rem; color: #475569; font-weight: 600; }
.pe-page-jump { width: 44px; height: 26px; border: 1px solid #cbd5e1; border-radius: 5px; text-align: center; font-size: 0.8rem; }

.pe-stage-scroll { flex: 1; overflow: auto; padding: 20px; display: flex; justify-content: center; align-items: flex-start; min-height: 520px; }
.pe-page-frame { position: relative; background: #ffffff; box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14); border: 1px solid #cbd5e1; line-height: 0; flex-shrink: 0; }
#pe-pdf-canvas { display: block; }
.pe-svg-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pe-dom-layer { position: absolute; inset: 0; overflow: hidden; user-select: none; touch-action: none; }

.pe-el-box { position: absolute; box-sizing: border-box; cursor: move; border: 1px dashed transparent; transform-origin: center center; }
.pe-el-box:hover { border-color: rgba(37, 99, 235, 0.5); }
.pe-el-box.is-existing { border-color: rgba(37, 99, 235, 0.22); }
.pe-el-box.is-existing:hover { border-color: #2563eb; background: rgba(37, 99, 235, 0.06); }
.pe-el-box.is-selected { border: 1.5px solid #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18); z-index: 10; }
.pe-doc-notice { padding: 7px 14px; font-size: 0.78rem; color: #1e3a8a; background: #eff6ff; border-bottom: 1px solid #bfdbfe; }
.pe-doc-notice.is-warning { color: #92400e; background: #fffbeb; border-bottom-color: #fde68a; }
.pe-el-box img { width: 100%; height: 100%; object-fit: fill; pointer-events: none; display: block; }
.pe-el-text { line-height: 1.25; white-space: pre-wrap; word-break: break-word; }
.pe-resize-se { position: absolute; right: -5px; bottom: -5px; width: 11px; height: 11px; background: #ffffff; border: 2px solid #2563eb; border-radius: 3px; cursor: nwse-resize; display: none; }
.pe-el-box.is-selected .pe-resize-se { display: block; }

.pe-props-col { padding: 14px; display: flex; flex-direction: column; gap: 12px; background: #ffffff; min-width: 0; }
.pe-section { display: flex; flex-direction: column; gap: 6px; }
.pe-label-row { display: flex; align-items: center; justify-content: space-between; }
.pe-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #334155; }
.pe-mini-label { display: block; font-size: 0.72rem; color: #64748b; }
.pe-val-badge { font-size: 0.74rem; font-weight: 600; color: #2563eb; background: #eff6ff; padding: 1px 7px; border-radius: 999px; }
.pe-textarea, .pe-select, .pe-input { width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 7px; padding: 6px 9px; font-size: 0.84rem; color: #0f172a; }
.pe-row-2 { display: grid; grid-template-columns: 1fr 72px; gap: 6px; }
.pe-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-items: end; }
.pe-style-row { display: flex; justify-content: space-between; gap: 6px; }
.pe-btn-group { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 7px; overflow: hidden; }
.pe-icon-btn { width: 32px; height: 28px; border: none; border-right: 1px solid #cbd5e1; background: #ffffff; cursor: pointer; font-size: 0.8rem; }
.pe-icon-btn:last-child { border-right: none; }
.pe-icon-btn.is-active { background: #eff6ff; color: #1d4ed8; font-weight: 700; }
.pe-color-input { width: 100%; height: 30px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 6px; background: #ffffff; cursor: pointer; }
.pe-fill-wrap { display: flex; align-items: center; gap: 4px; }
.pe-range { width: 100%; accent-color: #2563eb; }

.pe-layers-section { border-top: 1px solid #e2e8f0; padding-top: 10px; }
.pe-layers-list { display: flex; flex-direction: column; gap: 5px; max-height: 150px; overflow-y: auto; }
.pe-layer-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 7px; background: #f8fafc; cursor: pointer; font-size: 0.76rem; }
.pe-layer-item.is-selected { border-color: #2563eb; background: #eff6ff; }
.pe-layer-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-layer-page { font-size: 0.68rem; font-weight: 700; background: #e2e8f0; padding: 1px 5px; border-radius: 4px; }
.pe-layer-act { border: none; background: transparent; cursor: pointer; color: #64748b; }

.pe-apply-wrap { margin-top: auto; padding-top: 6px; }
.pe-apply-btn { width: 100%; background: #2563eb; color: #ffffff; border: none; border-radius: 9px; padding: 12px 16px; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.pe-apply-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Signature Modal */
.pe-modal { position: fixed; inset: 0; z-index: 9999; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pe-modal-card { width: 100%; max-width: 480px; background: #ffffff; border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); display: flex; flex-direction: column; gap: 12px; }
.pe-modal-head { display: flex; justify-content: space-between; align-items: center; }
.pe-modal-head h3 { margin: 0; font-size: 1.05rem; color: #0f172a; }
.pe-sig-note { margin: 0; font-size: 0.76rem; color: #64748b; }
.pe-sig-tabs { display: flex; gap: 6px; }
.pe-sig-canvas { width: 100%; height: 150px; border: 1px dashed #94a3b8; border-radius: 8px; background: #f8fafc; touch-action: none; cursor: crosshair; display: block; margin-bottom: 6px; }
.pe-modal-foot { display: flex; justify-content: flex-end; }

.pe-workspace[hidden], .pe-upload-card[hidden], .pe-modal[hidden] { display: none !important; }

@media (max-width: 1080px) {
  .pe-body { grid-template-columns: 1fr; }
  .pe-thumbs-rail { flex-direction: row; max-height: 110px; border-right: none; border-bottom: 1px solid #e2e8f0; overflow-x: auto; }
  .pe-rail-item { min-width: 72px; }
  .pe-stage-col { border-right: none; border-bottom: 1px solid #e2e8f0; }
}
