.hidden { display: none !important; }
.pdf-labeler-body { background: #e8edf5; min-height: 100vh; color: #132238; }
.pdf-labeler-app { height: 100vh; }
.pdf-main { min-height: 0; }
.pdf-container {
    position: relative;
    background: linear-gradient(180deg, #dae3ef 0%, #d6deea 100%);
    overscroll-behavior: contain;
}
.pdf-viewport-toolbar-wrap {
    position: sticky;
    top: 0.75rem;
    z-index: 30;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
    margin-bottom: -3.1rem;
}
.pdf-viewport-toolbar {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid rgba(19, 34, 56, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 22px rgba(14, 29, 51, 0.15);
    backdrop-filter: blur(10px);
}
.pdf-viewport-toolbar-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.15rem 0 0.1rem;
    color: #4d6482;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.pdf-viewport-toolbar-label svg {
    width: 0.95rem;
    height: 0.95rem;
}
.pdf-zoom-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pdf-zoom-label {
    min-width: 3.15rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #19314f;
}
.pdf-manager-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(20rem, 1fr);
    gap: 1rem;
}
.page-manager-panel {
    border: 1px solid #d8e0ea;
    border-radius: 0.9rem;
    background: #fbfdff;
    padding: 0.9rem;
    min-height: 0;
}
.page-manager-panel .panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #53657b;
    margin-bottom: 0.6rem;
}
.page-manager-pages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.85rem;
    max-height: 60vh;
    overflow: auto;
    padding-right: 0.2rem;
}
.page-manager-page {
    position: relative;
    border: 1px solid #d6deea;
    border-radius: 0.85rem;
    background: #fff;
    padding: 0.7rem;
    box-shadow: 0 10px 18px rgba(17, 36, 64, 0.06);
    cursor: grab;
}
.page-manager-page.dragging {
    opacity: 0.45;
    cursor: grabbing;
}
.page-manager-page.drop-target {
    border-color: #114a8b;
    box-shadow: 0 0 0 2px rgba(17, 74, 139, 0.12);
}
.page-manager-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}
.page-manager-page-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #19314f;
}
.page-manager-page-subtitle {
    margin-top: 0.14rem;
    font-size: 0.72rem;
    color: #62768f;
}
.page-manager-source-badge {
    border-radius: 999px;
    padding: 0.16rem 0.45rem;
    background: #edf2f8;
    color: #3f5876;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}
.page-manager-thumb {
    position: relative;
    aspect-ratio: 0.77;
    border-radius: 0.7rem;
    overflow: hidden;
    background: linear-gradient(180deg, #eef3f9 0%, #e2eaf4 100%);
    border: 1px solid #dde5ef;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.65rem;
}
.page-manager-thumb canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.page-manager-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.page-manager-thumb-placeholder {
    color: #7b8da5;
    font-size: 0.72rem;
}
.page-manager-page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.page-manager-insert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.75rem;
    max-height: 23rem;
    overflow: auto;
}
.insert-page-card {
    border: 1px solid #d6deea;
    border-radius: 0.8rem;
    background: #fff;
    padding: 0.65rem;
    cursor: pointer;
}
.insert-page-card.selected {
    border-color: #114a8b;
    box-shadow: 0 0 0 2px rgba(17, 74, 139, 0.12);
    background: #f8fbff;
}
.page-manager-dropzone {
    border: 2px dashed #c3d0e0;
    border-radius: 0.85rem;
    padding: 0.8rem;
    text-align: center;
    color: #62768f;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.65);
}
.page-manager-dropzone.drop-target {
    border-color: #114a8b;
    background: rgba(17, 74, 139, 0.05);
    color: #114a8b;
}
.page-manager-summary {
    font-size: 0.76rem;
    color: #60748d;
}
.pdf-fields-panel {
    width: 24rem;
    min-width: 24rem;
    border-color: var(--bs-border-color) !important;
    overscroll-behavior: contain;
}
.toolbar-divider { width: 1px; height: 1.5rem; background: rgba(255, 255, 255, 0.25); margin: 0 0.5rem; }
.icon-16 { width: 1rem; height: 1rem; }
.icon-48 { width: 3rem; height: 3rem; color: #8ca0bc; }
.icon-96 { width: 6rem; height: 6rem; color: #b7c3d6; }
.pdf-pages-wrap { max-width: 62rem; }
#fields-list {
    overscroll-behavior: contain;
    overflow-anchor: none;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}
.model-input { width: 100%; }
.model-suggestions {
    position: relative;
    top: 0;
    left: 0;
    z-index: 10;
    max-height: 10rem;
    width: 100%;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color);
    background: #fff;
    padding: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
.model-suggestion-btn {
    border: none;
    background: transparent;
    border-radius: 0;
    text-align: left;
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}
.model-suggestion-btn:hover { background: var(--bs-light); }
.tool-btn.active {
    background-color: #114a8b !important;
    border-color: #114a8b !important;
    color: #fff !important;
    box-shadow: 0 0 0 2px rgba(17, 74, 139, 0.25);
}
.floating-tool-picker {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 1050;
    width: fit-content;
    max-width: min(42rem, calc(100vw - 2rem));
    padding: 0.55rem;
    border-radius: 1rem;
    border: 1px solid rgba(19, 34, 56, 0.1);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 34px rgba(14, 29, 51, 0.15);
    backdrop-filter: blur(8px);
}
.floating-tool-picker .tool-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.floating-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid #d2dce7;
    border-radius: 999px;
    background: #f8fafc;
    color: #19314f;
    font-size: 0.82rem;
    font-weight: 600;
}
.floating-tool-btn svg { width: 0.95rem; height: 0.95rem; }
.floating-tool-btn.active {
    border-color: #114a8b;
    background: #114a8b;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(17, 74, 139, 0.16);
}
.quick-field-editor {
    position: fixed;
    z-index: 1060;
    width: min(26rem, calc(100vw - 1.5rem));
    padding: 0.55rem;
    border: 1px solid rgba(17, 74, 139, 0.14);
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 32px rgba(14, 29, 51, 0.18);
    backdrop-filter: blur(10px);
}
.quick-field-editor .quick-field-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.quick-field-editor .quick-field-input {
    min-width: 0;
}
.quick-field-editor .quick-field-icon {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #edf2f8;
    color: #38516d;
    flex: 0 0 auto;
}
.quick-field-editor .quick-field-icon svg {
    width: 0.95rem;
    height: 0.95rem;
}
.quick-field-editor .quick-field-done {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.quick-field-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}
.quick-field-suggestions.hidden {
    display: none;
}
.quick-field-suggestion {
    max-width: 100%;
    border-radius: 999px;
    font-size: 0.72rem;
    line-height: 1.1;
}
.header-auth-menu { min-width: 12rem; }
.page-overlay {
    position: absolute;
    inset: 0;
    user-select: none;
    touch-action: none;
}
.page-overlay.tool-active { cursor: crosshair; }
.page-overlay.tool-active.point-insert { cursor: copy; }
.draft-rect {
    position: absolute;
    border: 2px dashed #dd8a12;
    background: rgba(243, 171, 43, 0.22);
    pointer-events: none;
}
.labeler-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    max-width: 28rem;
    margin-bottom: 0;
}
.loading-modal {
    position: fixed;
    inset: 0;
    z-index: 1075;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(18, 29, 46, 0.28);
    backdrop-filter: blur(4px);
}
.loading-modal-card {
    width: min(25rem, calc(100vw - 2rem));
    padding: 1.1rem 1.25rem;
    border: 1px solid rgba(17, 74, 139, 0.14);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 40px rgba(14, 29, 51, 0.18);
    text-align: center;
}
.drag-over { background: #cad8eb !important; }
.loading-spinner { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.pdf-page-shell {
    margin-bottom: 1.5rem;
    border-radius: 0.75rem;
}
.pdf-page-label {
    font-size: 0.82rem;
    color: #4f6582;
    margin-bottom: 0.45rem;
}
.pdf-page {
    position: relative;
    background: #fff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 10px 22px rgba(16, 31, 56, 0.12);
}
.field-box {
    position: absolute;
    border: 2px solid var(--field-border, #0f6ab3);
    background: var(--field-fill, rgba(15, 106, 179, 0.12));
    color: var(--field-text, #0c3d68);
    cursor: move;
    border-radius: 0.35rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.field-box:hover {
    background: var(--field-fill-hover, rgba(15, 106, 179, 0.2));
}
.field-box.selected {
    box-shadow: 0 0 0 3px rgba(17, 74, 139, 0.25);
}
.field-box[data-field-type="text"] {
    --field-border: #0b84c6;
    --field-fill: rgba(11, 132, 198, 0.12);
    --field-fill-hover: rgba(11, 132, 198, 0.22);
    --field-text: #084a70;
}
.field-box[data-field-type="multiline"] {
    --field-border: #2563eb;
    --field-fill: rgba(37, 99, 235, 0.12);
    --field-fill-hover: rgba(37, 99, 235, 0.2);
    --field-text: #183f92;
}
.field-box[data-field-type="checkbox"] {
    --field-border: #198754;
    --field-fill: rgba(25, 135, 84, 0.13);
    --field-fill-hover: rgba(25, 135, 84, 0.2);
    --field-text: #14513a;
}
.field-box[data-field-type="signature"] {
    --field-border: #7c3aed;
    --field-fill: rgba(124, 58, 237, 0.12);
    --field-fill-hover: rgba(124, 58, 237, 0.19);
    --field-text: #5525a8;
}
.field-box[data-field-type="dropdown"] {
    --field-border: #c06612;
    --field-fill: rgba(192, 102, 18, 0.13);
    --field-fill-hover: rgba(192, 102, 18, 0.2);
    --field-text: #7c450f;
}
.field-box[data-field-type="listbox"] {
    --field-border: #b45309;
    --field-fill: rgba(180, 83, 9, 0.13);
    --field-fill-hover: rgba(180, 83, 9, 0.2);
    --field-text: #6b3506;
}
.field-box[data-field-type="radio"] {
    --field-border: #c2410c;
    --field-fill: rgba(194, 65, 12, 0.12);
    --field-fill-hover: rgba(194, 65, 12, 0.19);
    --field-text: #7a2a09;
}
/* --- Preview mode --- */
.field-preview-content {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    align-items: center;
    padding: 0 2px;
}
.field-preview-content.preview-checkbox {
    justify-content: center;
    padding: 0;
}
.field-preview-content.preview-signature {
    padding: 2px;
}
.field-preview-content.preview-signature img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.85;
}
.field-box.previewing .field-chip {
    display: none;
}
.field-box.previewing {
    background: transparent;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: none;
}
#preview-btn.active {
    background: rgba(255, 255, 255, 0.2);
}
.field-chip {
    position: absolute;
    top: 0.18rem;
    left: 0.18rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    max-width: calc(100% - 0.36rem);
    min-width: 0;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    font-size: 0.62rem;
    line-height: 1.1;
    color: var(--field-text, #0c3d68);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.field-chip svg { width: 0.7rem; height: 0.7rem; flex: 0 0 auto; }
.field-chip .field-chip-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.field-chip.hide-name .field-chip-name { display: none; }
.field-chip.compact {
    top: 0.1rem;
    left: 0.1rem;
    gap: 0.18rem;
    max-width: calc(100% - 0.2rem);
    padding: 0.04rem 0.24rem;
    font-size: 0.56rem;
    line-height: 1;
}
.field-chip.icon-only {
    padding: 0.08rem 0.2rem;
    min-width: 1rem;
    justify-content: center;
}
.field-chip.wrap-name {
    align-items: flex-start;
    border-radius: 0.55rem;
    white-space: normal;
}
.field-chip.wrap-name .field-chip-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
}
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: #114a8b;
    border: 1px solid #fff;
}
.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.n { top: -5px; left: calc(50% - 5px); cursor: n-resize; }
.resize-handle.s { bottom: -5px; left: calc(50% - 5px); cursor: s-resize; }
.resize-handle.e { top: calc(50% - 5px); right: -5px; cursor: e-resize; }
.resize-handle.w { top: calc(50% - 5px); left: -5px; cursor: w-resize; }
.field-list-page {
    margin-bottom: 1rem;
}
.field-list-page:last-child {
    margin-bottom: 0;
}
.field-page-divider {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0 0 0.55rem;
    color: #62768f;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field-page-divider::before,
.field-page-divider::after {
    content: '';
    height: 1px;
    background: #dde5ef;
    flex: 1 1 auto;
}
.field-list-item {
    border: 1px solid #d8e0ea;
    background: #fff;
    border-radius: 0.7rem;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.45rem;
    cursor: pointer;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.field-list-item:last-child {
    margin-bottom: 0;
}
.field-list-item:hover {
    border-color: #b4c1d2;
    transform: translateY(-1px);
}
.field-list-item.selected {
    border-color: #114a8b;
    box-shadow: 0 8px 18px rgba(17, 74, 139, 0.1);
    background: #f8fbff;
}
.field-list-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}
.field-list-icon {
    width: 1.55rem;
    height: 1.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #edf2f8;
    color: #38516d;
    flex: 0 0 auto;
}
.field-list-icon svg {
    width: 0.82rem;
    height: 0.82rem;
}
.field-list-name {
    min-width: 0;
    font-size: 0.84rem;
    font-weight: 600;
    color: #17304f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.field-card-editor {
    margin-top: 0.65rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dbe5f0;
}
.field-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.85rem;
}
.field-card-help {
    font-size: 0.76rem;
    margin-top: 0.35rem;
}
.field-card-help.info { color: #0b5ed7; }
.field-card-help.warning { color: #9a5800; }
.field-card-subtext {
    font-size: 0.76rem;
    color: #60748d;
}
.font-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    align-items: end;
}
.font-row .auto-size-wrap {
    min-width: 7rem;
}
.field-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 600;
    background: #edf2f8;
    color: #38516d;
}
.field-type-badge svg { width: 0.8rem; height: 0.8rem; }
.fields-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
    margin-top: 0.8rem;
}
.fields-toolbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.2rem;
    gap: 0.5rem;
}
.fields-toolbar .form-control,
.fields-toolbar .form-select {
    font-size: 0.78rem;
}
#fields-list {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}
.dirty-indicator { font-size: 0.72rem; }
.normalization-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}
.normalization-card {
    border: 1px solid #d8e0ea;
    border-radius: 0.8rem;
    padding: 0.65rem 0.75rem;
    background: #fbfdff;
}
.normalization-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #53657b;
    margin: 0 0 0.5rem;
}
.normalization-card .form-check {
    margin-bottom: 0.4rem;
}
.normalization-inline {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    align-items: end;
}
.normalization-inline-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    align-items: end;
}
.normalization-card .form-text {
    font-size: 0.72rem;
    margin-top: 0.35rem;
    line-height: 1.25;
}
@media (max-width: 1100px) {
    .pdf-fields-panel { width: 100%; min-width: 0; max-height: 42vh; }
    .pdf-main { flex-direction: column !important; }
    .pdf-manager-layout {
        grid-template-columns: 1fr;
    }
    .floating-tool-picker {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        max-width: none;
    }
    .quick-field-editor {
        width: min(24rem, calc(100vw - 1rem));
    }
    .normalization-grid {
        grid-template-columns: 1fr;
    }
    .font-row {
        grid-template-columns: 1fr;
    }
    .page-manager-pages,
    .page-manager-insert-grid {
        grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    }
}
@media (max-width: 768px) {
    .pdf-viewport-toolbar-wrap {
        top: 0.5rem;
        margin-bottom: -2.85rem;
    }
    .pdf-viewport-toolbar {
        gap: 0.2rem;
        padding: 0.3rem 0.38rem;
    }
    .pdf-viewport-toolbar-label {
        display: none;
    }
}
