:root {
    --bs-primary: #335fbe;
    --bs-primary-rgb: 51, 95, 190;
    --bs-warning: #9a6a24;
    --bs-warning-rgb: 154, 106, 36;
    --bs-info: #2d6f96;
    --bs-info-rgb: 45, 111, 150;
    --bs-success: #2f8a57;
    --bs-success-rgb: 47, 138, 87;
    --bs-danger: #b55656;
    --bs-danger-rgb: 181, 86, 86;
    --bs-secondary: #6a7688;
    --bs-secondary-rgb: 106, 118, 136;
}

.btn {
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: 0.38rem;
    --bs-btn-padding-y: 0.42rem;
    --bs-btn-padding-x: 0.78rem;
}

.btn-primary {
    --bs-btn-bg: #335fbe;
    --bs-btn-border-color: #335fbe;
    --bs-btn-hover-bg: #2d55aa;
    --bs-btn-hover-border-color: #2d55aa;
    --bs-btn-active-bg: #284b96;
    --bs-btn-active-border-color: #284b96;
}

.btn-outline-primary {
    --bs-btn-color: #335fbe;
    --bs-btn-border-color: #6f93d8;
    --bs-btn-hover-bg: #e9f0ff;
    --bs-btn-hover-border-color: #5f85cf;
    --bs-btn-hover-color: #2c4f9b;
}

.btn-outline-secondary {
    --bs-btn-color: #4f6178;
    --bs-btn-border-color: #c7d2e2;
    --bs-btn-hover-color: #34485f;
    --bs-btn-hover-bg: #edf2f9;
    --bs-btn-hover-border-color: #b7c6da;
}

.btn:disabled,
.btn.disabled,
fieldset:disabled .btn {
    opacity: 1;
    filter: none;
    box-shadow: none;
}

.btn-primary:disabled,
.btn-primary.disabled,
.btn-check:disabled + .btn-primary,
.btn-check[disabled] + .btn-primary {
    background-color: #8ea7d9;
    border-color: #8ea7d9;
    color: #f5f8ff;
}

.btn-outline-primary:disabled,
.btn-outline-primary.disabled,
.btn-check:disabled + .btn-outline-primary,
.btn-check[disabled] + .btn-outline-primary {
    color: #8ca0c8;
    border-color: #c6d3eb;
    background-color: #f6f9ff;
}

.btn-outline-secondary:disabled,
.btn-outline-secondary.disabled,
.btn-check:disabled + .btn-outline-secondary,
.btn-check[disabled] + .btn-outline-secondary {
    color: #97a3b6;
    border-color: #d5deeb;
    background-color: #f7f9fc;
}

.btn-outline-dark:disabled,
.btn-outline-dark.disabled,
.btn-check:disabled + .btn-outline-dark,
.btn-check[disabled] + .btn-outline-dark {
    color: #8e99aa;
    border-color: #c8d0dc;
    background-color: #f7f9fc;
}

.material-symbols-rounded {
    font-size: 0.95rem;
    line-height: 1;
    vertical-align: -0.08em;
}

.btn .material-symbols-rounded {
    font-size: 1rem;
    vertical-align: -0.06em;
}

.docgen-body {
    --docgen-bg: #eef2f8;
    --docgen-card: #ffffff;
    --docgen-border: #d8e0ec;
    --docgen-border-strong: #c7d3e4;
    --docgen-text: #132238;
    --docgen-muted: #5d6d83;
    --docgen-accent: #335fbe;
    --docgen-accent-soft: #e8efff;
    --docgen-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    height: 100vh;
    overflow: hidden;
}

.docgen-workspace {
    --bs-border-color: var(--docgen-border);
    height: 100vh;
    overflow: hidden;
}

.docgen-workspace > .d-flex {
    padding: 0 4px;
}

.docgen-topbar {
    padding: 0 2px;
}

.docgen-top-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.docgen-menu-item {
    appearance: none;
    border: 0;
    background: transparent;
    color: #33485f;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.1;
    border-radius: 0.56rem;
    padding: 0.42rem 0.62rem;
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.docgen-menu-item:hover {
    background: #ecf1fa;
    color: #23384f;
}

.docgen-menu-item:focus-visible {
    outline: 2px solid rgba(51, 95, 190, 0.35);
    outline-offset: 1px;
}

.docgen-menu-item .material-symbols-rounded {
    font-size: 1.03rem;
    vertical-align: -0.05em;
}

.docgen-menu-item-static {
    color: #526781;
    background: #f4f8ff;
    border: 1px solid #d6e0ef;
    cursor: default;
    padding: 0.4rem 0.55rem;
}

.docgen-menu-item-static:hover {
    background: #f4f8ff;
    color: #526781;
}

.docgen-layout {
    height: calc(100vh - 88px);
    overflow: hidden;
}

.doc-preview-card,
.doc-sidebar {
    border-radius: 16px;
    background: var(--docgen-card);
    border: 1px solid var(--docgen-border);
    box-shadow: var(--docgen-shadow);
}

.doc-preview-card {
    height: 100%;
    overflow: hidden;
}

.doc-sidebar {
    height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fd 100%);
}

.doc-preview-body,
.doc-sidebar-body {
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    scrollbar-width: thin;
}

.doc-preview-body {
    padding: 14px !important;
    background-color: var(--docgen-bg);
    background-image:
        linear-gradient(45deg, rgba(255, 255, 255, 0.54) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.54) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.54) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.54) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.doc-sidebar-body {
    padding: 20px;
}

.sidebar-empty-state {
    border: 1.5px dashed #c7d7f0;
    border-radius: 14px;
    padding: 28px 16px 24px;
    background: linear-gradient(160deg, #f8fbff 0%, #eef3fc 100%);
    text-align: center;
}

/* ── Pick-template CTA button ─────────────────────────────────────────── */
.docgen-empty-pick-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid #c7d7f0;
    border-radius: 14px;
    padding: 18px 28px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    color: var(--bs-primary);
}

.docgen-empty-pick-btn:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 4px 20px rgba(51,95,190,.14);
    background: #f0f5ff;
}

.docgen-empty-pick-icon {
    font-size: 40px;
    line-height: 1;
    color: var(--bs-primary);
    opacity: .85;
}

.docgen-empty-pick-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--bs-primary);
    letter-spacing: .02em;
    display: flex;
    align-items: center;
    gap: 3px;
}

.sidebar-tabs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    width: fit-content;
    border: 1px solid #d8e2ef;
    border-radius: 0.68rem;
    padding: 3px;
    background: #f5f8fd;
    margin-bottom: 12px;
}

.sidebar-tabs .nav-item {
    display: flex;
}

.sidebar-tabs .nav-link {
    border: 0;
    color: #607187;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.42rem 0.72rem;
    border-radius: 0.52rem;
    transition: color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
}

.sidebar-tabs .nav-link .material-symbols-rounded {
    font-size: 0.98rem;
    margin-right: 0.06rem;
    vertical-align: -0.04em;
}

.sidebar-tabs .nav-link.active {
    color: #173154;
    background: #ffffff;
    border: 1px solid #cfdced;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.09);
    font-weight: 700;
}

.sidebar-tabs .nav-link:not(.active):hover {
    color: #314a6a;
    background: #f2f6fd;
}

.sidebar-tab-content {
    padding-top: 2px;
}


.doc-preview-card .card-header {
    border-bottom: 1px solid var(--docgen-border);
    padding: 14px 16px !important;
    background: #fff;
}

.doc-preview-toolbar {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.doc-toolbar-btn {
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-padding-x: 0.68rem;
    --bs-btn-border-radius: 0.5rem;
    min-height: 2.12rem;
    font-size: 0.93rem;
}

.doc-toolbar-icon-btn {
    --bs-btn-padding-y: 0.3rem;
    --bs-btn-padding-x: 0.45rem;
    --bs-btn-border-radius: 0.45rem;
    min-height: 2rem;
    min-width: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.doc-toolbar-icon-btn .material-symbols-rounded {
    font-size: 1.15rem;
}
.doc-toolbar-icon-btn:disabled,
.doc-toolbar-icon-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.doc-toolbar-sep {
    display: inline-block;
    width: 1px;
    height: 1.4rem;
    background: var(--bs-border-color);
    margin: 0 0.25rem;
}

.preview-empty-state {
    min-height: calc(100vh - 260px);
    border: 1px dashed var(--docgen-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 32px;
    background: #f5f8fd;
}

.preview-empty-state > .material-symbols-rounded,
.preview-empty-state .material-symbols-rounded.display-6 {
    font-size: 2rem;
    margin-right: 0;
    vertical-align: 0;
}

.preview-frame {
    display: block;
    width: 100%;
    min-height: calc(100vh - 282px);
    background: #fff;
    overflow: hidden;
}

.alert-loading {
    background: #edf7ff;
    color: #2a5873;
    border-color: #c8dff2;
}

.alert-success-soft {
    background: #edf8f1;
    color: #24543a;
    border-color: #c6e2cf;
}

.alert-error-soft {
    background: #fdf1f1;
    color: #7f2b2b;
    border-color: #f0cfcf;
}

.alert-info-soft {
    background: #edf3ff;
    color: #2b4578;
    border-color: #c9d9f3;
}

.chatbox-card {
    border: 1px solid var(--docgen-border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.chatbox-header {
    background: #0f172a;
    color: #e2e8f0;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
}

.chatbox-header .material-symbols-rounded {
    font-size: 1.06rem;
    margin-right: 0.24rem;
    vertical-align: -0.08em;
}

.chatbox-thread {
    background: #020617;
    min-height: 400px;
    max-height: 620px;
    overflow-y: auto;
    padding: 12px;
}

.chat-empty {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #93c5fd;
    font-size: 12px;
}

.chat-empty .material-symbols-rounded {
    font-size: 1.52rem;
    margin-right: 0;
    vertical-align: 0;
}

.chat-empty-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: #c7dcff;
    line-height: 1.3;
}

.chat-empty-desc {
    max-width: 560px;
    color: #8fb3e8;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-empty-hints {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.35rem;
}

.chat-empty-hints span {
    display: inline-flex;
    align-items: center;
    padding: 0.34rem 0.64rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.42);
    color: #9ec0ef;
    font-size: 0.78rem;
    line-height: 1.35;
}

.chat-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.chat-row-user {
    justify-content: flex-end;
}

.chat-row-ai {
    justify-content: flex-start;
}

.chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-bubble {
    position: relative;
    max-width: calc(100% - 52px);
    border-radius: 12px;
    padding: 8px 34px 8px 10px;
    border: 1px solid #1e293b;
}

.chat-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 6px;
    background: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.chat-copy-btn .material-symbols-rounded {
    margin-right: 0;
    font-size: 1rem;
    vertical-align: -0.06em;
}

.chat-row:hover .chat-copy-btn,
.chat-copy-btn:focus-visible {
    opacity: 1;
}

.chat-copy-btn:hover {
    background: rgba(148, 163, 184, 0.35);
}

.chat-bubble-user {
    background: linear-gradient(90deg, #2563eb 0%, #06b6d4 100%);
    color: #fff;
}

.chat-bubble-ai {
    background: #0b1220;
    color: #cbd5e1;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-bottom: 6px;
}

.chat-role {
    font-weight: 700;
}

.chat-time {
    opacity: 0.85;
}

.chat-text {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.4;
}

.chat-summary {
    margin-top: 8px;
    border-top: 1px dashed rgba(148, 163, 184, 0.35);
    padding-top: 6px;
    color: #93c5fd;
    font-size: 11px;
    line-height: 1.35;
}

.chat-status {
    font-size: 10px;
}

.chat-status-dots {
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
}

.chat-status-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #93c5fd;
    opacity: 0.35;
    animation: chatStatusDot 1s ease-in-out infinite;
}

.chat-status-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-status-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatStatusDot {
    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-1px);
    }
}

#runStatusBadge {
    transition: all 0.2s ease;
}

#runStatusBadge.status-running {
    background: #334155 !important;
    color: #e2e8f0;
    box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.45);
    animation: statusPulse 1.8s ease-in-out infinite;
}

#runStatusBadge.status-success {
    background: #166534 !important;
    color: #dcfce7;
}

#runStatusBadge.status-failed {
    background: #991b1b !important;
    color: #fee2e2;
}

.chat-row.is-running .chat-bubble-ai {
    border-color: rgba(125, 211, 252, 0.35);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.16), 0 0 0 0 rgba(56, 189, 248, 0.12);
    animation: aiBubblePulse 2.2s ease-in-out infinite;
}

.chat-row.is-running .chat-bubble-ai::before {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    top: 0;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.05) 0%, rgba(56, 189, 248, 0.9) 50%, rgba(56, 189, 248, 0.05) 100%);
    background-size: 200% 100%;
    animation: aiScan 1.4s linear infinite;
}

@keyframes statusPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.35);
        opacity: 0.95;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(125, 211, 252, 0);
        opacity: 1;
    }
}

@keyframes aiBubblePulse {
    0%,
    100% {
        box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.14), 0 0 0 0 rgba(56, 189, 248, 0.1);
    }
    50% {
        box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.24), 0 0 0 6px rgba(56, 189, 248, 0);
    }
}

@keyframes aiScan {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

.chatbox-input-wrap {
    position: relative;
    border-top: 1px solid #cfd9e8;
    padding: 0;
    background: #f4f7fd;
}

.chatbox-input-wrap .form-control {
    min-height: 92px;
    resize: vertical;
    border: 0;
    border-radius: 0!important;
    background: #ffffff;
    color: #1f2f45;
    font-size: 1rem;
    line-height: 1.45;
    padding: 0.82rem 1rem 0.88rem 1rem;
}

.chatbox-input-wrap .form-control::placeholder {
    color: #6b7280;
}

.chatbox-input-wrap .form-control:focus {
    border-top-color: #8ea8dc;
    box-shadow: inset 0 1px 0 #8ea8dc;
}

#aiSendBtn {
    position: absolute;
    right: 0.1rem;
    bottom: 0.1rem;
    width: 1.9rem;
    height: 1.9rem;
    min-height: 1.9rem;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    color: #335fbe;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

#aiSendBtn .material-symbols-rounded {
    margin-right: 0;
    font-size: 1.18rem;
    line-height: 1;
    vertical-align: 0;
}

#aiSendBtn:hover,
#aiSendBtn:focus-visible {
    color: #244fa9;
}

#aiSendBtn:active {
    color: #1f468f;
}

#aiSendBtn:disabled,
#aiSendBtn.disabled {
    background: transparent !important;
    color: #9aa9c7;
}

.chat-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7dd3fc;
    animation: chatPulse 1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatPulse {
    0%,
    80%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.console-header {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px 10px 0 0;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
}

.console-body {
    background: #020617;
    color: #cbd5e1;
    border-radius: 0 0 10px 10px;
    padding: 10px 12px;
    min-height: 140px;
    max-height: 220px;
    overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.45;
    border: 1px solid #1e293b;
    border-top: 0;
}

.console-line {
    margin-bottom: 6px;
    white-space: pre-wrap;
}

.console-line:last-child {
    margin-bottom: 0;
}

.console-ts {
    color: #94a3b8;
}

.console-level-info {
    color: #7dd3fc;
}

.console-level-error {
    color: #fca5a5;
}

.console-level-warn {
    color: #fcd34d;
}

.debug-summary {
    border: 1px solid #1e293b;
    border-top: 0;
    background: #0b1220;
    color: #cbd5e1;
    padding: 8px 10px;
}

.debug-summary-title {
    font-size: 12px;
    font-weight: 700;
    color: #93c5fd;
    margin-bottom: 4px;
}

.schema-form-container {
    height: calc(100vh - 410px)!important;
    max-height: none;
    overflow-y: auto;
}

.doc-sidebar .form-control,
.doc-sidebar .form-select,
.recent-doc-toolbar .form-control,
.recent-doc-toolbar .form-select {
    border-color: #d0dae8;
    border-radius: 0.52rem;
    font-size: 0.9rem;
    background-color: #fff;
}

.doc-sidebar .form-control:focus,
.doc-sidebar .form-select:focus,
.recent-doc-toolbar .form-control:focus,
.recent-doc-toolbar .form-select:focus {
    border-color: #9db3df;
    box-shadow: 0 0 0 0.16rem rgba(51, 95, 190, 0.13);
}

.recent-doc-modal .modal-content {
    border: 1px solid var(--docgen-border-strong);
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.recent-doc-modal .modal-header,
.recent-doc-modal .modal-footer {
    border-color: var(--docgen-border);
    background: #f8fbff;
}

.recent-doc-modal .modal-title {
    color: var(--docgen-text);
    font-weight: 700;
}

.recent-doc-toolbar .form-label {
    font-size: 0.76rem;
    color: var(--docgen-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.recent-doc-toolbar .form-control,
.recent-doc-toolbar .form-select {
    font-size: 0.86rem;
    min-height: 34px;
    border-color: var(--docgen-border);
}

.recent-doc-toolbar .form-control:focus,
.recent-doc-toolbar .form-select:focus {
    border-color: #9ab4e6;
    box-shadow: 0 0 0 0.16rem rgba(51, 95, 190, 0.14);
}

.recent-doc-table-wrap {
    border: 1px solid var(--docgen-border);
    border-radius: 10px;
    max-height: 440px;
    overflow: auto;
    background: #fff;
}

.recent-doc-table-wrap table {
    font-size: 0.9rem;
}

.recent-doc-table-wrap thead th {
    position: sticky;
    top: 0;
    background: #f3f7fe;
    z-index: 1;
    border-bottom: 1px solid var(--docgen-border);
    font-weight: 600;
    color: #32455f;
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.recent-doc-table-wrap td {
    border-color: #e5ebf4;
    vertical-align: top;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.recent-doc-table-wrap tbody tr:hover {
    background: #f8fbff;
}

.recent-doc-table-wrap .small {
    color: #6a7b90 !important;
    font-size: 0.78rem;
}

.recent-doc-state {
    border: 1px dashed var(--docgen-border);
    border-radius: 10px;
    background: #f7faff;
    padding: 9px 12px;
    margin-bottom: 10px;
    color: var(--docgen-muted);
    font-size: 0.85rem;
}

.recent-doc-modal .btn {
    --bs-btn-font-size: 0.82rem;
    --bs-btn-padding-y: 0.32rem;
    --bs-btn-padding-x: 0.62rem;
}

.recent-doc-modal .badge.text-bg-success {
    background: #e8f5ee !important;
    color: #1f4d35 !important;
    border: 1px solid #c8e2d3;
}

.recent-doc-modal .badge.text-bg-danger {
    background: #faecec !important;
    color: #6a2f2f !important;
    border: 1px solid #efcece;
}

.recent-doc-modal .badge.text-bg-secondary {
    background: #eef2f7 !important;
    color: #3f536d !important;
    border: 1px solid #d7dfeb;
}

.recent-doc-modal .badge.text-bg-light {
    background: #f5f7fb !important;
    color: #3f536d !important;
    border: 1px solid #d9e1ec !important;
}

.recent-doc-table-wrap .badge {
    font-weight: 600;
    font-size: 0.76rem;
    padding: 0.3rem 0.52rem;
    border-radius: 999px;
}

.schema-form-container .form-label {
    color: #334155;
}

.docgen-field-focus-pulse {
    border-radius: 8px;
    animation: docgenFieldPulse 1.4s ease;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.35);
}

@keyframes docgenFieldPulse {
    0% {
        background: rgba(59, 130, 246, 0.15);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.35);
    }
    60% {
        background: rgba(59, 130, 246, 0.06);
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
    100% {
        background: transparent;
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

@media (max-width: 991.98px) {
    .docgen-body,
    .docgen-workspace {
        height: auto;
        overflow: auto;
    }

    .docgen-layout {
        height: auto;
        overflow: visible;
    }

    .doc-preview-body,
    .doc-sidebar-body {
        height: auto;
        overflow: visible;
    }

    .preview-empty-state,
    .preview-frame {
        min-height: 420px;
    }

    .schema-form-container {
        height: auto;
        max-height: 420px;
    }

    .doc-sidebar {
        position: static !important;
        height: auto;
    }
}
.preview-empty-state:not(.d-none) ~ .preview-container {
    display: none;
}

/* ── Computed field control ── */
.docgen-computed-field {
    opacity: 0.72;
}

.docgen-computed-field input {
    background: #f1f5f9 !important;
    color: #64748b;
    cursor: default;
    font-variant-numeric: tabular-nums;
}

.docgen-computed-badge {
    font-size: 9px;
    font-weight: 500;
    padding: 2px 5px;
    background: #e0f2fe;
    color: #0369a1;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.docgen-computed-badge .material-symbols-rounded {
    font-size: 12px;
}

/* ── Completeness badge ── */
.docgen-completeness-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: default;
}

.docgen-comp-low {
    background: #fee2e2 !important;
    color: #b91c1c !important;
}

.docgen-comp-mid {
    background: #fef3c7 !important;
    color: #92400e !important;
}

.docgen-comp-high {
    background: #d1fae5 !important;
    color: #065f46 !important;
}

/* ── Validation results in chat ── */
.chat-validation {
    margin-top: 6px;
}

.docgen-validation-block {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.docgen-vr-item {
    font-size: 11px;
    line-height: 1.3;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 2px 0;
}

.docgen-vr-item .material-symbols-rounded {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.docgen-vr-pass {
    color: #6ee7b7;
}

.docgen-vr-error {
    color: #fca5a5;
}

.docgen-vr-warn {
    color: #fde68a;
}

/* ── Validation tab pane ─────────────────────────────────────────────── */
#validationResultsList .docgen-vr-item {
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    gap: 8px;
    margin-bottom: 6px;
}

#validationResultsList .docgen-vr-pass {
    color: #166534;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

#validationResultsList .docgen-vr-error {
    color: #991b1b;
    border-color: #fecaca;
    background: #fff1f2;
}

#validationResultsList .docgen-vr-warn {
    color: #92400e;
    border-color: #fde68a;
    background: #fffbeb;
}

#validationResultsList .docgen-vr-item .material-symbols-rounded {
    font-size: 18px;
}

/* ── Template modal ──────────────────────────────────────────────────── */
.docgen-template-modal-sidebar {
    background: #f8fafc;
}

.docgen-cat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: none;
    background: none;
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}

.docgen-cat-btn .material-symbols-rounded {
    font-size: 18px;
    flex-shrink: 0;
}

.docgen-cat-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.docgen-cat-btn.active {
    background: var(--bs-primary);
    color: #fff;
}

.docgen-template-card-col {
    display: flex;
}

.docgen-template-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    text-align: left;
    width: 100%;
    height: 100%;
}

.docgen-template-card:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 4px 16px rgba(51,95,190,.12);
    background: #f8faff;
}

.docgen-template-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--bs-primary);
}

.docgen-template-card-icon .material-symbols-rounded {
    font-size: 24px;
}

.docgen-template-card-body {
    flex: 1;
    min-width: 0;
}

.docgen-template-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    margin-bottom: 4px;
}

.docgen-template-card-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.docgen-template-card-meta {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ── Selected template bar ───────────────────────────────────────────── */
.docgen-selected-template-bar {
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* ── Sidebar tabs — show tabs when sidebarWorkArea is visible ────────── */
.sidebar-tabs {
    margin-bottom: 0;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-tab-content {
    overflow-y: auto;
    padding-top: 12px;
}

/* ── Validation tab results (light mode) ────────────────────────────── */
.docgen-validation-block {
    padding: 4px 0;
}

/* ── Pastel validation badges ────────────────────────────────────────── */
.docgen-badge-error {
    background: #f5d0d0;
    color: #7f1d1d;
}

.docgen-badge-warn {
    background: #e8d9a0;
    color: #422006;
}
