.docgen-layout {
    display: grid;
    gap: 1.25rem;
}

/* overflow:hidden у .admin-card ломает position: sticky у панели справа */
.admin-card:has(.docgen-layout) {
    overflow: visible;
}

@media (min-width: 1200px) {
    .docgen-layout {
        grid-template-columns: minmax(0, 1fr) 19rem;
        align-items: stretch;
    }

    .docgen-editor-column {
        min-width: 0;
    }

    .docgen-palette-column {
        display: flex;
        flex-direction: column;
        align-self: stretch;
        width: 100%;
        max-width: 19rem;
        min-height: 0;
        overflow: visible;
    }

    .docgen-layout .docgen-data-palette.legal-token-palette {
        position: sticky;
        top: var(--docgen-sticky-top, 5.5rem);
        width: 100%;
        max-width: none;
        overflow: visible;
        box-shadow: 0 14px 36px rgba(15, 23, 42, 0.1);
        z-index: 5;
    }

    .docgen-layout .docgen-data-palette.admin-card {
        overflow: visible;
    }

    .docgen-data-palette__body {
        position: relative;
    }

    .docgen-data-palette__scroll {
        max-height: calc(100vh - var(--docgen-sticky-top, 5.5rem) - 2rem);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-right: 0.25rem;
    }

    .docgen-data-palette__scroll::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    .docgen-palette-scrollbar {
        position: absolute;
        top: 0;
        right: -0.875rem;
        width: 4px;
        height: 100%;
        border-radius: 999px;
        background: rgba(148, 163, 184, 0.22);
        pointer-events: none;
    }

    .docgen-palette-scrollbar__thumb {
        width: 100%;
        min-height: 2rem;
        border-radius: 999px;
        background: #94a3b8;
        transform: translateY(0);
        will-change: transform;
    }

    .docgen-palette-sticky-sentinel {
        height: 1px;
        margin: 0;
        pointer-events: none;
    }

    .docgen-palette-drawer-trigger,
    .docgen-palette-drawer-close,
    .docgen-palette-drawer-collapse {
        display: none !important;
    }
}

@media (max-width: 1199px) {
    .docgen-layout {
        --docgen-palette-drawer-width: min(19rem, 40vw);
        --docgen-palette-drawer-overlap: 1.25rem;
        grid-template-columns: minmax(0, 1fr);
    }

    .docgen-editor-column {
        min-width: 0;
    }

    .docgen-pages-canvas {
        margin-right: 0;
        transition: margin-right 0.24s ease;
    }

    .is-palette-drawer-open .docgen-pages-canvas,
    body.docgen-palette-drawer-open .docgen-pages-canvas {
        margin-right: calc(var(--docgen-palette-drawer-width) - var(--docgen-palette-drawer-overlap));
    }

    .docgen-palette-column {
        position: fixed;
        top: var(--docgen-palette-drawer-top, var(--docgen-sticky-top, 4.5rem));
        right: 0;
        bottom: 0.5rem;
        width: var(--docgen-palette-drawer-width);
        z-index: 45;
        transform: translateX(100%);
        transition: transform 0.24s ease, top 0.2s ease;
        pointer-events: none;
        padding: 0;
        margin: 0;
    }

    .docgen-palette-column .docgen-data-palette.legal-token-palette {
        position: static;
        top: auto;
        width: 100%;
        height: 100%;
        max-height: calc(100vh - var(--docgen-palette-drawer-top, var(--docgen-sticky-top, 4.5rem)) - 0.75rem);
        border-radius: 0.5rem 0 0 0.5rem;
        box-shadow: -6px 0 24px rgba(15, 23, 42, 0.12);
        overflow: hidden;
    }

    .docgen-palette-column .docgen-data-palette.admin-card {
        height: 100%;
        border-radius: 0.5rem 0 0 0.5rem;
    }

    .docgen-data-palette__body {
        height: 100%;
    }

    .docgen-data-palette__scroll {
        max-height: calc(100vh - var(--docgen-palette-drawer-top, var(--docgen-sticky-top, 4.5rem)) - 1rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-right: 0.25rem;
    }

    .docgen-palette-sticky-sentinel,
    .docgen-palette-scrollbar {
        display: none !important;
    }

    .is-palette-drawer-open .docgen-palette-column,
    body.docgen-palette-drawer-open .docgen-palette-column {
        transform: translateX(0);
        pointer-events: auto;
    }

    .docgen-palette-drawer-trigger {
        position: fixed;
        right: 0;
        top: 50%;
        z-index: 44;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
        width: 2.15rem;
        min-height: 8rem;
        padding: 0.65rem 0.2rem;
        border: 1px solid #cbd5e1;
        border-right: 0;
        border-radius: 0.5rem 0 0 0.5rem;
        background: #fff;
        color: #334155;
        box-shadow: -4px 0 16px rgba(15, 23, 42, 0.08);
        cursor: pointer;
        transition: opacity 0.2s ease, top 0.15s ease;
        transform: translateY(-50%);
    }

    .docgen-palette-drawer-trigger[hidden] {
        display: none !important;
    }

    .docgen-palette-column:not(.docgen-palette-drawer-zone) {
        visibility: hidden;
        pointer-events: none;
    }

    .docgen-palette-drawer-trigger__label {
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        line-height: 1.1;
        text-align: center;
    }

    .docgen-palette-drawer-trigger__icon {
        width: 0.55rem;
        height: 0.55rem;
        border-top: 2px solid currentColor;
        border-left: 2px solid currentColor;
        transform: rotate(-45deg);
        margin-bottom: 0.15rem;
    }

    .docgen-palette-drawer-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        margin-bottom: 0.35rem;
    }

    .docgen-palette-drawer-head .legal-token-palette__title {
        margin-bottom: 0;
    }

    .docgen-palette-drawer-close {
        flex: 0 0 auto;
        width: 2rem;
        height: 2rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        background: #fff;
        color: #64748b;
        font-size: 1.35rem;
        line-height: 1;
        cursor: pointer;
    }

    .docgen-palette-drawer-close:hover {
        background: #f8fafc;
        color: #0f172a;
    }

    .docgen-palette-drawer-collapse {
        position: absolute;
        left: 0;
        top: 50%;
        z-index: 3;
        display: none;
        align-items: center;
        justify-content: center;
        width: 1.5rem;
        height: 3.25rem;
        padding: 0;
        border: 1px solid #cbd5e1;
        border-right: 0;
        border-radius: 0.5rem 0 0 0.5rem;
        background: #fff;
        color: #475569;
        box-shadow: -3px 0 12px rgba(15, 23, 42, 0.1);
        cursor: pointer;
        transform: translate(-100%, -50%);
    }

    .docgen-palette-drawer-collapse__icon {
        display: block;
        width: 0.55rem;
        height: 0.55rem;
        border-top: 2px solid currentColor;
        border-right: 2px solid currentColor;
        transform: rotate(45deg);
        margin-left: 0.15rem;
    }

    .docgen-palette-drawer-collapse:hover {
        background: #f8fafc;
        color: #0f172a;
    }

    body.docgen-palette-drawer-open .docgen-palette-drawer-collapse,
    .is-palette-drawer-open .docgen-palette-drawer-collapse {
        display: flex;
    }

    body.docgen-palette-drawer-open .docgen-palette-drawer-trigger {
        opacity: 0;
        pointer-events: none;
    }
}

.docgen-pages-canvas {
    background: #e2e8f0;
    padding: 1.5rem 1rem;
    border-radius: 0.5rem;
    margin-top: 0.25rem;
}

/* Legacy continuous editor (AI training preview only; main editor uses .docgen-pages-stack) */
.docgen-continuous-canvas {
    background: #e2e8f0;
    padding: 1.5rem 1rem;
    border-radius: 0.5rem;
    margin-top: 0.25rem;
}

.docgen-continuous-wrap {
    width: min(210mm, 100%);
    margin: 0 auto;
    --docgen-sheet-height: 297mm;
}

.docgen-continuous-wrap--landscape {
    width: min(297mm, 100%);
    --docgen-sheet-height: 210mm;
}

.docgen-page-count {
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    text-align: center;
}

.docgen-continuous-sheet {
    position: relative;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    min-height: var(--docgen-sheet-height, 297mm);
}

.docgen-page-ghost-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.docgen-page-ghost {
    position: absolute;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 2px;
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08),
        0 8px 24px rgba(15, 23, 42, 0.1);
}

.docgen-page-editor--continuous {
    position: relative;
    z-index: 2;
    min-height: var(--docgen-sheet-height, 297mm);
    overflow-x: hidden;
    overflow-y: visible;
    height: auto;
    max-height: none;
    background: transparent;
}

.docgen-page-guides {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.docgen-page-guide {
    --docgen-page-break-line: 10px;
    position: absolute;
    left: 0;
    right: 0;
    height: var(--docgen-page-break-line);
    background: #cbd5e1;
    box-sizing: border-box;
    pointer-events: none;
}

.docgen-page-ghost::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 24px;
    background: linear-gradient(to bottom, transparent, rgba(226, 232, 240, 0.55));
    pointer-events: none;
}

.docgen-page-break-spacer,
.docgen-page-break-filler {
    display: none !important;
}

.docgen-split-sandbox {
    position: fixed;
    left: -10000px;
    top: 0;
    visibility: hidden;
    pointer-events: none;
}

.docgen-tiptap-root {
    width: 100%;
    display: flex;
    justify-content: center;
    min-height: 200px;
}

.docgen-tiptap-root .ProseMirror {
    outline: none;
    font-size: 0.9375rem;
    line-height: 1.65;
    word-break: break-word;
    min-height: 1.5rem;
}

.docgen-tiptap-root .rm-with-pagination {
    margin: 0 auto;
    background: #fff;
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08),
        0 8px 24px rgba(15, 23, 42, 0.1);
}

.docgen-tiptap-root .rm-page-break {
    background: #e2e8f0;
}

.docgen-pages-stack.docgen-tiptap-root {
    gap: 0;
}


.docgen-page-sheet {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    flex-shrink: 0;
    margin: 0 auto;
    background: #fff;
    border: none;
    border-radius: 2px;
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08),
        0 8px 24px rgba(15, 23, 42, 0.1);
    overflow: hidden;
}

.docgen-page-sheet--portrait {
    width: min(210mm, 100%);
    height: 297mm;
    --docgen-page-height: 297mm;
}

.docgen-page-sheet--landscape {
    width: min(297mm, 100%);
    height: 210mm;
    --docgen-page-height: 210mm;
}

.docgen-page-label {
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.docgen-page-editor {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    overflow: clip;
    --docgen-editor-pad-y: 18mm;
    --docgen-editor-pad-x: 16mm;
    padding: var(--docgen-editor-pad-y) var(--docgen-editor-pad-x);
    outline: none;
    font-size: 0.9375rem;
    line-height: 1.65;
    word-break: break-word;
    box-sizing: border-box;
}

.docgen-page-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(16, 184, 150, 0.2);
}

.docgen-page-editor.is-drag-over {
    background: #f0fdf9;
}

.docgen-preview-body {
    background: #e2e8f0;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.docgen-preview-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 210mm;
    margin: 0 auto;
}

.docgen-preview-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    padding: 18mm 16mm;
    min-height: 297mm;
    font-size: 0.9375rem;
    line-height: 1.65;
}

.docgen-preview-page--landscape {
    max-width: 297mm;
    min-height: 210mm;
}

.docgen-format-toolbar-sentinel {
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.docgen-format-toolbar {
    position: sticky;
    top: 0;
    z-index: 31;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #f8fafc;
}

.docgen-format-toolbar.is-stuck {
    position: fixed;
    top: 0;
    margin: 0;
    box-sizing: border-box;
    padding: 0.75rem 2rem 0.75rem calc(2rem + 1.5rem);
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.docgen-format-toolbar-spacer:not([hidden]) {
    display: block;
    margin-bottom: 1rem;
}

body.docgen-toolbar-stuck .flex-1.ml-64 > header {
    visibility: hidden;
}

.docgen-format-toolbar__group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.75rem;
    border-right: 1px solid #e2e8f0;
}

.docgen-format-toolbar__group:last-child {
    border-right: 0;
    padding-right: 0;
}

.docgen-format-toolbar__group--end {
    margin-left: 0;
}

.docgen-format-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #fff;
    color: #334155;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.docgen-format-btn.is-active {
    border-color: #10b896;
    background: #ecfdf8;
    color: #047857;
}

.docgen-format-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    padding: 0;
}

.docgen-align-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 0.875rem;
    height: 0.6875rem;
}

.docgen-align-icon > span {
    display: block;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
}

.docgen-align-icon--left > span:nth-child(1) {
    width: 100%;
}

.docgen-align-icon--left > span:nth-child(2) {
    width: 72%;
}

.docgen-align-icon--left > span:nth-child(3) {
    width: 44%;
}

.docgen-align-icon--center > span {
    margin-inline: auto;
}

.docgen-align-icon--center > span:nth-child(1) {
    width: 100%;
}

.docgen-align-icon--center > span:nth-child(2) {
    width: 72%;
}

.docgen-align-icon--center > span:nth-child(3) {
    width: 44%;
}

.docgen-align-icon--right > span {
    margin-left: auto;
}

.docgen-align-icon--right > span:nth-child(1) {
    width: 100%;
}

.docgen-align-icon--right > span:nth-child(2) {
    width: 72%;
}

.docgen-align-icon--right > span:nth-child(3) {
    width: 44%;
}

.docgen-align-icon--justify > span {
    width: 100%;
}

.docgen-orient-icon {
    display: block;
    border: 2px solid currentColor;
    border-radius: 1px;
    box-sizing: border-box;
}

.docgen-orient-icon--portrait {
    width: 0.625rem;
    height: 0.875rem;
}

.docgen-orient-icon--landscape {
    width: 0.875rem;
    height: 0.625rem;
}

.docgen-format-size-label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: #475569;
}

/* Tables in docgen editor and preview */
.docgen-page-editor .docgen-table,
.docgen-preview-page .docgen-table,
.docgen-page-editor table,
.docgen-preview-page table,
.docgen-tiptap-root .docgen-table,
.docgen-tiptap-root table,
.docgen-tiptap-root .table-plus {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0.65rem 0;
    margin-left: 0;
    margin-right: 0;
    table-layout: fixed;
    float: none;
    position: static;
    left: auto;
    transform: none;
}

/* Resizable tables: col widths from columnResizing, not forced 100% stretch */
.docgen-tiptap-root .tableWrapper {
    width: 100%;
    margin: 0.65rem 0;
    overflow-x: auto;
    position: relative;
}

.docgen-tiptap-root .tableWrapper > table,
.docgen-tiptap-root .tableWrapper > .docgen-table {
    width: auto;
    min-width: 100%;
    max-width: none;
    margin: 0;
}

/* PaginationPlus injects display:contents on tables — breaks column resize */
.docgen-tiptap-root.rm-with-pagination table,
.docgen-tiptap-root .rm-with-pagination table {
    display: table !important;
    border-collapse: collapse !important;
}

.docgen-tiptap-root.rm-with-pagination table tbody,
.docgen-tiptap-root .rm-with-pagination table tbody {
    display: table-row-group !important;
    max-height: none !important;
    overflow: visible !important;
}

.docgen-tiptap-root.rm-with-pagination table tr,
.docgen-tiptap-root .rm-with-pagination table tr,
.docgen-tiptap-root.rm-with-pagination table > tr,
.docgen-tiptap-root .rm-with-pagination table > tr {
    display: table-row !important;
}

.docgen-tiptap-root.rm-with-pagination .table-row-group,
.docgen-tiptap-root .rm-with-pagination .table-row-group {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
}

.docgen-tiptap-root.resize-cursor,
.docgen-tiptap-root .resize-cursor {
    cursor: col-resize !important;
}

.docgen-page-editor .docgen-table td,
.docgen-page-editor .docgen-table th,
.docgen-preview-page .docgen-table td,
.docgen-preview-page .docgen-table th,
.docgen-page-editor table td,
.docgen-page-editor table th,
.docgen-preview-page table td,
.docgen-preview-page table th,
.docgen-tiptap-root .docgen-table td,
.docgen-tiptap-root .docgen-table th,
.docgen-tiptap-root table td,
.docgen-tiptap-root table th,
.docgen-tiptap-root .table-plus td,
.docgen-tiptap-root .table-plus th {
    border: 1px solid #94a3b8;
    padding: 0.35rem 0.5rem;
    vertical-align: top;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.docgen-page-editor .docgen-table td p,
.docgen-page-editor .docgen-table th p,
.docgen-preview-page .docgen-table td p,
.docgen-preview-page .docgen-table th p,
.docgen-tiptap-root .docgen-table td p,
.docgen-tiptap-root .docgen-table th p,
.docgen-tiptap-root table td p,
.docgen-tiptap-root table th p,
.docgen-tiptap-root .table-plus td p,
.docgen-tiptap-root .table-plus th p {
    margin: 0;
    min-height: 1.2em;
}

.docgen-page-editor .docgen-table__cell--selected,
.docgen-tiptap-root .selectedCell {
    outline: 2px solid #10b981;
    outline-offset: -2px;
    background: #ecfdf5;
}

.docgen-table-menu {
    position: relative;
}

.docgen-table-menu__toggle {
    min-width: 6.5rem;
    font-size: 0.8125rem;
}

.docgen-table-menu__dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 50;
    min-width: 13rem;
    padding: 0.35rem 0;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.docgen-table-menu__item {
    display: block;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    color: #334155;
    cursor: pointer;
}

.docgen-table-menu__item:hover:not(:disabled):not(.is-disabled) {
    background: #f1f5f9;
}

.docgen-table-menu__item--danger {
    color: #dc2626;
}

.docgen-table-menu__item:disabled,
.docgen-table-menu__item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.docgen-table-menu__sep {
    margin: 0.35rem 0;
    border: 0;
    border-top: 1px solid #e2e8f0;
}

.docgen-table-insert-panel {
    max-width: 22rem;
}

.docgen-table-grid-picker {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
}

.docgen-table-grid-picker__cell {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #cbd5e1;
    border-radius: 2px;
    background: #fff;
    cursor: pointer;
    padding: 0;
}

.docgen-table-grid-picker__cell.is-active {
    background: #10b981;
    border-color: #059669;
}

.docgen-table-grid-picker__size {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    text-align: center;
}

.docgen-table-insert-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.docgen-table-insert-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.docgen-tiptap-root .column-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    margin: 0;
    padding: 0;
    cursor: col-resize;
    z-index: 30;
    background: transparent;
    pointer-events: auto;
}

.docgen-tiptap-root .column-resize-handle:hover,
.docgen-tiptap-root .column-resize-dragging {
    background: rgba(16, 185, 129, 0.35);
}

/* Legacy TablePlus dot handles — hidden if old content still renders them */
.docgen-tiptap-root .slider,
.docgen-tiptap-root .handle {
    display: none !important;
}

.docgen-custom-fields-group--first {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.docgen-custom-fields-group {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-company-fields-group {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-company-blocks-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.docgen-company-block {
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    overflow: hidden;
}

.docgen-company-block__header-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #f8fafc;
}

.docgen-company-block__title-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.docgen-company-block__header {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
}

.docgen-company-block__title-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
}

.docgen-company-block__edit {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #fff;
    color: #475569;
    font-size: 0.75rem;
    cursor: pointer;
}

.docgen-company-block__edit:hover {
    border-color: #10b896;
    color: #047857;
    background: #ecfdf8;
}

.docgen-company-block__chevron {
    color: #64748b;
    font-weight: 400;
}

.docgen-company-block__remove {
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    background: #fef2f2;
    color: #b91c1c;
    cursor: pointer;
}

.docgen-company-block__body {
    padding: 0.5rem 0.625rem 0.75rem;
}

.docgen-company-block__group {
    margin-bottom: 0.75rem;
}

.docgen-company-block__group:last-child {
    margin-bottom: 0;
}

.docgen-generate-step--hidden {
    display: none;
}

.docgen-generate-step-nav.consultation-modal__modes {
    margin: 0.75rem 0 0;
    gap: 0.25rem;
    padding: 0.25rem;
    align-items: stretch;
    justify-items: stretch;
    grid-auto-rows: 1fr;
}

.docgen-generate-step-nav.consultation-modal__modes.docgen-generate-step-nav--count-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.docgen-generate-step-nav.consultation-modal__modes.docgen-generate-step-nav--count-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.docgen-generate-step-nav.consultation-modal__modes.docgen-generate-step-nav--count-4,
.docgen-generate-step-nav.consultation-modal__modes.docgen-generate-step-nav--count-5,
.docgen-generate-step-nav.consultation-modal__modes.docgen-generate-step-nav--count-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.docgen-generate-step-nav__btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 3rem;
    box-sizing: border-box;
    padding: 0.45rem 0.3rem;
    font-size: inherit;
    line-height: 1.2;
    text-align: center;
}

.docgen-generate-step-nav__title {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    color: inherit;
}

.docgen-generate-step-nav__btn.is-active .docgen-generate-step-nav__title {
    color: #047857;
}

.docgen-generate-step-nav__num {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.2;
    color: #94a3b8;
    text-transform: lowercase;
}

.docgen-generate-step-nav__btn.is-active .docgen-generate-step-nav__num {
    color: #6ee7b7;
}

.docgen-generate-step-nav__warn {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    z-index: 1;
}

.docgen-generate-step-nav__warn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    background: #fef3c7;
    color: #d97706;
    font-size: 0.625rem;
    font-weight: 800;
    line-height: 1;
    cursor: help;
}

.docgen-generate-step-nav__warn-tooltip {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.35rem);
    z-index: 3;
    width: max-content;
    max-width: 11rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.5rem;
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.625rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.docgen-generate-step-nav__warn:hover .docgen-generate-step-nav__warn-tooltip {
    opacity: 1;
    visibility: visible;
}

.docgen-generate-step-nav__warn--hidden {
    display: none;
}

@media (min-width: 640px) {
    .docgen-generate-step-nav__btn {
        min-height: 3.25rem;
        padding: 0.55rem 0.4rem;
    }

    .docgen-generate-step-nav__title {
        font-size: 0.8125rem;
    }

    .docgen-generate-step-nav__num {
        font-size: 0.75rem;
    }
}

.docgen-generate-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.docgen-generate-footer:has([data-docgen-step-back]:not(.docgen-generate-btn-back--hidden)) {
    grid-template-columns: minmax(6.5rem, 34%) 1fr;
}

.docgen-generate-btn-back {
    width: 100%;
    padding: 0.85rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    color: #475569;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.docgen-generate-footer .consultation-modal__submit {
    width: 100%;
    margin: 0;
}

.docgen-generate-btn-back:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.docgen-generate-btn-back--hidden,
.docgen-generate-btn-submit--hidden,
.docgen-generate-btn-next--hidden {
    display: none;
}

.docgen-generate-section {
    margin-bottom: 1rem;
    min-width: 0;
}

.docgen-generate-section:first-child {
    margin-top: 0;
}

.docgen-generate-panel .consultation-modal__form {
    min-width: 0;
    width: 100%;
}

.docgen-generate-section__title {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.docgen-generate-section__hint {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: #64748b;
}

.docgen-generate-panel {
    width: min(720px, 100%);
    max-width: calc(100vw - 1.5rem);
    min-height: min(36rem, calc(100vh - 2rem));
}

.docgen-generate-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    padding-right: 0.15rem;
    align-content: start;
}

.docgen-generate-custom-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.docgen-generate-companies-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    width: 100%;
}

.docgen-generate-companies-grid:has(.docgen-generate-company:only-child) {
    grid-template-columns: minmax(0, 1fr);
}

.docgen-generate-company {
    margin: 0;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    min-width: 0;
}

.docgen-generate-company__title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
}

.docgen-generate-company__head {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.docgen-generate-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    padding: 0.2rem;
    border-radius: 0.75rem;
    background: #f1f5f9;
}

.docgen-generate-hint {
    position: relative;
    flex-shrink: 0;
    width: 1.3rem;
    height: 1.3rem;
    border: 1.5px solid #94a3b8;
    border-radius: 9999px;
    background: #fff;
    color: #64748b;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.docgen-generate-hint--inline {
    width: 1.1rem;
    height: 1.1rem;
    border-color: #cbd5e1;
    background: transparent;
}

.docgen-generate-mode__btn.is-active .docgen-generate-hint--inline {
    border-color: #86efac;
    color: #047857;
    background: #ecfdf5;
}

.docgen-generate-hint__icon {
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
}

.docgen-generate-hint--inline .docgen-generate-hint__icon {
    font-size: 0.625rem;
}

.docgen-generate-hint--inline .docgen-generate-hint__tooltip {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

.docgen-generate-hint__tooltip {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.4rem);
    z-index: 3;
    width: max-content;
    max-width: 13.5rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.55rem;
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.docgen-generate-hint:hover .docgen-generate-hint__tooltip,
.docgen-generate-hint:focus-visible .docgen-generate-hint__tooltip {
    opacity: 1;
    visibility: visible;
}

.docgen-generate-mode__btn {
    border: 0;
    border-radius: 0.55rem;
    padding: 0.45rem 0.4rem;
    background: transparent;
    color: #475569;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.docgen-generate-mode__btn--auto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.docgen-generate-mode__btn-text {
    min-width: 0;
}

.docgen-generate-mode__btn.is-active {
    background: #fff;
    color: #047857;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.docgen-generate-company__fields {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.docgen-generate-director-block {
    margin-top: 0.25rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
}

.docgen-generate-director-hint {
    margin: 0 0 0.75rem;
}

.docgen-generate-company-preview {
    margin-top: 0.15rem;
}

.docgen-generate-company-preview__text {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #64748b;
    word-break: break-word;
}

.docgen-generate-director-nominative-row {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-generate-director-nominative-row__label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.docgen-generate-director-nominative-copy {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f766e;
    cursor: pointer;
    line-height: 1.4;
}

.docgen-generate-director-nominative-copy:hover:not(:disabled) {
    text-decoration: underline;
}

.docgen-generate-director-nominative-copy:disabled {
    color: #94a3b8;
    cursor: default;
}

.docgen-generate-director-nominative-copy.is-copied {
    color: #047857;
}

.docgen-generate-company__fields--manual {
    max-height: 16rem;
    overflow-y: auto;
    padding-right: 0.1rem;
}

.docgen-generate-company__panel--hidden {
    display: none;
}

.docgen-generate-field {
    display: block;
    min-width: 0;
}

.docgen-generate-field__input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.docgen-generate-panel input.docgen-generate-field__input.form-input:not([type="checkbox"]) {
    min-height: 2.625rem;
    line-height: 1.25;
}

.docgen-generate-panel input[type="date"].docgen-generate-field__input.form-input {
    height: 2.625rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    appearance: none;
    -webkit-appearance: none;
}

.docgen-generate-panel input[type="date"].docgen-generate-field__input.form-input::-webkit-calendar-picker-indicator {
    margin: 0;
    cursor: pointer;
}

.docgen-preview-body.docgen-generate-open .docgen-generate-panel,
body.docgen-generate-open .docgen-generate-panel,
.docgen-preview-body.docgen-generate-open .docgen-generate-panel *,
body.docgen-generate-open .docgen-generate-panel * {
    box-sizing: border-box;
}

.docgen-preview-body.docgen-generate-open textarea.docgen-generate-field__input.form-input,
body.docgen-generate-open textarea.docgen-generate-field__input.form-input {
    min-height: 8.25rem;
    resize: vertical;
}

.docgen-generate-input-wrap {
    position: relative;
}

.docgen-generate-input-wrap .docgen-generate-field__input:not(textarea) {
    padding-right: 7.25rem;
}

.docgen-generate-input-wrap--date .docgen-generate-field__input {
    padding-right: 9rem;
}

.docgen-generate-input-wrap--textarea {
    width: 75%;
    max-width: 75%;
}

.docgen-generate-input-wrap--textarea .docgen-generate-field__input {
    padding-bottom: 1.5rem;
}

.docgen-generate-skip-link {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    padding: 0;
    z-index: 1;
}

.docgen-generate-input-wrap--textarea .docgen-generate-skip-link {
    top: auto;
    bottom: 0.55rem;
    transform: none;
}

.docgen-generate-skip-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.docgen-generate-field.is-skipped .docgen-generate-field__input {
    opacity: 0.55;
    background: #f8fafc;
    color: #94a3b8;
}

.docgen-generate-field.is-skipped .docgen-generate-skip-link {
    color: #64748b;
}

.docgen-generate-field.is-skipped .form-label-compact {
    color: #cbd5e1;
}

.docgen-preview-body.docgen-generate-open,
body.docgen-generate-open {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1e293b;
    overflow: hidden;
}

/* Как в «Заказать консультацию»: центр заголовка, отступ до полей как у блока вкладок */
.docgen-generate-panel .consultation-modal__header {
    margin-bottom: 0.75rem;
}

.docgen-generate-panel .consultation-modal__title {
    margin: 0;
}

.docgen-generate-panel .consultation-modal__subtitle {
    margin-top: 0.35rem;
    text-align: center;
    line-height: 1.45;
}

.docgen-generate-panel .docgen-generate-scroll {
    margin-top: 2.75rem;
}

.docgen-generate-panel:has(.docgen-generate-step-nav) .docgen-generate-scroll {
    margin-top: 0.5rem;
}

.docgen-preview-body.docgen-generate-open .consultation-modal__submit,
body.docgen-generate-open .consultation-modal__submit {
    width: 100%;
}

@media (min-width: 640px) {
    .docgen-generate-mode__btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.55rem;
    }
}

@media (max-width: 639px) {
    .docgen-generate-companies-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.docgen-custom-fields-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.docgen-passport-block {
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    overflow: hidden;
}

.docgen-passport-block__header-row {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #f8fafc;
}

.docgen-passport-block__chip {
    flex: 1 1 auto;
    min-width: 0;
}

.docgen-passport-block__body {
    padding: 0.5rem 0.625rem 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-passport-block__subchips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.docgen-passport-block__subchip {
    font-size: 0.6875rem;
    padding: 0.15rem 0.45rem;
}

.docgen-fio-block {
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    overflow: hidden;
}

.docgen-fio-block__header-row {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #f8fafc;
}

.docgen-fio-block__chip {
    flex: 1 1 auto;
    min-width: 0;
}

.docgen-fio-block__body {
    padding: 0.5rem 0.625rem 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-fio-block__subchips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.docgen-fio-block__subchip {
    font-size: 0.6875rem;
    padding: 0.15rem 0.45rem;
}

.docgen-sum-block {
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    overflow: hidden;
}

.docgen-sum-block__header-row {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.25rem;
    background: #f8fafc;
}

.docgen-sum-block__chip {
    flex: 1 1 auto;
    min-width: 0;
}

.docgen-sum-block__body {
    padding: 0.5rem 0.625rem 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.docgen-sum-block__subchips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.docgen-sum-block__subchip {
    font-size: 0.6875rem;
    padding: 0.15rem 0.45rem;
}

.docgen-custom-field-row {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
}

.docgen-custom-field-row__chip,
.docgen-passport-block__chip,
.docgen-fio-block__chip,
.docgen-sum-block__chip {
    flex: 1 1 auto;
    min-width: 0;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
    border-radius: 0.625rem;
    white-space: normal;
    text-align: left;
}

.docgen-custom-field-chip__name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
}

.docgen-custom-field-chip__meta {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #94a3b8;
    text-transform: uppercase;
    line-height: 1.2;
}

.docgen-custom-field-btn {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #f8fafc;
    font-size: 0.6875rem;
    line-height: 1;
    color: #475569;
    cursor: pointer;
}

.docgen-custom-field-btn--danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fef2f2;
}

.docgen-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.docgen-modal.hidden {
    display: none;
}

.docgen-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.docgen-modal__panel {
    position: relative;
    width: min(24rem, 100%);
    padding: 1.25rem;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.docgen-modal__panel--wide {
    width: min(36rem, 100%);
}

.docgen-modal__panel--ai {
    display: flex;
    flex-direction: column;
    max-height: min(88vh, 52rem);
    padding: 0;
    overflow: hidden;
}

.docgen-modal__panel--ai .docgen-modal__header {
    flex-shrink: 0;
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.docgen-modal__panel--ai .docgen-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.docgen-modal__panel--ai .docgen-modal__footer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.75rem 1.25rem 1.25rem;
    border-top: 1px solid #f1f5f9;
    background: #fff;
}

.docgen-modal__title {
    margin: 0 0 0.35rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
}

.docgen-custom-field-format {
    margin-bottom: 0;
}

.docgen-custom-field-format.hidden {
    display: none;
}

.docgen-generate-passport-grid {
    display: grid;
    gap: 1rem;
}

.docgen-generate-passport-block {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #f8fafc;
}

.docgen-generate-passport-block__title {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.docgen-generate-passport-block__fields {
    display: grid;
    gap: 0.75rem;
}

.docgen-generate-fio-grid {
    display: grid;
    gap: 1rem;
}

.docgen-generate-fio-block {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #f8fafc;
}

.docgen-generate-fio-block__title {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.docgen-generate-fio-block__fields {
    display: grid;
    gap: 0.75rem;
}

.docgen-fio-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.docgen-fio-warning__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    background: #fb923c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.docgen-fio-warning__text {
    flex: 1 1 auto;
}

.docgen-generate-sum-grid {
    display: grid;
    gap: 1rem;
}

.docgen-generate-sum-block {
    display: grid;
    gap: 0.75rem;
}

.docgen-generate-sum-block__fields {
    display: grid;
    gap: 0.75rem;
}

.docgen-generate-input-wrap--sum-words.docgen-sum-words--auto .docgen-generate-field__input {
    border-color: #22c55e;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
}

.docgen-sum-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.docgen-sum-warning__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    background: #fb923c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.docgen-sum-warning__text {
    flex: 1 1 auto;
}

.docgen-modal__lead {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
}

.docgen-ai-replacements {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.docgen-doc-review-step--hidden {
    display: none;
}

.docgen-doc-review-form {
    display: grid;
    gap: 1rem;
}

.docgen-doc-review-field {
    display: grid;
    gap: 0.35rem;
}

.docgen-doc-review-field .form-label,
.docgen-doc-review-field .form-label-compact {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0;
}

.docgen-doc-review-field .form-input,
.docgen-doc-review-field input.form-input,
.docgen-doc-review-field textarea.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    color: #1e293b;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.docgen-doc-review-field .form-input:focus,
.docgen-doc-review-field input.form-input:focus,
.docgen-doc-review-field textarea.form-input:focus {
    outline: none;
    border-color: #2663DD;
    box-shadow: 0 0 0 3px rgba(38, 99, 221, 0.15);
}

.docgen-doc-review-field .form-input::placeholder {
    color: #94a3b8;
}

.docgen-doc-review-question {
    min-height: 6rem;
    resize: vertical;
}

.docgen-doc-review-status:empty {
    display: none;
}

.docgen-doc-review-results {
    display: grid;
    gap: 1rem;
    max-height: min(60vh, 32rem);
    overflow: auto;
    padding-right: 0.25rem;
}

.docgen-doc-review__meta {
    margin: 0;
    font-size: 0.8125rem;
    color: #64748b;
}

.docgen-doc-review__section {
    display: grid;
    gap: 0.5rem;
}

.docgen-doc-review__heading {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.docgen-doc-review__text {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: #334155;
    white-space: pre-wrap;
}

.docgen-doc-review__issues {
    display: grid;
    gap: 0.625rem;
}

.docgen-doc-review__issue {
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #f8fafc;
}

.docgen-doc-review__issue-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.docgen-doc-review__issue-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
}

.docgen-doc-review__severity {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.45rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
}

.docgen-doc-review__severity--high {
    background: #fee2e2;
    color: #991b1b;
}

.docgen-doc-review__severity--medium {
    background: #ffedd5;
    color: #9a3412;
}

.docgen-doc-review__severity--low {
    background: #e0f2fe;
    color: #075985;
}

.docgen-doc-review__quote {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.625rem;
    border-left: 3px solid #cbd5e1;
    font-size: 0.8125rem;
    color: #475569;
    background: #fff;
    border-radius: 0 0.375rem 0.375rem 0;
}

.docgen-doc-review__recommendations {
    margin: 0;
    padding-left: 1.125rem;
    display: grid;
    gap: 0.5rem;
}

.docgen-doc-review__recommendation {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #334155;
}

.docgen-doc-review__recommendation strong {
    display: block;
    color: #0f172a;
}

.docgen-doc-review__disclaimer {
    margin: 0;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #64748b;
}

.docgen-doc-review-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.docgen-doc-review-tabs__btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0.625rem 0.25rem;
    margin-bottom: -1px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.docgen-doc-review-tabs__btn.is-active {
    color: #0f766e;
    border-bottom-color: #10b981;
}

.docgen-doc-review-pane--hidden {
    display: none !important;
}

.docgen-doc-review-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: min(52vh, 28rem);
    overflow: auto;
}

.docgen-doc-review-history__item {
    display: grid;
    grid-template-columns: 9rem 1fr auto;
    gap: 0.35rem 0.75rem;
    align-items: start;
    width: 100%;
    text-align: left;
    padding: 0.75rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.docgen-doc-review-history__item:hover {
    border-color: #10b981;
    box-shadow: 0 1px 4px rgba(15, 118, 110, 0.12);
}

.docgen-doc-review-history__item-date {
    font-size: 0.75rem;
    color: #64748b;
}

.docgen-doc-review-history__item-type {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
}

.docgen-doc-review-history__item-summary {
    grid-column: 2 / -1;
    font-size: 0.8125rem;
    color: #475569;
    line-height: 1.4;
}

.docgen-doc-review-history__item-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
}

.docgen-doc-review-history__empty {
    margin: 0;
}

.docgen-review-highlight {
    border-radius: 0.15rem;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    cursor: help;
}

.docgen-review-highlight--high {
    background: rgba(254, 202, 202, 0.85);
    outline: 1px solid rgba(220, 38, 38, 0.35);
}

.docgen-review-highlight--medium {
    background: rgba(254, 240, 138, 0.85);
    outline: 1px solid rgba(217, 119, 6, 0.35);
}

.docgen-review-highlight--low {
    background: rgba(191, 219, 254, 0.85);
    outline: 1px solid rgba(37, 99, 235, 0.35);
}

body.docgen-review-comment-mode .docgen-public-tool {
    outline: 2px solid rgba(16, 185, 129, 0.35);
    outline-offset: 4px;
    border-radius: 0.75rem;
}

#docgenReviewCommentModeBtn.is-active {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}

body.docgen-preview-open {
    overflow: hidden;
}

.docgen-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 160;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
}

.docgen-preview-overlay__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.docgen-preview-overlay__title-wrap {
    min-width: 0;
}

.docgen-preview-overlay__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.docgen-preview-overlay__hint {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
    color: #64748b;
}

.docgen-preview-overlay__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.docgen-preview-overlay__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 1.5rem 1rem 2rem;
}

.docgen-preview-overlay__sheet {
    width: 210mm;
    max-width: calc(100vw - 2rem);
    margin: 0 auto 1.5rem;
}

.docgen-preview-overlay__sheet[data-orient="landscape"] {
    width: 297mm;
}

.docgen-preview-overlay__sheet .docgen-preview-page {
    outline: none;
    cursor: text;
}

.docgen-preview-overlay__sheet .docgen-preview-page:focus {
    box-shadow: 0 0 0 2px rgba(16, 184, 150, 0.35);
}

@media print {
    body.docgen-preview-open > *:not(#docgenPreviewOverlay) {
        display: none !important;
    }

    body.docgen-preview-open {
        overflow: visible;
    }

    .docgen-preview-overlay {
        position: static;
        background: #fff;
        backdrop-filter: none;
    }

    .docgen-preview-overlay__header {
        display: none !important;
    }

    .docgen-preview-overlay__scroll {
        padding: 0;
        overflow: visible;
    }

    .docgen-preview-overlay__sheet {
        width: auto;
        max-width: none;
        margin: 0;
        page-break-after: always;
    }

    .docgen-preview-overlay__sheet .docgen-preview-page {
        box-shadow: none;
        border: 0;
        border-radius: 0;
    }
}
