:root {
    --vase-bg: #f4f7fb;
    --vase-card: #ffffff;
    --vase-text: #172033;
    --vase-muted: #687386;
    --vase-border: #dce3ed;
    --vase-primary: #6d3df5;
    --vase-primary-soft: #f0eaff;
    --vase-dark: #111827;
    --vase-red: #dc2626;
    --vase-red-soft: #fff1f2;
    --vase-blue: #2563eb;
    --vase-blue-soft: #eff6ff;
    --vase-green: #16803a;
    --vase-shadow: 0 18px 55px rgba(31, 41, 55, .10);
}

.vase-editor,
.vase-editor * {
    box-sizing: border-box;
}

.vase-editor {
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    padding: 24px 24px 70px;
    color: var(--vase-text);
}

.vase-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.vase-heading {
    max-width: 850px;
}

.vase-kicker {
    margin-bottom: 5px;
    color: var(--vase-primary);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
}

.vase-title {
    margin: 0;
    font-size: clamp(27px, 3vw, 38px);
    line-height: 1.06;
    font-weight: 900;
    letter-spacing: -.03em;
}

.vase-subtitle {
    margin: 9px 0 0;
    color: var(--vase-muted);
    font-size: 14px;
    line-height: 1.55;
}

.vase-status-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.vase-save-status {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--vase-border);
    border-radius: 12px;
    background: #fff;
    color: var(--vase-muted);
    font-size: 12px;
    font-weight: 800;
}

.vase-save-status.saved {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: var(--vase-green);
}

.vase-save-status.saving {
    border-color: #fde68a;
    background: #fffbeb;
    color: #a16207;
}

.vase-save-status.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.vase-btn,
.vase-pill-btn,
.vase-mini-btn,
.vase-tab,
.vase-align-btn,
.vase-toggle-btn {
    font: inherit;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.vase-btn {
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 850;
}

.vase-btn:hover,
.vase-pill-btn:hover,
.vase-mini-btn:hover {
    transform: translateY(-1px);
}

.vase-btn:disabled,
.vase-mini-btn:disabled,
.vase-toggle-btn:disabled,
.vase-align-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.vase-btn-light {
    border-color: var(--vase-border);
    background: #fff;
    color: var(--vase-text);
}

.vase-btn-dark {
    background: var(--vase-dark);
    color: #fff;
}

.vase-btn-primary {
    background: var(--vase-primary);
    color: #fff;
    box-shadow: 0 9px 24px rgba(109, 61, 245, .22);
}

.vase-document-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 14px;
}

.vase-tab {
    min-width: 106px;
    padding: 11px 18px;
    border: 1px solid var(--vase-border);
    border-radius: 12px;
    background: #fff;
    color: var(--vase-text);
    font-size: 14px;
    font-weight: 900;
}

.vase-tab.active {
    border-color: var(--vase-dark);
    background: var(--vase-dark);
    color: #fff;
    box-shadow: 0 8px 20px rgba(17, 24, 39, .14);
}

.vase-tax-source {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
    padding: 13px 15px;
    border: 1px solid #fecaca;
    border-radius: 15px;
    background: linear-gradient(90deg, #fff1f2, #fff 65%);
}

.vase-tax-source-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 11px;
    background: #fee2e2;
}

.vase-tax-source-copy {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.vase-tax-source-copy strong {
    color: #991b1b;
    font-size: 13px;
}

.vase-tax-source-copy span {
    color: #7f1d1d;
    font-size: 12px;
    line-height: 1.35;
}

.vase-tax-source.is-ok {
    border-color: #fca5a5;
}

.vase-tax-source.is-warning {
    border-color: #fdba74;
    background: #fff7ed;
}

.vase-tax-source.is-warning .vase-tax-source-copy strong,
.vase-tax-source.is-warning .vase-tax-source-copy span {
    color: #9a3412;
}

.vase-tax-source-link {
    flex: 0 0 auto;
    padding: 8px 11px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #991b1b;
    background: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 850;
}

.vase-settings-card {
    border: 1px solid var(--vase-border);
    border-radius: 18px;
    background: var(--vase-card);
    box-shadow: 0 10px 35px rgba(31, 41, 55, .055);
}

.vase-settings-main {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr)) minmax(150px, auto);
    gap: 12px;
    align-items: end;
    padding: 14px;
}

.vase-field,
.vase-control {
    min-width: 0;
}

.vase-field label,
.vase-control label {
    display: block;
    margin-bottom: 6px;
    color: #4b5563;
    font-size: 11px;
    font-weight: 850;
}

.vase-field input,
.vase-field select,
.vase-control input,
.vase-control select {
    width: 100%;
    height: 38px;
    border: 1px solid #cfd8e4;
    border-radius: 10px;
    background: #fff;
    color: var(--vase-text);
    padding: 0 10px;
    outline: none;
}

.vase-field input:focus,
.vase-field select:focus,
.vase-control input:focus,
.vase-control select:focus {
    border-color: #9b7dfa;
    box-shadow: 0 0 0 3px rgba(109, 61, 245, .10);
}

.vase-input-unit {
    display: flex;
    align-items: center;
    border: 1px solid #cfd8e4;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.vase-input-unit input {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.vase-input-unit span {
    padding: 0 10px 0 4px;
    color: #7b8493;
    font-size: 11px;
    font-weight: 800;
}

.vase-switch {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid var(--vase-border);
    border-radius: 11px;
    background: #fafbfc;
    color: #374151;
    font-size: 12px;
    font-weight: 850;
    cursor: pointer;
}

.vase-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.vase-switch-ui {
    position: relative;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: .18s ease;
}

.vase-switch-ui::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: .18s ease;
}

.vase-switch input:checked + .vase-switch-ui {
    background: var(--vase-primary);
}

.vase-switch input:checked + .vase-switch-ui::after {
    transform: translateX(14px);
}

.vase-advanced-settings {
    border-top: 1px solid #edf1f5;
}

.vase-advanced-settings summary,
.vase-block-advanced summary {
    padding: 11px 14px;
    color: #566174;
    font-size: 12px;
    font-weight: 850;
    cursor: pointer;
    user-select: none;
}

.vase-advanced-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(180px, auto);
    gap: 12px;
    align-items: end;
    padding: 0 14px 14px;
}

.vase-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #4b5563;
    font-size: 12px;
    font-weight: 800;
}

.vase-raw-check {
    min-height: 38px;
}

.vase-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 14px 0;
    padding: 10px 14px;
    border-radius: 13px;
    background: #fff;
    border: 1px solid var(--vase-border);
}

.vase-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #5d6676;
    font-size: 11px;
}

.vase-legend-item > span {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.vase-legend-item.required > span { background: var(--vase-red); }
.vase-legend-item.automatic > span { background: var(--vase-blue); }
.vase-legend-item.editable > span { background: var(--vase-primary); }

.vase-addbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--vase-border);
    border-radius: 15px;
    background: #fff;
}

.vase-addbar-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vase-addbar-copy strong {
    font-size: 13px;
}

.vase-addbar-copy span {
    color: var(--vase-muted);
    font-size: 11px;
}

.vase-addbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vase-pill-btn {
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #d5dce6;
    border-radius: 10px;
    background: #fff;
    color: var(--vase-text);
    font-size: 12px;
    font-weight: 900;
}

.vase-pill-btn:hover {
    border-color: #bba9fb;
    background: var(--vase-primary-soft);
    color: #5b2bd8;
}

.vase-live-toolbar {
    position: sticky;
    top: 10px;
    z-index: 30;
    margin: 14px 0 18px;
    border: 1px solid var(--vase-border);
    border-radius: 16px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 10px 32px rgba(17, 24, 39, .09);
    backdrop-filter: blur(14px);
}

.vase-live-empty {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 48px;
    padding: 0 14px;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
}

.vase-live-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--vase-primary);
    box-shadow: 0 0 0 5px rgba(109, 61, 245, .10);
}

.vase-live-form {
    padding: 10px 12px;
}

.vase-live-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.vase-live-head > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 9px;
}

.vase-live-head strong {
    font-size: 13px;
}

.vase-live-head span {
    color: var(--vase-muted);
    font-size: 11px;
    font-weight: 750;
}

.vase-inspector-actions {
    display: flex;
    gap: 6px;
}

.vase-mini-btn {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid #d9e0e9;
    border-radius: 9px;
    background: #f8fafc;
    color: #253044;
    font-size: 12px;
    font-weight: 850;
}

.vase-mini-btn.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.vase-live-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) minmax(120px, .9fr) minmax(170px, auto) minmax(145px, auto) minmax(135px, auto);
    gap: 10px;
    align-items: end;
}

.vase-control.compact-control {
    min-width: 150px;
}

.vase-control.tiny-control {
    min-width: 130px;
}

.vase-number-pair {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) 68px;
    gap: 6px;
    align-items: center;
}

.vase-number-pair.two {
    grid-template-columns: 1fr 84px;
}

.vase-number-pair input[type="range"] {
    height: auto;
    border: 0;
    padding: 0;
    accent-color: var(--vase-primary);
}

.vase-segment {
    display: flex;
    gap: 4px;
}

.vase-align-btn,
.vase-toggle-btn {
    min-height: 36px;
    padding: 0 9px;
    border: 1px solid #dbe2ea;
    border-radius: 9px;
    background: #f6f7f9;
    color: #293142;
    font-size: 11px;
    font-weight: 850;
}

.vase-align-btn.active,
.vase-toggle-btn.active {
    border-color: var(--vase-dark);
    background: var(--vase-dark);
    color: #fff;
}

.vase-image-inline {
    display: grid;
    grid-template-columns: 42px minmax(110px, 1fr) minmax(155px, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.vase-image-preview {
    display: grid;
    place-items: center;
    width: 42px;
    height: 38px;
    overflow: hidden;
    border: 1px dashed #ccd5e0;
    border-radius: 8px;
    background: #f8fafc;
    color: #98a2b3;
    font-size: 8px;
}

.vase-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.vase-image-inline input[type="file"] {
    padding: 6px;
    font-size: 10px;
}

.vase-block-advanced {
    margin-top: 9px;
    border-top: 1px solid #edf1f5;
}

.vase-block-advanced summary {
    padding: 8px 0 0;
}

.vase-block-advanced-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 10px;
    padding-top: 9px;
}

.vase-layout {
    display: block;
}

.vase-paper-zone {
    min-width: 0;
}

.vase-paper-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1060px;
    margin: 0 auto 8px;
    padding: 0 8px;
    color: #667085;
    font-size: 11px;
    font-weight: 850;
}

.vase-paper-label-help {
    color: #8c95a5;
}

.vase-paper-stage {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 660px;
    max-height: 78vh;
    overflow: auto;
    padding: 30px 28px 70px;
    border: 1px solid #dce2e9;
    border-radius: 22px;
    background:
        linear-gradient(rgba(255,255,255,.15), rgba(255,255,255,.15)),
        radial-gradient(circle at top left, #e4e7ec, #d7dce4 55%, #d2d7df);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

.vase-paper {
    position: relative;
    width: 72mm;
    min-height: 120mm;
    height: auto;
    overflow: visible;
    background: #fff;
    color: #000;
    box-shadow: 0 18px 44px rgba(22, 28, 38, .22);
    transform: scale(var(--paper-preview-scale, 1));
    transform-origin: top center;
}

#visualDocument {
    min-height: inherit;
    overflow: visible;
}

.tpl-root {
    width: 100%;
    min-height: 120mm;
    height: auto;
    overflow: visible;
    background: #fff;
    color: #000;
}

.tpl-scale-content {
    width: 100%;
    min-height: inherit;
}

.tpl-block {
    position: relative;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.editor-block {
    position: relative;
    margin-left: 2px;
    margin-right: 2px;
    border-radius: 4px;
    outline: 1px solid transparent;
    cursor: pointer;
    transition: outline .12s ease, background .12s ease, box-shadow .12s ease;
}

.editor-block:not(.editor-required-zone):not(.editor-auto-zone) {
    outline: 1px dashed rgba(109, 61, 245, .26);
}

.editor-block:hover {
    outline: 1px dashed rgba(109, 61, 245, .65);
    background: rgba(109, 61, 245, .035);
}

.editor-block.selected {
    outline: 2px solid var(--vase-primary);
    background: rgba(109, 61, 245, .055);
    box-shadow: 0 0 0 3px rgba(109, 61, 245, .08);
}

.editor-block.locked {
    cursor: default;
}

.editor-block.editor-auto-zone {
    outline: 1px dashed rgba(37, 99, 235, .55);
    background: rgba(239, 246, 255, .55);
}

.editor-block.editor-auto-zone.selected {
    outline: 2px solid var(--vase-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .09);
}

.editor-required-zone {
    position: relative;
    border-radius: 4px;
    outline: 1.5px dashed rgba(220, 38, 38, .80);
    outline-offset: 2px;
    background: rgba(255, 241, 242, .45);
}

.editor-required-zone.editor-block.selected {
    outline: 2px solid var(--vase-red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .10);
}

.editor-only-marker {
    position: absolute;
    top: -10px;
    right: 1px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 5px;
    border-radius: 999px;
    font-family: Arial, sans-serif;
    font-size: 6.5px;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
}

.editor-required-zone > .editor-only-marker,
.editor-block.editor-required-zone > .editor-only-marker {
    background: #fee2e2;
    color: #b91c1c;
}

.editor-auto-zone > .editor-only-marker,
.editor-block.editor-auto-zone > .editor-only-marker {
    background: #dbeafe;
    color: #1d4ed8;
}

.tpl-inline-edit {
    display: block;
    min-height: 1em;
    border-radius: 2px;
    outline: none;
    cursor: text;
}

.tpl-inline-edit:focus {
    background: #fff8dc;
    box-shadow: inset 0 0 0 1px #f59e0b;
}

.tpl-separator {
    white-space: pre;
    overflow: hidden;
}

.tpl-image-wrap {
    width: 100%;
}

.tpl-image-wrap img {
    display: inline-block;
    max-width: 100%;
    object-fit: contain;
}

.tpl-placeholder {
    padding: 7px;
    border: 1px dashed #a8b0bd;
    border-radius: 4px;
    color: #6b7280;
    background: #f9fafb;
    font-family: Arial, sans-serif;
    font-size: 9px;
    text-align: center;
}

.tpl-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.tpl-row-left,
.tpl-row-right {
    min-width: 0;
}

.tpl-row-right {
    text-align: right;
    white-space: nowrap;
}

.tpl-item {
    margin: 2px 0 4px;
}

.tpl-extra {
    margin-left: 12px;
}

.tpl-sii-header-box {
    border: 2px solid #000;
    padding: 5px 7px;
    margin: 3mm 0 2mm;
    text-align: center;
    font-weight: 700;
    line-height: 1.25;
}

.tpl-sii-header-title {
    margin: 2px 0;
    font-size: 1.08em;
}

.tpl-required-company {
    line-height: 1.22;
}

.tpl-required-company .company-name {
    font-weight: 900;
}

.tpl-required-company .company-missing {
    color: #b91c1c;
    font-weight: 900;
}

.tpl-tax-totals {
    margin-top: 2mm;
    font-weight: 700;
}

.tpl-totals-title {
    margin: 2mm 0 1mm;
    text-align: center;
    font-weight: 900;
}

.tpl-required-sii,
.tpl-sii-box {
    border: 0;
    box-shadow: none;
}

.tpl-sii-box {
    padding: 0;
    margin-top: 3mm;
    text-align: center;
    font-size: 10px;
    line-height: 1.28;
}

.tpl-sii-image {
    display: block;
    width: 64mm;
    max-width: 96%;
    height: auto;
    margin: 0 auto 1.3mm;
    filter: grayscale(100%) contrast(180%);
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.tpl-sii-image-fallback {
    padding: 4mm 2mm;
    margin-bottom: 1.3mm;
    font-weight: 900;
}

.tpl-sii-caption {
    margin-top: .5mm;
    font-size: 11px;
    font-weight: 800;
}

.tpl-sii-resolution,
.tpl-sii-verification {
    font-size: 9.5px;
    line-height: 1.25;
}

.vase-cut-preview {
    position: relative;
    width: 100%;
    height: var(--cut-gap, 8mm);
    min-height: var(--cut-gap, 8mm);
    margin-top: 2mm;
    background: repeating-linear-gradient(
        135deg,
        rgba(15, 23, 42, .02) 0,
        rgba(15, 23, 42, .02) 5px,
        rgba(15, 23, 42, 0) 5px,
        rgba(15, 23, 42, 0) 10px
    );
}

.vase-cut-preview::after {
    content: "";
    position: absolute;
    left: -11px;
    right: -11px;
    bottom: 0;
    border-top: 2px dashed #e11d48;
}

.vase-cut-preview-label {
    position: absolute;
    left: 50%;
    bottom: -13px;
    z-index: 2;
    transform: translateX(-50%);
    padding: 2px 7px;
    border: 1px solid #fecdd3;
    border-radius: 999px;
    background: #fff;
    color: #be123c;
    font-family: Arial, sans-serif;
    font-size: 8px;
    font-weight: 900;
    white-space: nowrap;
}

.vase-cut-preview.no-cut::after {
    border-top-color: #94a3b8;
}

.vase-cut-preview.no-cut .vase-cut-preview-label {
    border-color: #cbd5e1;
    color: #64748b;
}

.vase-debug {
    display: none !important;
}

@media (max-width: 1180px) {
    .vase-settings-main {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }

    .vase-live-controls {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }

    .vase-block-advanced-grid,
    .vase-advanced-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }
}

@media (max-width: 820px) {
    .vase-editor {
        padding: 16px 12px 55px;
    }

    .vase-topbar {
        flex-direction: column;
    }

    .vase-status-wrap {
        justify-content: flex-start;
        width: 100%;
    }

    .vase-tax-source {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .vase-tax-source-link {
        margin-left: 50px;
    }

    .vase-settings-main,
    .vase-live-controls,
    .vase-block-advanced-grid,
    .vase-advanced-grid {
        grid-template-columns: 1fr 1fr;
    }

    .vase-addbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .vase-live-toolbar {
        position: static;
    }

    .vase-paper-stage {
        min-height: 560px;
        padding: 26px 16px 60px;
    }
}

@media (max-width: 560px) {
    .vase-document-tabs {
        justify-content: stretch;
    }

    .vase-tab {
        flex: 1 1 0;
        min-width: 0;
        padding-left: 8px;
        padding-right: 8px;
    }

    .vase-settings-main,
    .vase-live-controls,
    .vase-block-advanced-grid,
    .vase-advanced-grid {
        grid-template-columns: 1fr;
    }

    .vase-status-wrap .vase-btn {
        flex: 1 1 calc(50% - 8px);
    }

    .vase-save-status {
        width: 100%;
        justify-content: center;
    }

    .vase-legend {
        align-items: flex-start;
        flex-direction: column;
    }

    .vase-image-inline {
        grid-template-columns: 42px 1fr;
    }

    .vase-image-inline input[type="file"],
    .vase-image-inline .vase-mini-btn {
        grid-column: 1 / -1;
    }
}

/* =========================================================
   Editor limpio V2 - controles solamente al seleccionar
   ========================================================= */

.vase-addbar.vase-addbar-compact {
    max-width: 1060px;
    margin: 12px auto 14px;
    padding: 9px 12px;
    border-radius: 13px;
    box-shadow: 0 5px 18px rgba(17, 24, 39, .045);
}

.vase-addbar.vase-addbar-compact .vase-addbar-copy span {
    max-width: 620px;
}

.vase-selection-toolbar[hidden] {
    display: none !important;
}

.vase-selection-toolbar {
    position: sticky;
    top: 8px;
    z-index: 35;
    width: min(1060px, calc(100% - 16px));
    margin: 0 auto 10px;
    border: 1px solid #dce3ec;
    border-radius: 14px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .10);
    backdrop-filter: blur(12px);
}

.vase-selection-form {
    padding: 9px 10px 10px;
}

.vase-selection-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 7px;
    margin-bottom: 8px;
    border-bottom: 1px solid #edf1f5;
}

.vase-selection-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.vase-selection-title strong {
    color: #111827;
    font-size: 13px;
    white-space: nowrap;
}

.vase-selection-title span {
    overflow: hidden;
    color: #7b8494;
    font-size: 10px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vase-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #dce3eb;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.vase-icon-btn:hover {
    background: #eef2f7;
    color: #111827;
}

.vase-selection-main {
    display: grid;
    grid-template-columns: 125px 140px minmax(205px, auto) 100px minmax(250px, 1fr);
    gap: 8px;
    align-items: end;
}

.vase-selection-main .vase-control label,
.vase-selection-context .vase-control label,
.vase-block-advanced .vase-control label {
    margin-bottom: 4px;
    font-size: 9px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.vase-selection-main select,
.vase-selection-main input,
.vase-selection-context select,
.vase-selection-context input {
    min-height: 34px;
}

.vase-stepper {
    display: grid;
    grid-template-columns: 34px minmax(62px, 1fr) 34px;
    min-height: 34px;
    overflow: hidden;
    border: 1px solid #dbe2ea;
    border-radius: 9px;
    background: #fff;
}

.vase-step-btn {
    border: 0;
    background: #f6f8fa;
    color: #111827;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}

.vase-step-btn:first-child {
    border-right: 1px solid #e5e9ef;
}

.vase-step-btn:last-child {
    border-left: 1px solid #e5e9ef;
}

.vase-step-btn:hover:not(:disabled) {
    background: #eee9ff;
    color: #5b2bd8;
}

.vase-step-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.vase-step-value {
    display: grid;
    place-items: center;
    padding: 0 6px;
    color: #273244;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.vase-segment.compact-segment {
    gap: 3px;
}

.vase-segment.compact-segment .vase-align-btn,
.vase-segment.compact-segment .vase-toggle-btn {
    min-height: 34px;
    padding: 0 8px;
}

.vase-selection-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
}

.vase-selection-actions .vase-mini-btn {
    min-height: 34px;
    white-space: nowrap;
}

.vase-selection-context {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
}

.vase-selection-context:empty {
    display: none;
}

.vase-selection-context .context-control {
    margin: 0;
}

.vase-selection-context #textControl input {
    width: 100%;
}

.vase-selection-toolbar .vase-block-advanced {
    margin-top: 8px;
}

.vase-selection-toolbar .vase-block-advanced summary {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 3px 2px 0;
    color: #667085;
    font-size: 10px;
    font-weight: 850;
    cursor: pointer;
}

/* La boleta se muestra limpia. Los estados aparecen al interactuar. */
.editor-only-marker {
    display: none !important;
}

.editor-block,
.editor-block:not(.editor-required-zone):not(.editor-auto-zone),
.editor-required-zone,
.editor-block.editor-auto-zone {
    outline: 1px solid transparent;
    outline-offset: 1px;
    background: transparent;
    box-shadow: none;
}

.editor-block {
    margin-left: 0;
    margin-right: 0;
    border-radius: 3px;
}

.editor-block:not(.locked) {
    cursor: pointer;
}

.editor-block:not(.locked):hover {
    outline: 1px dashed rgba(109, 61, 245, .65);
    background: rgba(109, 61, 245, .025);
}

.editor-block.selected,
.editor-block:not(.editor-required-zone):not(.editor-auto-zone).selected {
    outline: 2px solid rgba(109, 61, 245, .88);
    background: rgba(109, 61, 245, .045);
    box-shadow: 0 0 0 3px rgba(109, 61, 245, .07);
}

.editor-block.editor-auto-zone:hover,
.editor-block.editor-auto-zone.selected {
    outline-color: rgba(37, 99, 235, .82);
    background: rgba(239, 246, 255, .35);
}

.editor-required-zone:hover,
.editor-required-zone.editor-block.selected {
    outline: 1px dashed rgba(220, 38, 38, .72);
    background: rgba(255, 241, 242, .28);
}

/* Indicadores mínimos: solo aparecen al pasar el mouse. */
.editor-required-zone::after,
.editor-auto-zone::after {
    position: absolute;
    top: -8px;
    right: 1px;
    z-index: 8;
    display: none;
    padding: 2px 5px;
    border-radius: 999px;
    font-family: Arial, sans-serif;
    font-size: 6.5px;
    line-height: 1.1;
    font-weight: 900;
    pointer-events: none;
    white-space: nowrap;
}

.editor-required-zone:hover::after {
    content: "🔒 NO EDITABLE";
    display: inline-flex;
    border: 1px solid #fecaca;
    background: #fff;
    color: #b91c1c;
}

.editor-auto-zone:hover::after {
    content: "↻ DATO DEL POS";
    display: inline-flex;
    border: 1px solid #bfdbfe;
    background: #fff;
    color: #1d4ed8;
}

.tpl-inline-edit:focus {
    background: #fff9dc;
    box-shadow: inset 0 0 0 1px #f59e0b;
}

/* Los datos faltantes siguen resaltados en rojo; los correctos parecen una boleta real. */
.tpl-required-company .company-missing {
    color: #b91c1c;
}

.vase-paper-label {
    max-width: 1060px;
}

@media (max-width: 1180px) {
    .vase-selection-main {
        grid-template-columns: 125px 140px 1fr 100px;
    }

    .vase-selection-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 820px) {
    .vase-selection-toolbar {
        position: static;
        width: 100%;
    }

    .vase-selection-main {
        grid-template-columns: 1fr 1fr;
    }

    .vase-selection-actions {
        grid-column: 1 / -1;
    }

    .vase-selection-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 1px;
    }
}

@media (max-width: 560px) {
    .vase-addbar.vase-addbar-compact {
        align-items: stretch;
    }

    .vase-addbar.vase-addbar-compact .vase-addbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .vase-selection-main {
        grid-template-columns: 1fr;
    }

    .vase-selection-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .vase-paper-label-help {
        display: none;
    }
}


/* V6 · estado real del Bridge y editor térmico compacto */
.vase-bridge-status {
    display:flex;
    align-items:center;
    gap:8px;
    min-width:220px;
    padding:7px 10px;
    border:1px solid #d8dee9;
    border-radius:10px;
    background:#fff;
}
.vase-bridge-dot {
    width:10px;
    height:10px;
    border-radius:50%;
    background:#94a3b8;
    flex:0 0 auto;
}
.vase-bridge-status.online .vase-bridge-dot { background:#16a34a; }
.vase-bridge-status.offline .vase-bridge-dot { background:#dc2626; }
.vase-bridge-status.checking .vase-bridge-dot { background:#f59e0b; }
.vase-bridge-copy { display:flex; flex-direction:column; line-height:1.1; }
.vase-bridge-copy strong { font-size:12px; color:#172033; }
.vase-bridge-copy small { font-size:10px; color:#64748b; margin-top:2px; max-width:310px; }

.vase-printer-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(420px, auto);
    gap: 14px 18px;
    align-items: center;
    margin: 0 0 14px;
    padding: 14px 15px;
    border: 1px solid #bfdbfe;
    border-radius: 15px;
    background: linear-gradient(90deg, #eff6ff, #ffffff 70%);
}

.vase-printer-panel[hidden] { display: none !important; }

.vase-printer-panel-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.vase-printer-panel-copy strong {
    color: #1e3a8a;
    font-size: 13px;
}

.vase-printer-panel-copy span {
    color: #475569;
    font-size: 11px;
    line-height: 1.45;
}

.vase-printer-panel-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.vase-printer-panel-controls select {
    width: min(360px, 40vw);
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--vase-border);
    border-radius: 11px;
    background: #fff;
    color: var(--vase-text);
    font: inherit;
    font-size: 12px;
    font-weight: 750;
}

.vase-printer-panel-message {
    grid-column: 1 / -1;
    color: #475569;
    font-size: 11px;
    font-weight: 750;
}

.vase-printer-panel-message.is-ok { color: #15803d; }
.vase-printer-panel-message.is-error { color: #b91c1c; }

@media (max-width: 980px) {
    .vase-printer-panel { grid-template-columns: 1fr; }
    .vase-printer-panel-controls { justify-content: flex-start; flex-wrap: wrap; }
    .vase-printer-panel-controls select { width: 100%; }
}
.editor-empty-hint {
    display:block;
    min-height:16px;
    padding:2px 4px;
    border:1px dashed #cbd5e1;
    border-radius:4px;
    color:#94a3b8;
    font-size:10px;
    line-height:1.1;
    text-align:center;
}
.tpl-separator { margin:0!important; padding:0!important; line-height:0!important; }
.tpl-rule { margin:0!important; padding:0!important; }
.tpl-item { margin:0!important; padding:0!important; line-height:1.02!important; }
.tpl-extra { margin-top:0!important; margin-bottom:0!important; padding:0!important; line-height:1.02!important; }
.tpl-block { margin-top:0!important; margin-bottom:0!important; padding-top:0!important; padding-bottom:0!important; }
@media (max-width: 900px) {
    .vase-bridge-status { width:100%; min-width:0; }
}


/* Tanda 8: reordenar bloques reales directamente sobre la boleta.
   Los controles de diseño no forman parte del HTML enviado a imprimir. */
.editor-block .editor-drag-handle {
    position: absolute;
    top: 0;
    left: -17px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 26px;
    padding: 0;
    border: 1px solid #b2cbff;
    border-radius: 6px 0 0 6px;
    background: #eaf2ff;
    color: #155ec1;
    box-shadow: 0 2px 4px rgba(0,0,0,.12);
    font: 900 15px/1 Arial,sans-serif;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0;
    transition: opacity .12s ease;
}
.editor-block:hover > .editor-drag-handle,
.editor-block.selected > .editor-drag-handle,
.editor-drag-handle:focus-visible {
    opacity: 1;
}
.editor-block > .editor-drag-handle:active,
.vase-reordering .editor-drag-handle { cursor: grabbing; }
.editor-block.vase-drag-source { outline: 2px dashed #2563eb !important; background: rgba(37,99,235,.08) !important; }
.editor-block.vase-drag-source > .editor-drag-handle { opacity: 1; }
.editor-block.vase-drop-before::before,
.editor-block.vase-drop-after::before {
    content: "";
    position: absolute;
    right: -6px;
    left: -6px;
    z-index: 35;
    height: 4px;
    border-radius: 8px;
    background: #2563eb;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
}
.editor-block.vase-drop-before::before { top: -3px; }
.editor-block.vase-drop-after::before { bottom: -3px; }
.vase-reordering,
.vase-reordering * { user-select: none !important; -webkit-user-select: none !important; }
@media (hover: none) {
    /* El control debe poder descubrirse y usarse sin pasar el mouse. */
    .editor-block > .editor-drag-handle { opacity: 1; }
}
@media print {
    .editor-drag-handle { display: none !important; }
}

.vase-screen-reader-only {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important; clip: rect(0,0,0,0) !important;
    white-space: nowrap !important; border: 0 !important;
}

/* Editor de comprobantes: controles de diseño fáciles de encontrar (28/10/2026). */
.vase-status-wrap { flex: 0 0 auto; }
.vase-actions { position: relative; z-index: 80; }
.vase-actions > summary { display: inline-flex; gap: 13px; align-items: center; justify-content: center; list-style: none; cursor: pointer; user-select: none; }
.vase-actions > summary::-webkit-details-marker { display: none; }
.vase-actions[open] > summary { background: #263244; }
.vase-actions > summary.has-save-error { border-color: #dc2626; box-shadow: 0 0 0 2px #fee2e2; }
.vase-actions-menu {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    min-width: 232px;
    padding: 10px;
    border: 1px solid #dce3ed;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 15px 40px rgba(15, 23, 42, .18);
}
.vase-autosave-label { margin: 5px 5px 7px; font-size: 11px; font-weight: 800; color: #64748b; }
.vase-actions-menu .vase-save-status { width: 100%; justify-content: center; margin-bottom: 8px; }
.vase-actions-item {
    width: 100%; min-height: 39px; display: flex; align-items: center;
    text-align: left; border: 0; border-radius: 8px; padding: 9px 11px;
    background: transparent; font: inherit; font-size: 13px;
    font-weight: 700; color: #172033; cursor: pointer;
}
.vase-actions-item:hover, .vase-actions-item:focus-visible { background: #f2f5fc; }
.vase-actions-item:disabled { opacity: .6; cursor: wait; }
.vase-design-card {
    max-width: 1060px;
    margin: 14px auto 8px;
    padding: 15px 16px;
    background: #fff;
    border: 1px solid #dce3ed;
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(17, 24, 39, .04);
}
.vase-design-heading { margin-bottom: 13px; }
.vase-design-heading strong { display: block; font-size: 13px; font-weight: 900; color: #172033; }
.vase-design-heading span { display: block; font-size: 12px; color: #64748b; margin-top: 3px; }
.vase-design-controls { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1.4fr; gap: 12px; align-items: end; }
.vase-design-stepper { display: flex; height: 38px; overflow: hidden; border: 1px solid #cfd8e4; border-radius: 10px; }
.vase-design-stepper button { width: 39px; flex: 0 0 39px; border: 0; background: #f8fafc; color: #172033; font-size: 19px; font-weight: 800; cursor: pointer; }
.vase-design-stepper button:hover { background: #eaf0fa; }
.vase-design-stepper input { width: 100%; min-width: 42px; border: 0; padding: 0 3px; text-align: center; font-weight: 800; border-radius: 0; -moz-appearance: textfield; }
.vase-design-stepper input::-webkit-inner-spin-button, .vase-design-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.vase-design-stepper span { align-self: center; margin-right: 6px; font-size: 11px; font-weight: 750; color: #64748b; }
.vase-design-help { display: block; margin-top: 12px; font-size: 11px; line-height: 1.5; color: #64748b; }
.vase-legacy-line-fields { display: none !important; }
.vase-line-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* El acabado de la vista previa usa los mismos valores que la impresión térmica. */
#visualDocument[data-print-quality="normal"] .tpl-image-wrap img { filter: grayscale(100%); }
#visualDocument[data-print-quality="nitida"] .tpl-image-wrap img { filter: grayscale(100%) contrast(130%); }
#visualDocument[data-print-quality="alto_contraste"] .tpl-image-wrap img { filter: grayscale(100%) contrast(185%); }
.vase-tax-source { max-width: 1060px; margin: 26px auto 0; }
@media (max-width: 980px) {
    .vase-design-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .vase-status-wrap { align-self: flex-end; width: auto; }
    .vase-actions-menu { right: 0; }
    .vase-design-controls { grid-template-columns: minmax(0, 1fr); }
    .vase-design-card { padding: 13px 12px; }
    .vase-line-controls { grid-template-columns: 1fr; }
}

.vase-image-quality-tip { display: block; font-size: 10px; line-height: 1.45; color: #47704f; margin-top: 6px; }
.vase-image-quality-tip.low-resolution { color: #a16207; }
.vase-editor-notice[hidden] { display: none !important; }
.vase-editor-notice { position: fixed; z-index: 180; bottom: 22px; left: 50%; transform: translateX(-50%); width: min(450px, calc(100vw - 30px)); padding: 13px 17px; border: 1px solid #bae6fd; border-radius: 13px; background: #f0f9ff; color: #0f3b5f; font-size: 13px; font-weight: 750; box-shadow: 0 14px 40px #0f172a33; text-align: center; }
.vase-editor-notice.is-error { border-color: #fecaca; background: #fff1f2; color: #991b1b; }
.vase-editor-dialog { width: min(390px, calc(100% - 26px)); padding: 20px; border: 1px solid #dce3ed; border-radius: 15px; background: #fff; color: #172033; box-shadow: 0 22px 70px #0f172a55; }
.vase-editor-dialog::backdrop { background: rgba(15, 23, 42, .46); }
.vase-editor-dialog h2 { margin: 0 0 9px; font-size: 18px; }
.vase-editor-dialog p { margin: 0 0 18px; font-size: 13px; line-height: 1.5; color: #64748b; }
.vase-editor-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.vase-btn-danger { background: #dc2626; color: #fff; }
.vase-btn-danger:hover { background: #b91c1c; }

.vase-tax-source[hidden] { display: none !important; }
.vase-settings-main .vase-size-readout { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; justify-content: flex-start; padding: 4px 5px 1px; }
.vase-settings-main .vase-size-readout strong { white-space: nowrap; }
.vase-settings-main .vase-size-readout span { max-width: none; }
@media (max-width: 560px) {
    .vase-settings-main .vase-size-readout { flex-wrap: wrap; }
}
