: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; }

.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 { 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 92px; 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; }

.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; }

.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; }
.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; }
.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 { max-width: 1080px; }
.editor-title-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.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; }
.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; }

/* Journal */
.journal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.journal-filters { display: flex; align-items: flex-end; gap: 8px; }
.journal-filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; }
.journal-filters input { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 11px; }
.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: 140px 145px 140px minmax(170px, 1fr) 150px; 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 { width: 100%; min-height: 66px; padding: 11px 14px; text-align: left; border: 0; background: #fff; font-size: 11px; }
.journal-row:hover { background: #fbfcfd; }
.journal-row > span:nth-child(2) { display: flex; flex-direction: column; }
.journal-row small { color: var(--faint); font-size: 10px; }
.journal-services { display: flex; align-items: center; gap: 5px; }
.journal-services .brand-icon { width: 24px; height: 24px; flex-basis: 24px; border-radius: 6px; }
.journal-services .brand-icon img { width: 13px; height: 13px; }
.journal-services .brand-word { min-height: 24px; padding-inline: 5px; font-size: 6px; }
.run-details { padding: 0 14px 11px 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; }

/* 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, .stack-form select, .mapping-editor input, .mapping-editor select, .mapping-editor textarea { 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:disabled { color: #858a93; background: #f4f5f7; }
.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-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 { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; }
.auth-form .button { margin-top: 5px; }
.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; }
    .amo-tabs button { padding-inline: 7px; }
    .route-tab-panel { grid-template-columns: minmax(0, 1fr) 230px; }
    .journal-head, .journal-row { grid-template-columns: 125px 135px 130px minmax(170px, 1fr) 150px; }
}

@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: 24px; }
    .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; }
    .editor-summary { position: static; }
    .journal-table { overflow-x: auto; }
    .journal-head, .journal-row { min-width: 780px; }
    .run-details { min-width: 780px; }
    .page-hint { align-items: flex-start; flex-direction: column; }
    .page-hint a { margin-left: 0; }
}

@media (max-width: 620px) {
    .workspace-bar, .workspace-main { width: min(calc(100% - 28px), var(--workspace)); }
    .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 { 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; }
    .api-form > label:first-child, .api-form .inline-notice, .api-form .form-actions, .full-field { grid-column: auto; }
    .modal { padding: 12px; }
    .modal-card { padding: 22px 18px; }
    .journal-filters { align-items: stretch; flex-direction: column; }
    .auth-card { padding: 25px 21px; }
}

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