* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: #eef2f6;
    color: #16202f;
    font: 13px/1.4 Arial, sans-serif;
}

body {
    min-height: 100vh;
}

code, pre, textarea {
    font-family: Consolas, "Courier New", monospace;
}

.cb-page {
    max-width: 1820px;
    margin: 0 auto;
    padding: 14px;
}

.cb-header {
    margin-bottom: 12px;
}

.cb-header h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.cb-subtitle {
    color: #617086;
    max-width: 1100px;
    font-size: 13px;
}

.cb-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cb-panel {
    background: #fff;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.cb-panel h2 {
    margin: 0 0 10px;
    font-size: 16px;
}

.cb-section-title {
    margin: 0 0 8px;
    font-size: 13px;
    color: #324156;
}

.cb-panel__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.cb-grid {
    display: grid;
    gap: 10px;
}

.cb-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cb-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cb-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cb-field label {
    font-weight: 700;
    font-size: 12px;
}

.cb-field select,
.cb-field input,
.cb-field textarea,
.cb-block__title,
.cb-block__content {
    width: 100%;
    border: 1px solid #c9d3df;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    color: #182332;
    font: inherit;
}

.cb-field textarea {
    min-height: 110px;
    resize: vertical;
}

.cb-readonly {
    min-height: 36px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid #c9d3df;
    border-radius: 8px;
    background: #f7f9fc;
    color: #506078;
    word-break: break-all;
}

.cb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.cb-actions--compact {
    margin-top: 0;
}

.cb-btn {
    border: 1px solid #bcc7d4;
    background: #fff;
    color: #182235;
    border-radius: 8px;
    padding: 7px 11px;
    cursor: pointer;
    font: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.cb-btn:hover {
    background: #f2f5f9;
}

.cb-btn:active {
    transform: translateY(1px);
}

.cb-btn--primary {
    background: #203554;
    color: #fff;
    border-color: #203554;
}

.cb-btn--primary:hover {
    background: #182b46;
}

.cb-btn--small {
    padding: 5px 9px;
    font-size: 12px;
}

.cb-layout {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 12px;
}

.cb-sidebar,
.cb-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cb-meta {
    margin-bottom: 10px;
    color: #5a6980;
    font-size: 12px;
}

.cb-placeholder {
    color: #5a6980;
    font-size: 12px;
}

.cb-error {
    margin-bottom: 10px;
    color: #a62121;
    font-weight: 700;
}

.cb-file-picker-panel {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #dbe3ed;
    border-radius: 8px;
    background: #f7faff;
}

.cb-tree-wrap {
    max-height: 720px;
    overflow: auto;
    border: 1px solid #dfe6ef;
    border-radius: 8px;
    padding: 10px;
    background: #fbfcfe;
}

.cb-tree {
    list-style: none;
    margin: 0;
    padding-left: 16px;
}

.cb-tree--root {
    padding-left: 0;
}

.cb-tree__row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    flex-wrap: wrap;
}

.cb-tree__toggle {
    width: 20px;
    min-width: 20px;
    height: 20px;
    border: 1px solid #d1d9e4;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 11px;
}

.cb-tree__toggle:hover {
    background: #f3f6fb;
}

.cb-tree__toggle--empty {
    display: inline-block;
    border-color: transparent;
    background: transparent;
    cursor: default;
}

.cb-tree__icon {
    width: 16px;
    text-align: center;
    font-size: 12px;
}

.cb-tree__name {
    font-weight: 600;
    font-size: 12px;
}

.cb-tree__meta {
    color: #728097;
    font-size: 11px;
    word-break: break-all;
}

.cb-file-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #ecf3ff;
    color: #22498d;
    font-size: 11px;
    font-weight: 700;
}

.cb-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.2;
}

.cb-badge--muted {
    background: #eef2f7;
    color: #5d697b;
}

.cb-badge--root {
    background: #edf5ff;
    color: #234a91;
}

.cb-db-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 10px;
}

.cb-db-column {
    min-width: 0;
}

.cb-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #dfe6ef;
    border-radius: 8px;
    padding: 10px;
    background: #fbfcfe;
}

.cb-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.cb-debug-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: #304056;
}

.cb-debug-item {
    padding: 7px 9px;
    border-radius: 7px;
    background: #f7f9fc;
    border: 1px solid #e5ebf4;
    word-break: break-word;
}

.cb-block {
    border: 1px solid #dce4ef;
    border-radius: 8px;
    padding: 10px;
    background: #fbfcff;
    margin-bottom: 10px;
}

.cb-block__row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.cb-block__title {
    flex: 1 1 auto;
}

.cb-block__content {
    min-height: 90px;
    resize: vertical;
}

.cb-pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: #101723;
    color: #e7edf8;
    border-radius: 8px;
    padding: 12px;
    max-height: 420px;
    overflow: auto;
    font-size: 12px;
}

.cb-pre--context {
    max-height: 760px;
}

.cb-toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cb-toast {
    min-width: 220px;
    max-width: 340px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 12px;
}

.cb-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.cb-toast--info {
    background: #325a9b;
}

.cb-toast--success {
    background: #26714f;
}

.cb-toast--error {
    background: #a73434;
}

@media (max-width: 1280px) {
    .cb-layout {
        grid-template-columns: 1fr;
    }

    .cb-grid--2,
    .cb-grid--3,
    .cb-db-layout {
        grid-template-columns: 1fr;
    }
}