:root {
    --canvas: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #fafbfc;
    --ink: #202329;
    --ink-soft: #454a54;
    --muted: #777d88;
    --faint: #9ca1aa;
    --line: #e2e5ea;
    --line-strong: #d3d7de;
    --blue: #3678ff;
    --blue-dark: #245fd6;
    --blue-soft: #edf3ff;
    --green: #248865;
    --green-soft: #e9f7f1;
    --amber: #9b6b18;
    --amber-soft: #fff5dd;
    --red: #c6454f;
    --red-soft: #fff0f1;
    --lime: #c9f36a;
    --shadow: 0 14px 40px rgba(24, 31, 44, 0.07);
    --shadow-modal: 0 28px 90px rgba(20, 25, 36, 0.22);
    --radius: 16px;
    --radius-small: 10px;
    --workspace: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

:focus-visible {
    outline: 3px solid rgba(54, 120, 255, 0.34);
    outline-offset: 2px;
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 10px 14px; color: #fff; border-radius: 8px; background: var(--blue); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.wordmark {
    color: #17191d;
    font-size: 20px;
    font-weight: 820;
    letter-spacing: -0.055em;
}

.workspace-header {
    position: sticky;
    z-index: 50;
    top: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
}

.workspace-bar {
    width: min(calc(100% - 40px), var(--workspace));
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 0 auto;
}

.internal-badge {
    padding: 4px 7px;
    color: #6b7079;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7f8fa;
    font-size: 10px;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-nav { display: flex; align-self: stretch; align-items: stretch; gap: 28px; margin-left: 42px; }
.workspace-nav a { position: relative; display: flex; align-items: center; color: #666c76; font-size: 13px; font-weight: 650; }
.workspace-nav a:hover { color: var(--ink); }
.workspace-nav a.active { color: var(--ink); }
.workspace-nav a.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--blue); }

.workspace-user { display: flex; align-items: center; gap: 11px; margin-left: auto; }
.workspace-user > span { display: flex; flex-direction: column; align-items: flex-end; }
.workspace-user strong { font-size: 12px; }
.workspace-user small { color: var(--faint); font-size: 10px; }
.avatar-button { width: 34px; height: 34px; color: #31441b; border: 0; border-radius: 10px; background: var(--lime); font-size: 11px; font-weight: 820; }
.user-menu { position: relative; margin-left: auto; }
.user-menu summary { display: flex; align-items: center; gap: 11px; cursor: pointer; list-style: none; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-copy { display: flex; flex-direction: column; align-items: flex-end; }
.user-menu-copy strong { font-size: 12px; }
.user-menu-copy small { color: var(--faint); font-size: 10px; }
.user-menu .avatar-button { display: grid; place-items: center; }
.user-menu-dropdown { position: absolute; top: 100%; right: 0; z-index: 100; width: 220px; max-width: calc(100vw - 28px); padding-top: 10px; }
.user-menu-panel { padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.user-menu-panel a, .user-menu-panel button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; text-decoration: none; font: inherit; font-size: 13px; cursor: pointer; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--blue-soft, #edf2ff); }
.user-menu-panel .logout-form { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
@media (max-width: 760px) { .user-menu-copy { display: none; } }

.workspace-main { width: min(calc(100% - 40px), var(--workspace)); margin: 0 auto; padding: 48px 0 88px; }
.page-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.compact-page-title { margin-bottom: 22px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 820; letter-spacing: 0.11em; text-transform: uppercase; }
.page-title-row h1, .editor-title-row h1 { margin: 0; font-size: clamp(34px, 4vw, 46px); line-height: 1.06; letter-spacing: -0.055em; }
.page-title-row > div > p:last-child, .editor-title-row > div > p { max-width: 650px; margin: 11px 0 0; color: var(--muted); font-size: 14px; }

.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #fff;
    font-size: 12px;
    font-weight: 720;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: 0 8px 20px rgba(54, 120, 255, 0.2); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: var(--blue-dark); border-color: #cbd8f7; background: var(--blue-soft); }
.button-quiet { color: var(--ink-soft); border-color: var(--line); background: #fff; }
.button-danger { color: var(--red); border-color: #edc6ca; background: var(--red-soft); }
.button-danger:disabled { color: #a7aab0; border-color: var(--line); background: #f4f5f7; cursor: not-allowed; }
.button-small { min-height: 34px; padding: 0 12px; color: var(--ink-soft); border-color: var(--line); font-size: 11px; }
.button-full { width: 100%; }
.text-button, .back-button, .back-link { padding: 0; color: var(--blue-dark); border: 0; background: transparent; font-size: 12px; font-weight: 720; }
.back-button { margin-bottom: 24px; }
.back-link { display: inline-flex; margin-bottom: 22px; }

.compact-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.72); }
.compact-stats div { display: flex; align-items: baseline; gap: 9px; padding: 15px 18px; border-right: 1px solid var(--line); }
.compact-stats div:last-child { border-right: 0; }
.compact-stats strong { font-size: 21px; letter-spacing: -0.04em; }
.compact-stats span { color: var(--muted); font-size: 11px; }

.section-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-toolbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.segmented-control { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f0f2f5; }
.segmented-control button { min-height: 32px; padding: 0 12px; color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: 11px; font-weight: 700; }
.segmented-control button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 6px rgba(29, 35, 47, 0.08); }
.search-field input:not([type="checkbox"]):not([type="radio"]) { min-height: 36px; width: 220px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 12px; }

.route-list { display: flex; flex-direction: column; }
.route-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 176px; align-items: center; gap: 18px; padding: 18px; border-bottom: 1px solid var(--line); }
.route-row:last-child { border-bottom: 0; }
.route-row:hover { background: #fbfcfd; }
.route-main { min-width: 0; display: grid; grid-template-columns: minmax(210px, 0.75fr) minmax(430px, 1.25fr); align-items: center; gap: 25px; }
.route-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.route-title h2 { margin: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.route-title p { margin: 2px 0 0; color: var(--faint); font-size: 11px; }
.route-chain { min-width: 0; display: grid; grid-template-columns: auto minmax(110px, 1fr) auto auto minmax(130px, 1fr); align-items: center; gap: 9px; }
.chain-copy { min-width: 0; display: flex; flex-direction: column; }
.chain-copy small { color: var(--faint); font-size: 10px; }
.chain-copy strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chain-separator { padding: 4px 7px; color: var(--faint); border-radius: 999px; background: #f0f2f5; font-size: 10px; font-weight: 700; }
.route-result { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.route-result small { color: var(--faint); font-size: 10px; }
.route-actions { display: flex; justify-content: flex-end; gap: 7px; }
.routes-card > .connections-loading { min-height: 180px; display: flex; align-items: center; justify-content: center; }
.routes-card > .connections-loading.error { color: var(--red); }

.status-indicator { width: 8px; height: 8px; display: inline-block; flex: 0 0 8px; border-radius: 50%; background: #a6abb4; }
.status-indicator.success { background: #39aa7b; box-shadow: 0 0 0 4px rgba(57, 170, 123, 0.12); }
.status-indicator.warning { background: #e2a43d; box-shadow: 0 0 0 4px rgba(226, 164, 61, 0.12); }
.status-indicator.neutral { background: #9aa0aa; }
.status-badge { width: max-content; display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.status-badge.success { color: var(--green); background: var(--green-soft); }
.status-badge.warning { color: var(--amber); background: var(--amber-soft); }
.status-badge.error { color: var(--red); background: var(--red-soft); }
.status-badge.neutral { color: #6d727c; background: #eff1f4; }

.brand-icon { width: 34px; height: 34px; display: inline-flex; flex: 0 0 34px; align-items: center; justify-content: center; border-radius: 9px; }
.brand-icon img { width: 19px; height: 19px; display: block; }
.brand-icon.vk { background: #2f77ef; }
.brand-icon.vk img, .brand-icon.telegram img, .brand-icon.email img { filter: brightness(0) invert(1); }
.brand-icon.telegram { background: #229ed9; }
.brand-icon.email { background: #6f66d8; }
.brand-icon-large { width: 50px; height: 50px; flex-basis: 50px; border-radius: 14px; }
.brand-icon-large img { width: 27px; height: 27px; }
.brand-word { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0 8px; border-radius: 8px; font-size: 8px; font-style: normal; font-weight: 850; letter-spacing: -0.03em; }
.brand-word.amo { color: #113340; background: #d9f5ff; }
.brand-word.bitrix { color: #0f6f98; background: #dcf5ff; }
.brand-word-large { min-height: 50px; min-width: 62px; padding: 0 11px; border-radius: 14px; font-size: 11px; }

.page-hint { display: flex; align-items: center; gap: 16px; margin-top: 18px; padding: 15px 18px; border: 1px solid #d8e3fb; border-radius: 12px; background: #f3f7ff; }
.page-hint strong { font-size: 12px; white-space: nowrap; }
.page-hint p { margin: 0; color: #6c7380; font-size: 11px; }
.page-hint a { margin-left: auto; color: var(--blue-dark); font-size: 11px; font-weight: 720; white-space: nowrap; }

/* Connections */
.connections-layout { display: grid; grid-template-columns: 278px minmax(0, 1fr); align-items: start; gap: 16px; }
.connections-sidebar { position: sticky; top: 90px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.connection-group { margin-top: 22px; }
.connection-group-title { display: flex; align-items: center; justify-content: space-between; margin: 0 5px 7px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: 0.07em; text-transform: uppercase; }
.connection-group-title small { min-width: 20px; padding: 2px 6px; border-radius: 999px; background: #eff1f4; text-align: center; }
.connection-item { width: 100%; min-height: 58px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px; text-align: left; border: 1px solid transparent; border-radius: 11px; background: transparent; }
.connection-item:hover { background: #f7f8fa; }
.connection-item.active { border-color: #cbd8f7; background: var(--blue-soft); }
.connection-item > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.connection-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.connection-item small { overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.connection-item .brand-icon { width: 31px; height: 31px; flex-basis: 31px; }
.connection-item .brand-icon img { width: 17px; height: 17px; }
.connections-help { margin-top: 24px; padding: 13px; border-radius: 11px; background: #f6f7f9; }
.connections-help strong { font-size: 11px; }
.connections-help p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.connections-loading { margin-top: 16px; padding: 14px 8px; color: var(--muted); font-size: 11px; text-align: center; }
.connections-loading.error { color: var(--red); }
.connections-empty-state { min-height: 500px; margin: 20px; }

.connection-workspace { min-width: 0; }
.connection-detail { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.connection-detail-header { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.connection-heading { min-width: 0; display: flex; align-items: center; gap: 13px; }
.connection-heading > div { min-width: 0; display: grid; grid-template-columns: auto auto; align-items: center; gap: 2px 8px; }
.connection-heading p { grid-column: 1 / -1; margin: 0; color: var(--faint); font-size: 10px; }
.connection-heading h2 { margin: 0; overflow: hidden; font-size: 18px; letter-spacing: -0.03em; text-overflow: ellipsis; white-space: nowrap; }
.header-button-group { display: flex; align-items: center; gap: 7px; }

.sync-banner, .api-method-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 16px 20px 0; padding: 13px 15px; border: 1px solid #cddbf9; border-radius: 11px; background: #f2f6ff; }
.sync-banner strong, .api-method-banner strong { font-size: 12px; }
.sync-banner p, .api-method-banner p { margin: 2px 0 0; color: #707786; font-size: 10px; }
.warning-banner { border-color: #ead5aa; background: #fff8e9; }
.api-method-banner { border-color: #cde7dc; background: #f0faf6; }

.detail-tabs { display: flex; gap: 3px; margin-top: 14px; padding: 0 20px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.detail-tabs button { position: relative; min-height: 45px; display: flex; align-items: center; gap: 6px; padding: 0 11px; color: var(--muted); border: 0; background: transparent; font-size: 11px; font-weight: 720; white-space: nowrap; }
.detail-tabs button.active { color: var(--ink); }
.detail-tabs button.active::after { content: ""; position: absolute; right: 7px; bottom: -1px; left: 7px; height: 2px; background: var(--blue); }
.detail-tabs small { padding: 2px 5px; border-radius: 999px; background: #eff1f4; font-size: 9px; }
.amo-tabs { gap: 0; }
.amo-tabs button { padding-inline: 8px; }

.detail-panel { min-height: 420px; padding: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric-grid article { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.metric-grid span { display: block; color: var(--faint); font-size: 10px; }
.metric-grid strong { display: block; margin-top: 4px; overflow: hidden; font-size: 16px; letter-spacing: -0.03em; text-overflow: ellipsis; white-space: nowrap; }

.info-section { margin-top: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
.connection-name-form { margin: 16px 20px 0; }
.connection-name-form .form-actions { margin-top: 0; }
.responsibility-hint { color: var(--muted); font-size: 11px; line-height: 1.6; }
.responsibility-history { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.responsibility-history summary { cursor: pointer; color: var(--ink-soft); font-size: 12px; font-weight: 680; }
.responsibility-history[open] summary { margin-bottom: 12px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h3 { margin: 0; font-size: 13px; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.table-note { color: var(--faint); font-size: 10px; white-space: nowrap; }
.info-list { margin: 0; border-top: 1px solid var(--line); }
.info-list div { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.info-list dt { color: var(--muted); font-size: 11px; }
.info-list dd { margin: 0; font-size: 12px; font-weight: 620; overflow-wrap: anywhere; }
.resource-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.resource-section { min-width: 0; }
.resource-list { max-height: 330px; overflow-y: auto; border-top: 1px solid var(--line); }
.resource-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.resource-row > span { min-width: 0; display: flex; flex-direction: column; }
.resource-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.resource-row small { color: var(--faint); font-size: 9px; }
.resource-load-error { grid-column: 1 / -1; padding: 16px; color: var(--red); border: 1px solid #efd1d4; border-radius: 10px; background: var(--red-soft); font-size: 11px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; padding: 15px; border: 1px solid #efd1d4; border-radius: 10px; background: #fff8f8; }
.danger-zone strong { font-size: 11px; }
.danger-zone p { margin: 2px 0 0; color: #90747a; font-size: 10px; }

.data-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 610px; }
.data-table th { padding: 10px 12px; color: var(--faint); background: #f7f8fa; font-size: 10px; font-weight: 720; text-align: left; }
.data-table td { padding: 12px; border-top: 1px solid var(--line); font-size: 11px; }
.data-table td strong { font-size: 12px; }
.empty-panel { display: flex; min-height: 300px; flex-direction: column; align-items: flex-start; justify-content: center; padding: 40px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #fbfcfd; }
.empty-panel h3 { margin: 0; font-size: 15px; }
.empty-panel p { max-width: 510px; margin: 7px 0 16px; color: var(--muted); font-size: 11px; }
.fields-panel { padding: 5px 0; }
.field-catalog { display: flex; flex-wrap: wrap; gap: 8px; }
.field-catalog span { padding: 9px 11px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 9px; background: #fafbfc; font-size: 11px; }

/* Route editor */
.route-editor-page { width: min(calc(100% - 40px), 1400px); max-width: 1400px; min-width: 0; }
.route-editor-page form, .route-builder-panel, .route-builder-panel > *, .workflow, .workflow-step, .route-step-fields, .route-step-fields label, .source-filter, .source-condition-row, .source-condition-row label, .custom-mapping-section, .custom-mapping-row, .custom-mapping-row label, .editor-summary { min-width: 0; }
.route-editor-page > .connections-loading { min-height: 240px; display: flex; align-items: center; justify-content: center; }
.route-editor-page > .connections-loading.error { color: var(--red); }
.route-name-field { display: flex; flex-direction: column; gap: 6px; margin-top: 24px; }
.route-name-field > span { color: var(--ink-soft); font-size: 11px; font-weight: 680; }
.route-name-field input:not([type="checkbox"]):not([type="radio"]) { width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; font-size: 14px; font-weight: 650; }
.editor-title-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.editor-title-row .header-button-group { flex: 0 0 auto; }
.title-with-status { display: flex; align-items: center; gap: 11px; }
.editor-title-row h1 { font-size: 30px; }
.editor-tabs { display: flex; gap: 24px; margin-top: 28px; border-bottom: 1px solid var(--line); }
.editor-tabs button { position: relative; min-height: 45px; display: flex; align-items: center; gap: 6px; padding: 0; color: var(--muted); border: 0; background: transparent; font-size: 11px; font-weight: 720; }
.editor-tabs button.active { color: var(--ink); }
.editor-tabs button.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--blue); }
.editor-tabs small { padding: 2px 6px; border-radius: 999px; background: #eff1f4; font-size: 9px; }
.route-tab-panel { display: grid; grid-template-columns: minmax(0, 1fr) 260px; align-items: start; gap: 18px; padding-top: 24px; }
.route-tab-panel[data-route-tab-panel="journal"] { display: block; }
.workflow { display: flex; flex-direction: column; align-items: stretch; }
.workflow-step { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.workflow-step > header { display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.workflow-step > header > div { min-width: 0; }
.workflow-step > header p { margin: 0; color: var(--blue); font-size: 10px; font-weight: 760; text-transform: uppercase; }
.workflow-step > header h2 { margin: 1px 0 0; font-size: 14px; }
.workflow-step > header .button { margin-left: auto; }
.step-number { width: 27px; height: 27px; display: inline-flex; flex: 0 0 27px; align-items: center; justify-content: center; color: var(--blue-dark); border-radius: 8px; background: var(--blue-soft); font-size: 10px; font-weight: 820; }
.step-service { display: flex; align-items: center; gap: 10px; margin: 15px 17px 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.step-service > div { display: flex; min-width: 0; flex-direction: column; }
.step-service small { color: var(--faint); font-size: 10px; }
.step-service strong { font-size: 11px; }
.step-service .status-badge { margin-left: auto; }
.step-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 11px 17px 0; }
.step-summary div { padding: 10px; border-radius: 9px; background: #f5f7fa; }
.step-summary dt, .step-summary dd { margin: 0; }
.step-summary dt { color: var(--faint); font-size: 10px; }
.step-summary dd { margin-top: 2px; font-size: 11px; font-weight: 650; }
.available-output { margin: 13px 17px 15px; color: #68717f; font-size: 10px; }
.mapping-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 11px 17px 0; }
.mapping-preview div { min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.mapping-preview span { color: var(--faint); font-size: 10px; }
.mapping-preview strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.variable-chip { display: inline-flex; width: max-content; max-width: 100%; padding: 3px 6px; overflow: hidden; color: var(--blue-dark); border-radius: 6px; background: var(--blue-soft); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.workflow-line { position: relative; height: 52px; display: flex; align-items: center; justify-content: center; }
.workflow-line::before { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.workflow-line button { position: relative; z-index: 1; min-height: 30px; padding: 0 10px; color: var(--blue-dark); border: 1px solid #bed0f8; border-radius: 999px; background: #fff; font-size: 10px; font-weight: 720; }
.workflow-arrow { position: relative; z-index: 1; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--blue-dark); border: 1px solid #bed0f8; border-radius: 50%; background: #fff; font-size: 14px; }
.route-step-fields { margin: 15px 17px 16px; }
.route-step-fields input:not([type="checkbox"]):not([type="radio"]):disabled { color: #707681; background: #f4f5f7; }
.source-filter { margin: 0 17px 16px; padding: 14px; border: 1px solid #c8d7f7; border-radius: 11px; background: #f8faff; }
.source-filter-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.source-filter-heading > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.source-filter-heading strong { font-size: 12px; }
.source-filter-heading span { color: var(--muted); font-size: 10px; }
.filter-state { flex: 0 0 auto; padding: 5px 8px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: 9px; font-weight: 760; }
.filter-state.active { color: var(--blue-dark); border-color: #acc4fa; background: var(--blue-soft); }
.source-filter-settings { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 10px; margin-top: 13px; }
.source-filter-settings label { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.source-filter-settings label > span { color: var(--ink-soft); font-size: 10px; font-weight: 680; }
.source-filter-settings input:not([type="checkbox"]):not([type="radio"]), .source-filter-settings select { width: 100%; min-width: 0; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-size: 11px; }
.source-filter-settings small { color: var(--faint); font-size: 9px; }
.source-condition-list { display: grid; gap: 9px; margin-top: 13px; }
.source-condition-list:empty { display: none; }
.source-condition-row { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(130px, 0.8fr) minmax(160px, 1fr) auto; align-items: end; gap: 8px; padding-top: 10px; border-top: 1px solid #d9e3f8; }
.source-condition-row label { display: flex; flex-direction: column; gap: 5px; }
.source-condition-row label > span { color: var(--ink-soft); font-size: 9px; font-weight: 680; }
.source-condition-row input:not([type="checkbox"]):not([type="radio"]), .source-condition-row select { width: 100%; min-width: 0; min-height: 38px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-size: 10px; }
.source-filter-empty { margin-top: 12px; padding: 10px 11px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; background: #fff; font-size: 10px; }
.source-filter-add { margin-top: 11px; color: var(--blue-dark); border-color: #bed0f8; background: #fff; }
.template-field select[data-variable-picker], .variable-picker { min-height: 34px; color: var(--blue-dark); border-color: #c8d7f7; background: var(--blue-soft); font-size: 10px; font-weight: 680; }
.custom-mapping-section { margin: 3px 17px 16px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.custom-mapping-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.custom-mapping-heading > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.custom-mapping-heading strong { font-size: 11px; }
.custom-mapping-heading span { color: var(--faint); font-size: 9px; }
.custom-mapping-heading .button { flex: 0 0 auto; }
.custom-mapping-list { display: grid; gap: 9px; margin-top: 11px; }
.custom-mapping-list:empty { display: none; }
.custom-mapping-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.custom-mapping-row label { display: flex; flex-direction: column; gap: 5px; }
.custom-mapping-row label > span { color: var(--ink-soft); font-size: 10px; font-weight: 680; }
.custom-mapping-row input:not([type="checkbox"]):not([type="radio"]), .custom-mapping-row select { width: 100%; min-width: 0; max-width: 100%; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-size: 11px; }
.custom-mapping-remove { min-height: 32px; margin-bottom: 2px; padding: 0 9px; color: var(--red); border: 1px solid #efd1d4; border-radius: 8px; background: #fff; font-size: 9px; font-weight: 700; }
.custom-mapping-remove:hover { background: var(--red-soft); }
.optional-step { border-style: dashed; }
.route-draft-notice { flex-direction: column; margin: 14px 0; }
.route-draft-notice strong { font-size: 11px; }
.route-summary-actions { display: grid; gap: 9px; }
.route-builder-panel { width: 100%; max-width: 100%; padding-top: 18px; }
.editor-summary { position: sticky; top: 92px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.editor-summary h2 { margin: 0 0 13px; font-size: 13px; }
.editor-summary dl { margin: 0; }
.editor-summary dl div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.editor-summary dt { color: var(--muted); font-size: 10px; }
.editor-summary dd { margin: 0; font-size: 10px; font-weight: 700; text-align: right; }
.validation-success { display: flex; flex-direction: column; margin-top: 13px; padding: 11px; border-radius: 9px; background: var(--green-soft); }
.validation-success strong { color: var(--green); font-size: 11px; }
.validation-success span { margin-top: 2px; color: #658075; font-size: 10px; }

/* Scenario canvas */
.scenario-workspace { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #f8f9fb; box-shadow: var(--shadow); }
.scenario-stage-strip { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: #fff; }
.scenario-stage-strip > div { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 9px; padding: 13px 16px; color: var(--faint); }
.scenario-stage-strip > div + div { border-left: 1px solid var(--line); }
.scenario-stage-strip > div > span { grid-row: 1 / 3; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 10px; font-weight: 800; }
.scenario-stage-strip strong { align-self: end; font-size: 11px; }
.scenario-stage-strip small { margin-top: 1px; font-size: 9px; }
.scenario-stage-strip .active { color: var(--ink); background: var(--blue-soft); }
.scenario-stage-strip .active > span { color: #fff; border-color: var(--blue); background: var(--blue); }
.scenario-canvas { min-height: 660px; padding: 30px 24px 44px; overflow-x: auto; background: #f8f9fb; }
.scenario-node { position: relative; width: min(100%, 350px); min-height: 86px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 auto; padding: 14px 42px 14px 15px; color: var(--ink); text-align: left; border: 1px solid #d7dce5; border-radius: 13px; background: #fff; box-shadow: 0 6px 18px rgba(32, 39, 52, 0.07); }
.scenario-node:hover, .scenario-node:focus-visible { border-color: #aebfe8; box-shadow: 0 8px 22px rgba(40, 83, 182, 0.12); }
.scenario-node-kicker { color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.scenario-node strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }
.scenario-node small { max-width: 100%; overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.node-settings-label { position: absolute; top: 14px; right: 13px; color: var(--blue-dark); font-size: 9px; font-weight: 730; }
.source-node { border-color: #c9d6f4; }
.scenario-trunk { width: 1px; height: 22px; margin: 0 auto; border-left: 1px dashed #aeb9ca; }
.branching-tool { width: min(100%, 350px); min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin: 0 auto; padding: 11px 15px; color: var(--ink); text-align: left; border: 1px solid #b9caf3; border-radius: 13px; background: #f2f6ff; }
.branching-tool:hover { border-color: var(--blue); background: #eaf1ff; }
.branching-tool span { color: var(--blue); font-size: 9px; font-weight: 780; }
.branching-tool strong { font-size: 11px; }
.scenario-branches { position: relative; min-width: max-content; display: flex; align-items: flex-start; justify-content: center; gap: 18px; padding: 38px 4px 0; }
.scenario-branches::before { content: ""; position: absolute; top: 18px; left: calc(var(--branch-edge, 50%) / 2); right: calc(var(--branch-edge, 50%) / 2); border-top: 1px dashed #aeb9ca; }
.scenario-branch { position: relative; width: 260px; display: flex; flex: 0 0 260px; flex-direction: column; align-items: stretch; }
.scenario-branch::before { content: ""; position: absolute; top: -20px; left: 50%; height: 20px; border-left: 1px dashed #aeb9ca; }
.branch-header { position: relative; z-index: 1; min-height: 64px; padding: 11px 38px 10px 12px; border: 1px solid #d7dce5; border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(32, 39, 52, 0.05); }
.branch-header button { width: 100%; padding: 0; color: inherit; text-align: left; border: 0; background: transparent; }
.branch-header strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.branch-header small { display: block; margin-top: 5px; color: var(--blue-dark); font-size: 9px; }
.branch-remove { position: absolute; z-index: 2; top: 9px; right: 9px; width: 24px !important; height: 24px; color: var(--red) !important; text-align: center !important; border: 1px solid #efd1d4 !important; border-radius: 7px !important; background: #fff !important; }
.branch-flow-line { width: 1px; height: 15px; margin: 0 auto; border-left: 1px dashed #aeb9ca; }
.branch-node { width: 100%; min-height: 76px; padding-right: 38px; border-color: #bfe5df; }
.branch-node + .branch-flow-line { height: 14px; }
.add-branch-action { min-height: 40px; color: var(--blue-dark); border: 1px dashed #b9caf3; border-radius: 10px; background: #f6f8fd; font-size: 9px; font-weight: 730; }
.add-branch-action:hover { border-color: var(--blue); background: var(--blue-soft); }
.scenario-action-controls { display: flex; justify-content: flex-end; gap: 5px; margin-top: 6px; }
.scenario-action-controls .button { min-height: 28px; padding: 4px 8px; font-size: 8px; }
.scenario-summary dd { max-width: 125px; }
.block-settings-card { width: min(100%, 760px); }
.block-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; }
.block-settings-grid label, .condition-editor label { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.block-settings-grid label > span, .condition-editor label > span { color: var(--ink-soft); font-size: 10px; font-weight: 680; }
.block-settings-grid input:not([type="checkbox"]):not([type="radio"]), .block-settings-grid select, .block-settings-grid textarea, .condition-editor input:not([type="checkbox"]):not([type="radio"]), .condition-editor select { width: 100%; min-width: 0; min-height: 42px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: 11px; }
.block-settings-grid textarea { min-height: 110px; padding-top: 10px; resize: vertical; }
.block-settings-grid .full-field { grid-column: 1 / -1; }
.block-settings-grid select { cursor: pointer; }
.block-settings-grid .muted { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.block-settings-grid > .button { justify-self: start; max-width: 100%; }
.block-settings-card .modal-close { border-radius: 8px; }
.google-file-field { min-width: 0; }
.google-file-label { display: block; margin-bottom: 5px; color: var(--ink-soft); font-size: 10px; font-weight: 680; }
.google-file-trigger { min-height: 42px; padding: 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); font-size: 11px; cursor: pointer; overflow-wrap: anywhere; }
.google-file-picker[open] > .google-file-trigger { border-color: var(--blue); background: var(--blue-soft); }
.google-file-panel { margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.block-settings-grid .google-file-panel input[type="search"] { background: var(--canvas); border-color: transparent; }
.google-file-results { display: grid; max-height: 220px; margin-top: 8px; overflow-y: auto; overscroll-behavior: contain; }
.google-file-option { width: 100%; min-height: 38px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 11px; overflow-wrap: anywhere; }
.google-file-option:hover, .google-file-option[aria-pressed="true"] { color: var(--blue-dark); background: var(--blue-soft); }
.google-file-panel .muted:not(:empty) { padding: 10px; }
.google-file-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.block-settings-section { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.block-settings-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.block-settings-section-header strong { font-size: 11px; }
.condition-editor { display: grid; gap: 9px; }
.condition-editor-row { display: grid; grid-template-columns: minmax(170px, 1.2fr) minmax(125px, .8fr) minmax(145px, 1fr) auto; align-items: end; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.condition-editor-row .button { min-height: 38px; color: var(--red); }
.block-settings-empty { padding: 12px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 9px; background: #fafbfc; font-size: 10px; }
.variable-field { position: relative; z-index: 0; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.variable-field.is-open { z-index: 30; }
.variable-field-label { color: var(--ink-soft); font-size: 10px; font-weight: 680; }
.variable-token-editor { min-height: 52px; padding: 8px 11px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font-size: 11px; line-height: 30px; overflow-wrap: anywhere; cursor: text; transition: border-color 160ms ease, box-shadow 160ms ease; }
.variable-token-editor:hover { border-color: #b9c1cf; }
.variable-token-editor:focus { border-color: #8cabf7; outline: 0; box-shadow: 0 0 0 3px rgba(54, 112, 244, 0.12); }
.variable-token-editor:empty::before { color: var(--faint); content: attr(data-placeholder); pointer-events: none; }
.variable-token-editor-multiline { min-height: 104px; line-height: 1.55; white-space: pre-wrap; }
.variable-token-chip { max-width: calc(100% - 4px); min-height: 30px; display: inline-flex; align-items: center; gap: 5px; margin: 1px 4px 1px 0; padding: 3px 5px 3px 9px; color: #38404c; vertical-align: middle; border-radius: 9px; background: #eef0f3; font-size: 10px; line-height: 22px; white-space: nowrap; }
.variable-token-chip strong { max-width: 210px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; }
.variable-token-chip > span { max-width: 190px; padding: 0 6px; overflow: hidden; border-radius: 5px; background: #fff; text-overflow: ellipsis; }
.variable-token-remove { width: 22px; height: 22px; flex: 0 0 22px; padding: 0; color: #808896; border: 0; border-radius: 5px; background: transparent; font-size: 15px; line-height: 20px; }
.variable-token-remove:hover { color: var(--red); background: #fff; }
.variable-catalog { position: absolute; z-index: 50; top: calc(100% + 7px); left: 0; width: 100%; max-height: 360px; padding: 12px; overflow-y: auto; border: 1px solid #d8dde6; border-radius: 13px; background: #fff; box-shadow: 0 18px 50px rgba(24, 31, 43, 0.18); }
.variable-catalog-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 1px 3px 10px; border-bottom: 1px solid var(--line); }
.variable-catalog-heading strong { font-size: 13px; }
.variable-catalog-heading span { color: var(--faint); font-size: 9px; }
.block-settings-grid .variable-catalog-search, .custom-mapping-row .variable-catalog-search { min-height: 42px; margin: 10px 0; padding: 0 12px; border: 0; border-radius: 9px; background: #f3f4f6; font-size: 11px; }
.variable-catalog-groups { display: grid; gap: 4px; }
.variable-catalog-group { border-bottom: 1px solid var(--line); }
.variable-catalog-group:last-child { border-bottom: 0; }
.variable-catalog-group summary { padding: 10px 7px; cursor: pointer; }
.variable-group-copy { display: inline-flex; flex-direction: column; gap: 2px; margin-left: 4px; vertical-align: middle; }
.variable-catalog-group summary strong { font-size: 11px; }
.variable-catalog-group summary small { color: var(--faint); font-size: 9px; }
.variable-catalog-options { padding: 0 0 7px; }
.variable-catalog-option { width: 100%; min-height: 46px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 7px 9px; color: var(--ink); text-align: left; border: 0; border-top: 1px solid #f0f1f4; background: #fff; }
.variable-catalog-option:hover, .variable-catalog-option:focus-visible { background: var(--blue-soft); outline: 0; }
.variable-catalog-option strong { font-size: 10px; }
.variable-catalog-option small { color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.variable-catalog-empty { margin: 0; padding: 12px 7px; color: var(--faint); font-size: 10px; }
.custom-mapping-row > .variable-field { grid-column: 1 / -1; }


/* Journal */
.route-journal-panel { width: 100%; max-width: 100%; padding-top: 18px; }
.journal-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.journal-toolbar h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.journal-toolbar p { max-width: 520px; margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.journal-filters { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 8px; }
.journal-filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; }
.journal-filters input:not([type="checkbox"]):not([type="radio"]), .journal-filters select { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 11px; }
.journal-search input:not([type="checkbox"]):not([type="radio"]) { width: 190px; }
.journal-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.journal-summary > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-right: 1px solid var(--line); }
.journal-summary > div:last-child { border-right: 0; }
.journal-summary strong { font-size: 16px; }
.journal-summary span { color: var(--faint); font-size: 9px; }
.journal-table { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.journal-head, .journal-row { display: grid; grid-template-columns: 132px minmax(185px, 1.2fr) 125px minmax(170px, 1fr) 132px 72px; align-items: center; gap: 12px; }
.journal-head { padding: 10px 14px; color: var(--faint); background: #f7f8fa; font-size: 10px; }
.journal-run { border-top: 1px solid var(--line); }
.journal-run:first-of-type { border-top: 0; }
.journal-row { position: relative; width: 100%; min-height: 66px; padding: 11px 34px 11px 14px; color: var(--ink); text-align: left; border: 0; background: #fff; font-size: 11px; cursor: pointer; }
.journal-row:hover { background: #fbfcfd; }
.journal-row:focus-visible { z-index: 1; outline: 2px solid var(--blue); outline-offset: -2px; }
.journal-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.journal-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journal-row small { color: var(--faint); font-size: 10px; }
.journal-expand { position: absolute; top: 50%; right: 14px; color: var(--faint); transform: translateY(-50%); }
.journal-row[aria-expanded="true"] .journal-expand { transform: translateY(-50%) rotate(180deg); }
.journal-pagination { display: flex; justify-content: center; margin-top: 12px; }
.journal-loading { min-height: 110px; }
.journal-empty { margin: 0; }
.run-details { padding: 0 14px 12px 42px; background: #fbfcfd; }
.run-step { min-height: 54px; display: grid; grid-template-columns: auto minmax(180px, 1fr) minmax(180px, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.run-step > div { display: flex; flex-direction: column; }
.run-step strong { font-size: 11px; }
.run-step small { color: var(--faint); font-size: 10px; }
.run-step > span:nth-child(3) { font-size: 11px; }
.run-step > button { color: var(--blue-dark); border: 0; background: transparent; font-size: 10px; font-weight: 720; }
.journal-detail-card { width: min(100%, 820px); }
.journal-detail-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 18px 0; }
.journal-detail-meta > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfc; }
.journal-detail-meta span { color: var(--faint); font-size: 9px; }
.journal-detail-meta strong { overflow-wrap: anywhere; font-size: 11px; }
.journal-detail-section { margin-top: 18px; }
.journal-detail-section h3 { margin: 0 0 8px; font-size: 12px; }
.journal-detail-section dl { margin: 0; }
.journal-detail-section dl div { display: grid; grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.journal-detail-section dt { color: var(--faint); font-size: 10px; }
.journal-detail-section dd { margin: 0; overflow-wrap: anywhere; font-size: 10px; }
.journal-payload { max-height: 330px; margin: 0; padding: 13px; overflow: auto; color: #dce7ff; border-radius: 9px; background: #1e2530; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Global lead journal */
.workspace-main.global-journal-page { width: min(calc(100% - 40px), 1380px); }
.global-journal-filters { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.global-journal-filters > label, .global-journal-filter { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 10px; }
.global-journal-filters input:not([type="checkbox"]):not([type="radio"]), .global-journal-filters select { min-width: 0; min-height: 40px; width: 100%; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 11px; }
.status-filter { position: relative; }
.global-filter-heading { min-height: 14px; display: flex; align-items: center; gap: 6px; }
.filter-info-button { width: 15px; height: 15px; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--blue-dark); border: 1px solid #aac2f7; border-radius: 50%; background: #eef4ff; font: 700 9px/1 Georgia, serif; cursor: pointer; }
.filter-info-button:hover, .filter-info-button[aria-expanded="true"] { color: #fff; border-color: var(--blue); background: var(--blue); }
.filter-info-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.status-help-popover { position: absolute; z-index: 30; top: calc(100% + 7px); left: 0; width: min(390px, calc(100vw - 56px)); padding: 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow-modal); }
.status-help-popover > strong { display: block; margin-bottom: 8px; font-size: 12px; }
.status-help-popover dl { margin: 0; }
.status-help-popover dl div { display: grid; grid-template-columns: 125px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.status-help-popover dt { color: var(--ink); font-weight: 720; }
.status-help-popover dd { margin: 0; color: var(--muted); line-height: 1.4; }
.global-journal-search { grid-column: span 2; }
.global-journal-filter-actions { display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; }
.global-journal-summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.global-journal-card { min-height: 240px; overflow: hidden; }
.global-journal-card > .journal-loading { min-height: 238px; display: flex; align-items: center; justify-content: center; }
.global-journal-error { margin: 18px; }
.global-journal-table { overflow-x: auto; }
.global-journal-head, .global-journal-row { min-width: 1120px; display: grid; grid-template-columns: 145px minmax(190px, 1fr) minmax(200px, 1.1fr) minmax(190px, 1fr) 145px minmax(190px, 1fr); align-items: center; gap: 14px; }
.global-journal-head { padding: 11px 16px; color: var(--faint); background: #f7f8fa; font-size: 10px; }
.global-journal-row { width: 100%; min-height: 76px; padding: 12px 16px; color: var(--ink); text-align: left; border: 0; border-top: 1px solid var(--line); background: #fff; font-size: 11px; cursor: pointer; }
.global-journal-row:hover { background: #fbfcfd; }
.global-journal-row:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--blue); outline-offset: -2px; }
.global-journal-timeline { border-top: 1px solid var(--line); }
.global-journal-step { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.global-journal-step > div { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.global-journal-step strong { font-size: 11px; }
.global-journal-step small, .muted-copy { color: var(--faint); font-size: 10px; }
.external-response-section { padding-top: 4px; }
.external-response-card { margin-top: 10px; padding: 13px; border: 1px solid #efc4c4; border-radius: 11px; background: #fff8f8; }
.external-response-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.external-response-heading strong { font-size: 12px; }
.external-response-card .journal-detail-section { margin-top: 8px; }
.external-response-card .journal-detail-section > h3 { display: none; }
.manual-routing-section { padding: 15px; border: 1px solid #b9caf2; border-radius: 11px; background: var(--blue-soft); }
.manual-routing-copy { margin: -2px 0 12px; line-height: 1.5; }
.manual-routing-field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 10px; }
.manual-routing-field select { width: 100%; min-height: 42px; padding: 0 11px; color: var(--ink); border: 1px solid #b9caf2; border-radius: 9px; background: #fff; font-size: 11px; }
.manual-routing-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.manual-routing-message { flex: 1; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.manual-routing-message.success { color: var(--green); }
.manual-routing-message.error { color: var(--red); }
.manual-routing-empty { margin: 10px 0 0; padding: 10px 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 10px; line-height: 1.5; }

/* Forms and modal */
.modal { position: fixed; z-index: 200; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(25, 29, 37, 0.55); backdrop-filter: blur(3px); }
.modal-card { position: relative; z-index: 1; width: min(100%, 610px); max-height: min(820px, calc(100vh - 48px)); padding: 28px; overflow-y: auto; border: 1px solid rgba(255, 255, 255, 0.72); border-radius: 18px; background: #fff; box-shadow: var(--shadow-modal); }
.connection-modal-card { width: min(100%, 640px); }
.step-modal-card { width: min(100%, 720px); }
.details-modal-card { width: min(100%, 560px); }
.action-modal-card { width: min(100%, 500px); }
.modal-close { position: absolute; top: 18px; right: 20px; padding: 5px 7px; color: var(--muted); border: 0; background: transparent; font-size: 11px; font-weight: 700; }
.modal-card h2 { margin: 0; font-size: 23px; letter-spacing: -0.04em; }
.modal-lead { margin: 7px 0 21px; color: var(--muted); font-size: 11px; }
.service-catalog { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.service-catalog > button, .action-catalog > button { min-height: 70px; display: flex; align-items: center; gap: 11px; padding: 11px; text-align: left; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.service-catalog > button:hover, .action-catalog > button:hover { border-color: #b9caf2; background: var(--blue-soft); }
.service-catalog > button > span:last-child, .action-catalog > button > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.service-catalog strong, .action-catalog strong { font-size: 12px; }
.service-catalog small, .action-catalog small { color: var(--faint); font-size: 10px; }
.action-catalog { display: grid; gap: 9px; margin-top: 20px; }
.stack-form, .mapping-editor { display: grid; gap: 13px; }
.api-form { grid-template-columns: 1fr 1fr; }
.api-form > label:first-child, .api-form .inline-notice, .api-form .form-actions { grid-column: 1 / -1; }
.stack-form label, .mapping-editor label { display: flex; flex-direction: column; gap: 5px; }
.stack-form label > span, .mapping-editor label > span { color: var(--ink-soft); font-size: 11px; font-weight: 680; }
.mapping-editor label > span b { color: var(--red); font-size: 7px; font-weight: 700; }
.stack-form input:not([type="checkbox"]):not([type="radio"]), .stack-form select, .mapping-editor input:not([type="checkbox"]):not([type="radio"]), .mapping-editor select, .mapping-editor textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: 12px; }
.stack-form input:not([type="checkbox"]):not([type="radio"]):disabled { color: #858a93; background: #f4f5f7; }

/* Shared checkbox component. Keep checkbox/radio out of text-input sizing rules.
   The :has fallback also protects newly added plain checkbox labels. */
label.checkbox-field, label:has(> input[type="checkbox"]) { display: flex; min-width: 0; min-height: 44px; flex-direction: row; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--ink-soft); font-size: 11px; cursor: pointer; }
input[type="checkbox"] { appearance: auto; flex: 0 0 18px; width: 18px; max-width: 18px; height: 18px; min-height: 18px; margin: 1px 0 0; padding: 0; accent-color: var(--blue); cursor: pointer; }
.checkbox-copy { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.checkbox-copy strong { color: var(--ink-soft); font-size: 11px; font-weight: 680; line-height: 1.5; }
.checkbox-copy small { color: var(--muted); font-size: 10px; font-weight: 400; line-height: 1.6; }
input[type="checkbox"]:disabled { cursor: not-allowed; }
label.checkbox-field:has(> input:disabled) { opacity: .65; cursor: not-allowed; }
.mapping-editor { grid-template-columns: 1fr 1fr; margin-top: 20px; }
.mapping-editor textarea { padding-top: 10px; resize: vertical; }
.full-field { grid-column: 1 / -1; }
.inline-notice { display: flex; gap: 9px; padding: 11px; color: #6e6248; border: 1px solid #ead9af; border-radius: 9px; background: #fff8e9; font-size: 10px; }
.form-error { margin: 0; padding: 10px 11px; color: var(--red); border: 1px solid #efd1d4; border-radius: 9px; background: var(--red-soft); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 20px; }
.step-modal-card > .form-actions { padding-top: 17px; border-top: 1px solid var(--line); }
.payload-preview { margin: 18px 0 0; padding: 15px; overflow-x: auto; color: #dce7ff; border-radius: 10px; background: #1e2530; font: 10px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }
.prototype-note { margin: 15px 0 0; color: var(--faint); font-size: 10px; text-align: center; }
.toast { position: fixed; z-index: 300; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 15px; color: #fff; border-radius: 10px; background: #252a33; box-shadow: var(--shadow-modal); font-size: 12px; font-weight: 650; }

/* Auth */
.auth-page { min-height: 100vh; background: #eef1f5; }
.auth-layout { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px 20px; }
.auth-wordmark { margin-bottom: 24px; }
.auth-card { width: min(100%, 410px); padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow-modal); }
.auth-caption { margin-bottom: 10px; color: var(--blue); font-size: 10px; font-weight: 820; letter-spacing: 0.1em; text-transform: uppercase; }
.auth-card h1 { margin: 0; font-size: 25px; letter-spacing: -0.045em; }
.auth-card > p { margin: 8px 0 22px; color: var(--muted); font-size: 12px; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; }
.auth-form label span { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.auth-form input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; }
.auth-form .button { margin-top: 5px; }
.auth-error { min-height: 1.4em; margin: 0; color: var(--red); font-size: 0.88rem; }
.logout-form { margin: 0; }
.auth-card .prototype-note { margin-bottom: 0; }
.auth-footer { margin: 18px 0 0; color: #8b9099; font-size: 10px; }

@media (max-width: 1020px) {
    .route-row { grid-template-columns: minmax(0, 1fr) 140px; }
    .route-row > .button { grid-column: 2; }
    .route-main { grid-row: span 2; grid-template-columns: 1fr; gap: 10px; }
    .connections-layout { grid-template-columns: 245px minmax(0, 1fr); }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .resource-grid { grid-template-columns: 1fr; }
    .amo-tabs button { padding-inline: 7px; }
    .route-tab-panel { grid-template-columns: minmax(0, 1fr) minmax(200px, 230px); }
    .journal-toolbar { flex-direction: column; }
    .journal-filters { justify-content: flex-start; }
    .global-journal-filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 820px) {
    .workspace-bar { min-height: 60px; flex-wrap: wrap; padding-top: 10px; }
    .workspace-nav { order: 3; width: 100%; min-height: 40px; margin-left: 0; gap: 18px; overflow-x: auto; }
    .workspace-user > span, .internal-badge { display: none; }
    .workspace-main { padding-top: 34px; }
    .compact-stats { grid-template-columns: 1fr 1fr; }
    .compact-stats div:nth-child(2) { border-right: 0; }
    .compact-stats div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
    .route-row { grid-template-columns: 1fr auto; }
    .route-main { grid-column: 1 / -1; grid-row: auto; }
    .route-result { flex-direction: row; align-items: center; }
    .connections-layout { grid-template-columns: 1fr; }
    .connections-sidebar { position: static; }
    .connection-group { display: inline-block; width: calc(50% - 4px); vertical-align: top; }
    .connections-help { display: none; }
    .connection-detail-header, .editor-title-row { align-items: flex-start; flex-direction: column; }
    .header-button-group { width: 100%; }
    .header-button-group .button { flex: 1; }
    .route-tab-panel { grid-template-columns: 1fr; }
    .source-condition-row { grid-template-columns: 1fr 1fr; }
    .source-condition-row .source-condition-value { grid-column: 1 / -1; }
    .source-condition-row .custom-mapping-remove { justify-self: start; }
    .editor-summary { position: static; }
    .scenario-canvas { min-height: 560px; }
    .journal-table { overflow-x: auto; }
    .journal-head, .journal-row { min-width: 870px; }
    .run-details { min-width: 870px; }
    .page-hint { align-items: flex-start; flex-direction: column; }
    .page-hint a { margin-left: 0; }
}

@media (max-width: 560px) {
    .source-filter-heading { flex-direction: column; }
    .source-filter-settings, .source-condition-row { grid-template-columns: 1fr; }
    .source-condition-row .source-condition-value { grid-column: auto; }
}

@media (max-width: 620px) {
    .workspace-bar, .workspace-main { width: min(calc(100% - 28px), var(--workspace)); }
    .workspace-main.global-journal-page { width: min(calc(100% - 28px), 1380px); }
    .page-title-row { align-items: flex-start; flex-direction: column; }
    .page-title-row .button { width: 100%; }
    .compact-stats { grid-template-columns: 1fr; }
    .compact-stats div { border-right: 0; border-bottom: 1px solid var(--line); }
    .compact-stats div:last-child { border-bottom: 0; }
    .card-toolbar, .journal-toolbar { align-items: stretch; flex-direction: column; }
    .segmented-control { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
    .search-field input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
    .route-main { grid-template-columns: 1fr; }
    .route-chain { grid-template-columns: auto minmax(0, 1fr); }
    .route-chain .chain-separator { grid-column: 1 / -1; width: max-content; margin-left: 8px; }
    .connections-sidebar { padding: 12px; }
    .connection-group { display: block; width: 100%; }
    .sync-banner, .api-method-banner { align-items: flex-start; flex-direction: column; }
    .detail-panel { padding: 15px; }
    .metric-grid { grid-template-columns: 1fr; }
    .info-list div { grid-template-columns: 1fr; gap: 3px; }
    .step-summary, .mapping-preview { grid-template-columns: 1fr; }
    .service-catalog, .api-form, .mapping-editor { grid-template-columns: 1fr; }
    .scenario-stage-strip { grid-template-columns: 1fr; }
    .scenario-stage-strip > div + div { border-top: 1px solid var(--line); border-left: 0; }
    .scenario-canvas { padding: 22px 14px 34px; }
    .scenario-node, .branching-tool { width: min(100%, 330px); }
    .scenario-branches { justify-content: flex-start; }
    .block-settings-grid, .condition-editor-row { grid-template-columns: 1fr; }
    .block-settings-grid .full-field { grid-column: auto; }
    .api-form > label:first-child, .api-form .inline-notice, .api-form .form-actions, .full-field { grid-column: auto; }
    .custom-mapping-heading { align-items: stretch; flex-direction: column; }
    .custom-mapping-heading .button { width: 100%; }
    .custom-mapping-row { grid-template-columns: 1fr; align-items: stretch; }
    .custom-mapping-row > label { order: 1; }
    .custom-mapping-row > .variable-field { order: 2; }
    .custom-mapping-remove { width: 100%; order: 3; margin-bottom: 0; }
    .variable-token-chip strong { max-width: 130px; }
    .variable-token-chip > span { max-width: 115px; }
    .variable-catalog-heading span { display: none; }
    .modal { padding: 12px; }
    .modal-card { padding: 22px 18px; }
    .journal-filters { align-items: stretch; flex-direction: column; }
    .journal-search input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
    .journal-summary { grid-template-columns: 1fr 1fr; }
    .journal-summary > div { border-bottom: 1px solid var(--line); }
    .journal-summary > div:nth-child(even) { border-right: 0; }
    .journal-summary > div:last-child { border-bottom: 0; }
    .journal-detail-meta { grid-template-columns: 1fr; }
    .manual-routing-actions { align-items: stretch; flex-direction: column; }
    .manual-routing-actions .button { width: 100%; }
    .global-journal-filters { grid-template-columns: 1fr 1fr; }
    .global-journal-search { grid-column: 1 / -1; }
    .global-journal-filter-actions { grid-column: 1 / -1; }
    .global-journal-filter-actions .button { flex: 1; }
    .auth-card { padding: 25px 21px; }
}

@media (max-width: 460px) {
    .global-journal-filters { grid-template-columns: 1fr; }
    .global-journal-search, .global-journal-filter-actions { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Persistent delivery notifications across workspace pages. */
.delivery-notifications { border: 1px solid #d88c32; background: #fff8ed; color: #4b3216; border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; }
.delivery-notifications[hidden] { display: none; }
.delivery-notifications summary { cursor: pointer; font-weight: 600; }
.delivery-notification-list { max-height: 380px; overflow: auto; }
.delivery-notification { border-top: 1px solid #ead6b9; padding: 14px 0; overflow-wrap: anywhere; }
.delivery-notification a { font-weight: 600; }
.delivery-notification p { margin: 6px 0; }

/* Keep all workspace destinations readable in the horizontal navigation. */
.workspace-nav a { flex-shrink: 0; white-space: nowrap; }

/* Incoming webhook sample inspector */
.webhook-settings { min-width: 0; }
.webhook-json { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; padding: 16px; background: #f6f7fb; border-radius: 12px; }
.webhook-fields { max-height: 400px; overflow: auto; min-width: 0; }
.webhook-field { display: grid; grid-template-columns: minmax(0, 1fr) 65px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid #e8ebf2; overflow-wrap: anywhere; }
.webhook-settings .form-actions { flex-wrap: wrap; }
.webhook-settings input { min-width: 0; width: 100%; }
@media(max-width: 600px) { .webhook-field { grid-template-columns: minmax(0, 1fr) 65px; } .webhook-field code { grid-column: 1 / -1; } }
