:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success: #079455;
    --success-soft: #ecfdf3;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --code-bg: #0e1424;
    --radius: 10px;
    --radius-sm: 7px;
    --control-h: 38px;
    --topbar-h: 60px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
p { margin: 0; }

code, kbd, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Layout ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1680px;
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    font-size: 15px;
    color: var(--text);
}
.brand:hover { color: var(--text); }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    box-shadow: 0 2px 6px rgba(79, 70, 229, .35);
}
.brand-mark-lg { width: 46px; height: 46px; border-radius: 12px; }
.brand-mark-lg .icon { width: 22px; height: 22px; }

.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
}
.topbar-nav a:hover { color: var(--text); background: var(--surface-2); }
.topbar-nav a.active { color: var(--text); background: #f2f4f7; }
.topbar-nav a:focus-visible,
.segmented button:focus-visible,
.tabs button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

.container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-head p { margin-top: 4px; }
.page-head-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-head-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.card-head p { margin-top: 2px; }

/* ---------- Controls ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--control-h);
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 550;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
    user-select: none;
}
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .checkbox:focus-visible, .th-sort:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .25);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { color: #fff; background: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { color: #fff; background: var(--primary-hover); }

.btn-ghost { color: var(--text-2); background: var(--surface); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }

.btn-danger { color: #fff; background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b42318; }

.btn-danger-soft { color: var(--danger); background: var(--danger-soft); border-color: #fecdca; }
.btn-danger-soft:hover:not(:disabled) { background: #fee4e2; }

.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon-danger:hover:not(:disabled) { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }
.btn-block { width: 100%; }

.btn kbd {
    margin-left: 2px;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 500;
    background: rgba(255, 255, 255, .18);
}
.btn-ghost kbd { background: #f2f4f7; color: var(--muted); }

.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select {
    width: 100%;
    height: var(--control-h);
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: #a5b4fc; outline: none; box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.input.is-invalid { border-color: #fda29b; }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(217, 45, 32, .15); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }

.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }

.select {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    cursor: pointer;
}
.select-compact { width: auto; }

.checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .field-label { font-weight: 550; color: var(--text-2); font-size: 13px; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--danger); }
.field-error:empty { display: none; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }

.input-group { display: flex; }
.input-group .input { border-top-left-radius: 0; border-bottom-left-radius: 0; font-family: var(--mono); font-size: 13px; }
.input-addon {
    display: inline-flex;
    align-items: center;
    height: var(--control-h);
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12.5px;
}

/* Switch */
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d0d5dd;
    transition: background-color .2s;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .2);
    transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(7, 148, 85, .25); }
.switch input:disabled + .switch-track { opacity: .6; }
.switch-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; color: var(--text-2); cursor: pointer; }

/* Segmented */
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: #f2f4f7; }
.segmented button {
    height: calc(var(--control-h) - 6px);
    padding: 0 12px;
    border: 0;
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
    font-weight: 550;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}
.segmented button.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }

/* Badges & alerts */
.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
    white-space: nowrap;
}
.badge-type { color: var(--text-2); background: #eef2f6; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-info { color: #175cd3; background: #eff8ff; }
.badge-neutral { color: var(--text-2); background: #f2f4f7; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.alert-danger { color: #b42318; background: var(--danger-soft); border-color: #fecdca; }
.alert-warning { color: var(--warning); background: var(--warning-soft); border-color: #fedf89; }

.code-pill {
    padding: 3px 8px;
    border-radius: 6px;
    background: #f2f4f7;
    color: var(--text-2);
    white-space: nowrap;
}

/* ---------- Gateway card ---------- */

.gateway-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 20px;
}
.gateway-item { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.gateway-item + .gateway-item { border-left: 1px solid var(--border); }
.gateway-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.gateway-label .muted { text-transform: none; letter-spacing: 0; font-weight: 500; font-family: var(--mono); }
.gateway-value { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gateway-value code {
    flex: 1;
    min-width: 0;
    height: var(--control-h);
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gateway-value .placeholder { color: var(--primary); }
.secret { letter-spacing: .1em; color: var(--muted); }
.secret.revealed { letter-spacing: 0; color: var(--text); }

/* ---------- Table ---------- */

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.search { position: relative; flex: 1; max-width: 360px; min-width: 200px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; }

.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-count { font-weight: 600; color: var(--primary); margin-right: 4px; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
    position: sticky;
    top: var(--topbar-h);
    z-index: 5;
    padding: 0 16px;
    height: 42px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr.selected { background: var(--primary-soft); }

.th-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border: 0;
    background: none;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
}
.th-sort .icon { width: 13px; height: 13px; opacity: .35; }
.th-sort:hover { color: var(--text); }
th.sorted .th-sort { color: var(--text); }
th.sorted .th-sort .icon { opacity: 1; color: var(--primary); }
th[aria-sort="descending"] .th-sort .icon { transform: scaleY(-1); }

.col-check { width: 44px; padding-right: 0 !important; }
.col-actions { width: 1%; text-align: right !important; }
.cell-title a { font-weight: 600; color: var(--text); }
.cell-title a:hover { color: var(--primary); }

.api-url { display: flex; align-items: center; gap: 6px; max-width: 520px; }
.api-url code {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.btn-icon-xs { width: 26px; height: 26px; flex: none; border-color: transparent; background: transparent; }
.btn-icon-xs:hover { border-color: var(--border); background: var(--surface); }
.btn-icon-xs svg { width: 14px; height: 14px; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions .btn-icon { border-color: transparent; background: transparent; }
.row-actions .btn-icon:hover { border-color: var(--border); background: var(--surface); }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.per-page, .pager { display: flex; align-items: center; gap: 10px; }

.empty-state { padding: 56px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state .btn { margin-top: 12px; }
.empty-state-sm { padding: 32px 24px; }
.empty-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    color: var(--primary);
    background: var(--primary-soft);
    margin-bottom: 6px;
}
.empty-icon .icon { width: 22px; height: 22px; }

/* ---------- Editor page ---------- */

.endpoint-preview code { color: var(--muted); word-break: break-all; }
.save-state { font-size: 13px; }
.save-state.is-dirty { color: var(--warning); }

.fields-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 260px);
    gap: 20px;
    padding: 18px 20px;
    margin-bottom: 20px;
}

.status-map-card { padding: 18px 20px; margin-bottom: 20px; }
.status-map-card h2 { display: inline-flex; align-items: center; gap: 8px; }
.status-match-field { max-width: 440px; margin-bottom: 18px; }
.status-match-field .field-hint { max-width: 68ch; }
.status-map, .status-map-labels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.status-map { row-gap: 8px; }
.status-row, .status-map-label-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) var(--control-h);
    align-items: center;
    gap: 8px;
}
.status-map-label-pair { margin-bottom: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.status-map-label-pair span:last-child { grid-column: 3; }
.status-arrow { display: grid; place-items: center; color: var(--muted); }
.status-row.is-invalid .input { border-color: #fda29b; }
.status-map-empty { padding: 4px 0; }
.status-map-card .field-error { margin-top: 10px; }

.retry-card { padding: 18px 20px; margin-bottom: 20px; }
.retry-card .card-head { margin-bottom: 16px; }
.retry-settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 260px));
    gap: 16px 20px;
    margin-bottom: 16px;
}
.retry-messages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}
.retry-messages .textarea { min-height: 110px; }

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(380px, 1fr);
    gap: 20px;
    align-items: start;
}

.editor-card, .tester-card { padding: 18px 20px 20px; min-width: 0; }
.tester-card { position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; }

.editor-card .CodeMirror {
    height: calc(100vh - 290px);
    min-height: 520px;
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.6;
}
.code-error { margin-bottom: 8px; }

.reference {
    margin-bottom: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.reference dl { margin: 0; display: grid; gap: 4px; }
.reference dt { margin-top: 8px; }
.reference dt:first-child { margin-top: 0; }
.reference dt code { color: var(--primary); font-weight: 600; }
.reference dd { margin: 0; color: var(--text-2); font-size: 13px; }
.reference dd code { padding: 1px 5px; border-radius: 4px; background: #eaecf0; font-size: 12px; }

.params { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.param-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) var(--control-h); gap: 8px; }

.tester-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.result { margin-top: 18px; }
.result-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabs button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font: inherit;
    font-size: 13px;
    font-weight: 550;
    color: var(--muted);
    background: none;
    cursor: pointer;
    white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.segmented button:focus-visible,
.tabs button:focus-visible { position: relative; z-index: 1; }
.tab-count { min-width: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; line-height: 18px; text-align: center; background: #f2f4f7; color: var(--muted); }

.panel { margin: 0; }
pre.panel, .http-call pre {
    padding: 14px 16px;
    border-radius: 8px;
    background: var(--code-bg);
    color: #d6deeb;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    max-height: 480px;
}
.panel-empty { padding: 8px 0; }
.j-key { color: #82aaff; }
.j-str { color: #c3e88d; }
.j-num { color: #f78c6c; }
.j-bool { color: #c792ea; }
.j-null { color: #89ddff; }
.c-label { display: inline-block; font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: #82aaff; }
.c-error { color: #ff6b6b; }
.c-warning { color: #ffcb6b; }

.http-call { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.http-call summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    background: var(--surface-2);
    list-style: none;
}
.http-call summary::-webkit-details-marker { display: none; }
.http-call[open] summary { border-bottom: 1px solid var(--border); }
.http-method { font-family: var(--mono); font-weight: 700; font-size: 12px; }
.http-url { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.http-error { padding: 10px 12px 0; color: var(--danger); font-size: 13px; }
.http-grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 12px; }
.http-grid pre { margin: 0 0 8px; max-height: 280px; font-size: 12px; }

/* ---------- CodeMirror theme ---------- */

.cm-s-gw.CodeMirror { background: var(--code-bg); color: #d6deeb; }
.cm-s-gw .CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid #1d2640; }
.cm-s-gw .CodeMirror-linenumber { color: #4b5876; padding: 0 12px 0 8px; }
.cm-s-gw .CodeMirror-cursor { border-left: 2px solid #a5b4fc; }
.cm-s-gw div.CodeMirror-selected, .cm-s-gw.CodeMirror-focused div.CodeMirror-selected { background: #2a3658; }
.cm-s-gw .CodeMirror-line::selection, .cm-s-gw .CodeMirror-line > span::selection, .cm-s-gw .CodeMirror-line > span > span::selection { background: #2a3658; }
.cm-s-gw .CodeMirror-activeline-background { background: #141c33; }
.cm-s-gw .CodeMirror-activeline .CodeMirror-gutter-elt { color: #a5b4fc; }
.cm-s-gw .CodeMirror-matchingbracket { color: #fff !important; background: #33415f; text-decoration: none; }
.cm-s-gw .cm-keyword { color: #c792ea; }
.cm-s-gw .cm-def { color: #82aaff; }
.cm-s-gw .cm-variable { color: #d6deeb; }
.cm-s-gw .cm-variable-2 { color: #f07178; }
.cm-s-gw .cm-variable-3, .cm-s-gw .cm-type { color: #ffcb6b; }
.cm-s-gw .cm-builtin { color: #82aaff; }
.cm-s-gw .cm-atom { color: #f78c6c; }
.cm-s-gw .cm-number { color: #f78c6c; }
.cm-s-gw .cm-string, .cm-s-gw .cm-string-2 { color: #c3e88d; }
.cm-s-gw .cm-comment { color: #637196; font-style: italic; }
.cm-s-gw .cm-operator { color: #89ddff; }
.cm-s-gw .cm-meta { color: #ffcb6b; }
.cm-s-gw .cm-property { color: #80cbc4; }
.cm-s-gw .cm-error { color: #ff6b6b; }
.cm-s-gw .cm-error-line { background: rgba(255, 82, 82, .16); }

/* ---------- Toasts & modal ---------- */

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 40px));
}
.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: #fff;
    background: #101828;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    border-left: 4px solid var(--success);
}
.toast.show { opacity: 1; transform: none; }
.toast-error { border-left-color: #f97066; }
.toast-warning { border-left-color: #fdb022; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 24, 40, .45);
    backdrop-filter: blur(2px);
}
.modal {
    width: 100%;
    max-width: 420px;
    padding: 22px;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.modal p { margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ---------- Auth ---------- */

.auth-body { background: radial-gradient(1200px 600px at 50% -10%, #e0e7ff 0%, var(--bg) 60%); }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 24px; }
.auth-brand h1 { font-size: 20px; margin-top: 6px; }

/* ---------- Requests page ---------- */

.table-card { margin-bottom: 20px; }
.table-card .table-toolbar h2 { display: inline-flex; align-items: center; gap: 8px; }

.filters-bar { padding: 0 16px 14px; border-bottom: 1px solid var(--border); }
.filters-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters-fields .search { flex: 1; max-width: 320px; min-width: 180px; }
.input-date { width: auto; color: var(--text-2); }

.log-message { max-width: 460px; min-width: 0; }
.log-details summary { cursor: pointer; color: var(--text-2); list-style: none; }
.log-details summary::before { content: "▸"; margin-right: 6px; color: var(--muted); }
.log-details[open] summary::before { content: "▾"; }
.log-details-body {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.log-details-message { white-space: pre-wrap; word-break: break-word; }
.log-details-input {
    margin: 8px 0 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--code-bg);
    color: #d6deeb;
    font-size: 11.5px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow: auto;
}

.pager a.is-disabled { opacity: .45; pointer-events: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .tester-card { position: static; max-height: none; overflow: visible; }
    .editor-card .CodeMirror { height: 60vh; min-height: 420px; }
    .status-map, .status-map-labels { grid-template-columns: minmax(0, 1fr); }
    .status-map-labels-wide { display: none; }
    .http-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .topbar { height: auto; }
    .topbar-inner { height: auto; min-height: var(--topbar-h); padding: 10px 16px 0; gap: 8px 14px; flex-wrap: wrap; }
    .topbar-nav { order: 3; width: 100%; gap: 6px; margin-top: -3px; padding: 0 0 8px; }
    .topbar-nav a { flex: 1; padding: 6px 8px; text-align: center; }
    .topbar-actions { gap: 6px; }
    .hide-sm { display: none !important; }
    .container { padding: 20px 14px 40px; }
    h1 { font-size: 19px; }

    .gateway-card { grid-template-columns: 1fr; }
    .gateway-item + .gateway-item { border-left: 0; border-top: 1px solid var(--border); }
    .fields-card { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
    .editor-card, .tester-card { padding: 16px; }
    .http-grid { grid-template-columns: 1fr; }
    .page-actions { width: 100%; justify-content: space-between; }

    .search { max-width: none; }

    .table thead { display: none; }
    .table, .table tbody { display: block; }
    .table tbody { padding: 12px; display: grid; gap: 12px; }
    .table tbody tr {
        position: relative;
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 6px 12px;
        padding: 14px 14px 14px 46px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    .table td { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; min-width: 0; }
    .table td[data-label]::before {
        content: attr(data-label);
        min-width: 84px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--muted);
    }
    .table td.col-check { position: absolute; top: 16px; left: 16px; width: auto; }
    .table td.cell-title { grid-column: 1 / -1; font-size: 15px; }
    .table td.cell-title::before { display: none; }
    .table td.col-actions { grid-column: 1 / -1; width: auto; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); }
    .row-actions { width: 100%; }
    .table td:not(.cell-title):not(.col-actions):not(.col-check) { grid-column: 1 / -1; }
}

@media (max-width: 390px) {
    .topbar-inner { padding-inline: 12px; column-gap: 8px; }
    .brand { gap: 7px; font-size: 14px; }
    .brand-mark { width: 28px; height: 28px; }
    .topbar-actions .btn { padding-inline: 10px; }
}
