.contract-document-editor {
    --contract-editor-border: #d9e2ea;
    --contract-editor-toolbar-bg: #f6f9fb;
    --contract-editor-page-bg: #f3f6f8;
    --contract-editor-ink: #172033;
    --contract-editor-muted: #64748b;
}

.contract-document-editor__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem;
    border: 1px solid var(--contract-editor-border);
    border-radius: 0.75rem 0.75rem 0 0;
    background: var(--contract-editor-toolbar-bg);
}

.contract-document-editor__toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem;
    border-right: 1px solid var(--contract-editor-border);
}

.contract-document-editor__toolbar-group:last-child {
    border-right: 0;
}

.contract-document-editor__select {
    width: auto;
    min-width: 8.5rem;
}

.contract-document-editor__toolbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0.25rem;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--contract-editor-ink);
}

.contract-document-editor__toolbar-button:hover,
.contract-document-editor__toolbar-button:focus {
    border-color: #b8dbe7;
    background: #eaf6fa;
    color: #1E789A;
}

.contract-document-editor__toolbar-button--text {
    width: auto;
    min-width: 3.5rem;
    padding-inline: 0.65rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.contract-document-editor__asset-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(13, 23, 51, 0.42);
}

.contract-document-editor__asset-dialog {
    width: min(100%, 58rem);
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

.contract-document-editor__asset-picker {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.contract-document-editor__asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.85rem;
}

.contract-document-editor__asset-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: stretch;
    width: 100%;
    padding: 0.7rem;
    border: 1px solid #dfe8f2;
    border-radius: 0.85rem;
    background: #ffffff;
    text-align: left;
}

.contract-document-editor__asset-card:hover,
.contract-document-editor__asset-card:focus {
    border-color: #2ba3c5;
    box-shadow: 0 10px 22px rgba(43, 163, 197, 0.16);
}

.contract-document-editor__asset-preview {
    width: 100%;
    height: 7rem;
    object-fit: contain;
    border-radius: 0.6rem;
    background: #f5f9fd;
}

.contract-document-editor__asset-title {
    color: #0d1733;
    font-size: 0.86rem;
    font-weight: 700;
    word-break: break-word;
}

.contract-document-editor__asset-meta {
    color: #6a7894;
    font-size: 0.76rem;
}

.contract-document-editor__asset-image {
    display: block;
    max-width: 100%;
    min-height: 3rem;
    margin: 0.75rem 0;
    padding: 1.25rem;
    border: 1px dashed #8bc5d8;
    border-radius: 0.75rem;
    background: #f3fbfd;
}

.contract-document-editor__asset-image::after {
    content: "Contract image asset " attr(data-corvue-asset-id);
    color: #1e789a;
    font-family: var(--bs-font-sans-serif, Arial, sans-serif);
    font-size: 0.85rem;
    font-weight: 700;
}

.contract-document-editor__page-shell {
    overflow-x: auto;
    padding: 1.5rem;
    border: 1px solid var(--contract-editor-border);
    border-top: 0;
    border-radius: 0 0 0.75rem 0.75rem;
    background: var(--contract-editor-page-bg);
}

.contract-document-editor__surface {
    max-width: 794px;
    min-height: 560px;
    margin: 0 auto;
    padding: 3rem 3.25rem;
    border: 1px solid #d7dee8;
    border-radius: 0.35rem;
    background: #fff;
    box-shadow: 0 1rem 2.25rem rgba(13, 23, 51, 0.11);
}

.contract-document-editor__prosemirror {
    min-height: 460px;
    outline: none;
    color: var(--contract-editor-ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    line-height: 1.55;
}

.contract-document-editor__prosemirror p {
    margin: 0 0 0.85rem;
}

.contract-document-editor__prosemirror h1,
.contract-document-editor__prosemirror h2,
.contract-document-editor__prosemirror h3 {
    margin: 1.5rem 0 0.75rem;
    color: #0D1733;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.2;
}

.contract-document-editor__prosemirror h1:first-child,
.contract-document-editor__prosemirror h2:first-child,
.contract-document-editor__prosemirror h3:first-child {
    margin-top: 0;
}

.contract-document-editor__prosemirror h1 {
    font-size: 1.65rem;
}

.contract-document-editor__prosemirror h2 {
    font-size: 1.35rem;
}

.contract-document-editor__prosemirror h3 {
    font-size: 1.1rem;
}

.contract-document-editor__prosemirror table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    table-layout: fixed;
}

.contract-document-editor__prosemirror th,
.contract-document-editor__prosemirror td {
    min-width: 1em;
    padding: 0.5rem 0.65rem;
    border: 1px solid #9fb2c4;
    vertical-align: top;
}

.contract-document-editor__prosemirror th {
    background: #edf6f9;
    font-weight: 700;
}

.contract-document-editor__prosemirror .selectedCell::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: rgba(43, 163, 197, 0.18);
}

.contract-document-editor__prosemirror .column-resize-handle {
    position: absolute;
    top: 0;
    right: -2px;
    bottom: -2px;
    width: 4px;
    background: #2BA3C5;
    pointer-events: none;
}

.contract-document-editor__prosemirror hr.page-break {
    height: 0;
    margin: 2rem 0;
    border: 0;
    border-top: 2px dashed #68B0A8;
}

.contract-document-editor__prosemirror hr.page-break::after {
    content: "Page break";
    display: inline-block;
    margin-top: -0.8rem;
    padding: 0 0.5rem;
    background: #fff;
    color: var(--contract-editor-muted);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 0.75rem;
}

.contract-document-editor__prosemirror .is-empty::before {
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
    color: #94a3b8;
}

.contract-document-editor__contract-block {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border: 1px solid #9fd2e0;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #eef9fc, #f8fff0);
    color: #0D1733;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-weight: 700;
    cursor: pointer;
}

.contract-document-editor__contract-block-title,
.contract-document-editor__contract-block-meta,
.contract-document-editor__contract-block-warning {
    display: block;
}

.contract-document-editor__contract-block-meta {
    margin-top: 0.15rem;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
}

.contract-document-editor__contract-block-warning {
    margin-top: 0.35rem;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 700;
}

.contract-document-editor__contract-block--warning {
    border-color: #f59e0b;
    background: #fff7ed;
}

.contract-document-editor__contract-block::before {
    content: "Dynamic pricing block";
    display: block;
    margin-bottom: 0.25rem;
    color: #1E789A;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.contract-document-editor__contract-block.ProseMirror-selectednode {
    outline: 3px solid rgba(43, 163, 197, 0.35);
}

.contract-document-editor__selected-block,
.contract-document-editor__selected-block-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--contract-editor-border);
    border-top: 0;
    background: #fff;
}

.contract-document-editor__selected-block-form {
    display: block;
    background: #f8fafc;
}

.contract-document-editor__selected-block-options,
.contract-dynamic-block-picker__presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

.contract-document-editor__selected-block-options .form-check {
    min-width: 11rem;
}

.contract-dynamic-block-picker__menu {
    min-width: 21rem;
}

.contract-dynamic-block-picker__options {
    display: grid;
    gap: 0.25rem;
}

.contract-block-picker__preview {
    overflow: hidden;
    color: #64748b;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contract-dynamic-block {
    margin: 1rem 0;
}

.contract-dynamic-block__pricing-table,
.contract-dynamic-block__summary-table {
    width: 100%;
    border-collapse: collapse;
}

.contract-dynamic-block__pricing-table th,
.contract-dynamic-block__pricing-table td,
.contract-dynamic-block__summary-table th,
.contract-dynamic-block__summary-table td {
    padding: 0.45rem 0.6rem;
    border: 1px solid #d5e1ea;
}

.contract-dynamic-block__pricing-section-row,
.contract-dynamic-block__grand-total,
.contract-dynamic-block__section-total {
    background: #f6f9fb;
}

.contract-dynamic-block--total,
.contract-dynamic-block--unavailable {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #d5e1ea;
    border-radius: 0.65rem;
    background: #f6f9fb;
}

.contract-dynamic-block--unavailable {
    color: #92400e;
    background: #fff7ed;
}

.contract-snippets-page__filter-primary {
    min-width: min(28rem, 100%);
    flex: 1 1 22rem;
}

.contract-snippets-page__filter-select {
    min-width: 12rem;
}

.contract-snippets-page__preview {
    max-height: 16rem;
    overflow: auto;
    padding: 1rem;
    border: 1px solid #d5e1ea;
    border-radius: 0.65rem;
    background: #fff;
}

.contract-snippets-page__preview table {
    width: 100%;
    border-collapse: collapse;
}

.contract-snippets-page__preview th,
.contract-snippets-page__preview td {
    padding: 0.4rem 0.55rem;
    border: 1px solid #d5e1ea;
}

.contract-snippets-page__backdrop {
    position: fixed;
    z-index: 1050;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 2rem 1rem;
    background: rgba(13, 23, 51, 0.55);
}

.contract-snippets-page__modal-shell {
    width: min(72rem, 100%);
}

.contract-document-editor__fallback {
    min-height: 340px;
    font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 767.98px) {
    .contract-document-editor__page-shell {
        padding: 0.75rem;
    }

    .contract-document-editor__surface {
        padding: 1.25rem;
    }
}
