/* ==========================================================================
   PIPE — собственная дизайн-система в духе Chrono.
   Без Bootstrap, Bootstrap Icons и внешних шрифтов.
   ========================================================================== */

:root {
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

    --bg: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --surface-3: #eef1f8;
    --surface-glass: rgba(255, 255, 255, .82);

    --text: #171a25;
    --text-2: #545c70;
    --text-3: #8b92a6;

    --border: rgba(23, 26, 37, .09);
    --border-strong: rgba(23, 26, 37, .16);

    --accent: #5b5bd6;
    --accent-2: #8b6cf6;
    --accent-hover: #4e4ec8;
    --accent-soft: rgba(91, 91, 214, .10);

    --ok: #0f9d6e;
    --ok-soft: rgba(15, 157, 110, .12);
    --warn: #c77b00;
    --warn-soft: rgba(199, 123, 0, .13);
    --danger: #e5484d;
    --danger-soft: rgba(229, 72, 77, .10);
    --info: #0b8bc4;
    --info-soft: rgba(11, 139, 196, .11);

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 16px -6px rgba(16, 24, 40, .08);
    --shadow-md: 0 2px 4px rgba(16, 24, 40, .04), 0 20px 44px -18px rgba(16, 24, 40, .18);
    --shadow-lg: 0 32px 90px -24px rgba(16, 24, 40, .32);
    --ring: 0 0 0 3px rgba(91, 91, 214, .18);

    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --nav-h: 56px;
    --grid-dot: rgba(23, 26, 37, .10);
    --glow-1: rgba(124, 92, 255, .14);
    --glow-2: rgba(14, 165, 233, .10);
    --ease: cubic-bezier(.2, .7, .2, 1);

    color-scheme: light;
}

html[data-bs-theme="dark"] {
    --bg: #0d0f16;
    --surface: #12141d;
    --surface-2: #171a24;
    --surface-3: #1f2330;
    --surface-glass: rgba(18, 20, 29, .86);
    --text: #eef0f7;
    --text-2: #a6adc1;
    --text-3: #6f778c;
    --border: rgba(255, 255, 255, .09);
    --border-strong: rgba(255, 255, 255, .16);
    --accent: #8b7cff;
    --accent-2: #c084fc;
    --accent-hover: #9d90ff;
    --accent-soft: rgba(139, 124, 255, .14);
    --grid-dot: rgba(255, 255, 255, .10);
    --glow-1: rgba(139, 124, 255, .16);
    --glow-2: rgba(14, 165, 233, .10);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background:
        radial-gradient(900px 500px at 12% -10%, rgba(124, 92, 255, .12), transparent 70%),
        radial-gradient(700px 420px at 100% 0%, rgba(14, 165, 233, .09), transparent 70%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
svg { display: inline-block; vertical-align: -.14em; }
code, pre { font-family: var(--font-mono); }
h1, h2, h3, p { margin-top: 0; }

/* ------------------------------- utilities -------------------------------- */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; gap: .5rem; }
.flex-wrap { flex-wrap: wrap !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.ms-auto { margin-left: auto !important; }
.ms-1 { margin-left: .25rem !important; }
.ms-2 { margin-left: .5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.me-1 { margin-right: .25rem !important; }
.me-2 { margin-right: .5rem !important; }
.me-3 { margin-right: 1rem !important; }
.mt-1 { margin-top: .25rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .25rem !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.p-0 { padding: 0 !important; }
.p-1 { padding: .25rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.gap-1 { gap: .25rem !important; }
.gap-2 { gap: .5rem !important; }
.gap-3 { gap: 1rem !important; }
.w-100 { width: 100% !important; }
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }
.text-muted { color: var(--text-3) !important; }
.text-dark { color: var(--text) !important; }
.text-primary { color: var(--accent) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.text-danger { color: var(--danger) !important; }
.small, small { font-size: .82rem; }
.fs-1 { font-size: 2.4rem; }
.opacity-50 { opacity: .5; }
.fw-normal { font-weight: 400; }
.container-fluid { width: 100%; padding: 0 16px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > * { padding: 0 8px; }
.col-12 { width: 100%; }
.g-3 > * { margin-bottom: 1rem; }
@media (min-width: 576px) {
    .col-sm-4 { width: 33.333%; }
}
@media (min-width: 768px) {
    .col-md-4 { width: 33.333%; }
    .col-md-6 { width: 50%; }
    .col-md-8 { width: 66.666%; }
    .d-md-inline { display: inline !important; }
}
@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
}

/* ------------------------------- components ------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem .8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: .84rem;
    font-weight: 550;
    line-height: 1.2;
    transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { padding: .3rem .55rem; font-size: .78rem; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; color: #fff; }
.btn-success { background: var(--ok); border-color: transparent; color: #fff; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-light { background: var(--surface-2); }
.btn-link { border-color: transparent; background: transparent; color: var(--accent); }
.btn-outline-primary { color: var(--accent); border-color: rgba(91, 91, 214, .35); }
.btn-outline-secondary { color: var(--text-2); }
.btn-outline-success { color: var(--ok); border-color: rgba(15, 157, 110, .35); }
.btn-outline-info { color: var(--info); border-color: rgba(11, 139, 196, .35); }
.btn-outline-danger { color: var(--danger); border-color: rgba(229, 72, 77, .35); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-control, .form-select {
    width: 100%;
    padding: .48rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.form-control:disabled { background: var(--surface-2); color: var(--text-3); }
textarea.form-control { resize: vertical; }
.form-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.form-label, .inputlabel { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: .3rem; }
.form-text { font-size: .74rem; color: var(--text-3); margin-top: .3rem; }
.invalid-feedback { display: none; color: var(--danger); font-size: .75rem; margin: .2rem 0 .4rem; }
.invalid-feedback.is-visible { display: block; }
.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.form-check-input { width: 1rem; height: 1rem; accent-color: var(--accent); }
.form-switch .form-check-input { width: 2rem; height: 1.1rem; border-radius: 2rem; }
.form-check-label { font-size: .82rem; }

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-glass);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-sm);
}
.card-body { padding: 1.25rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius-md); border: 1px solid transparent; font-size: .85rem; margin-bottom: 1rem; }
.alert-danger { background: var(--danger-soft); border-color: rgba(229, 72, 77, .25); color: var(--danger); }
.alert-success { background: var(--ok-soft); border-color: rgba(15, 157, 110, .25); color: var(--ok); }
.alert-info { background: var(--info-soft); border-color: rgba(11, 139, 196, .25); color: var(--info); }
.badge { display: inline-block; padding: .2rem .5rem; border-radius: 2rem; font-size: .72rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.text-bg-secondary { background: var(--surface-3) !important; color: var(--text-2) !important; }
.text-bg-light { background: var(--surface-3) !important; color: var(--text-2) !important; }

.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th, .table td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.table tbody tr:hover { background: var(--surface-2); }
.table-responsive { overflow-x: auto; }

.spinner-border { display: inline-block; width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: pipe-spin .7s linear infinite; }
@keyframes pipe-spin { to { transform: rotate(360deg); } }

/* --------------------------------- nav ------------------------------------ */
#navigation {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--nav-h);
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
#navigation .navbar { display: flex; align-items: center; height: 100%; }
#navigation .container-fluid {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    height: 100%;
    gap: 1rem;
}
/* Bootstrap раньше задавал flex для детей navbar; после его удаления
   элементы шапки складывались друг под другом. */
#navigation .container-fluid > * { flex: 0 0 auto; min-width: 0; }
#navigation .nav-brand { display: flex; align-items: center; flex: 0 0 auto; }
#navigation .nav-actions { display: flex; align-items: center; gap: .6rem; flex: 0 0 auto; margin-left: auto; }
#navigation #logo_link { display: inline-flex; align-items: center; text-decoration: none; }
#navigation #logo_link img, #navigation .brand-logo { display: block; height: 34px; width: auto; }
.brand-mark { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
#navigation #themeToggle { display: inline-flex; align-items: center; justify-content: center; font-size: 0; cursor: pointer; padding: .35rem; border-radius: var(--radius-sm); }
#navigation #themeToggle:hover { background: var(--surface-3); }

/* User menu (chrono-style): avatar opens all navigation and logout. */
.user-menu { position: relative; }
.avatar-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0;
    border: 1px solid rgba(255,255,255,.28); border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; cursor: pointer; box-shadow: var(--shadow-sm);
    transition: transform .15s, box-shadow .15s;
}
.avatar-button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; font-weight: 700; line-height: 1; }
.avatar-letter--lg { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.user-menu__panel {
    position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
    width: 260px; padding: 8px;
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--surface); box-shadow: var(--shadow-lg);
    animation: pipe-in .16s ease;
}
.user-menu__panel[hidden] { display: none; }
.user-menu__head { display: flex; align-items: center; gap: .65rem; min-width: 0; padding: 8px 8px 12px; }
.user-menu__identity { display: flex; flex-direction: column; min-width: 0; }
.user-menu__identity strong, .user-menu__identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__identity strong { font-size: .85rem; }
.user-menu__identity small { font-size: .72rem; color: var(--text-3); }
.user-menu__divider { height: 1px; margin: 4px 0; background: var(--border); }
.user-menu__item {
    display: flex; align-items: center; gap: .6rem; width: 100%;
    padding: .5rem .6rem; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-2);
    font-size: .84rem; font-weight: 550; text-align: left; text-decoration: none; cursor: pointer;
}
.user-menu__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__item svg { flex: none; color: var(--text-3); }
.user-menu__item:hover, .user-menu__item.active { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.user-menu__item:hover svg, .user-menu__item.active svg { color: var(--accent); }

/* ------------------------------ common pages ------------------------------ */
.page-shell { max-width: 1160px; margin: 0 auto; padding: 32px 20px 60px; }
.page-title { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .3rem; display: flex; align-items: center; gap: .5rem; }
.page-subtitle { color: var(--text-2); font-size: .9rem; margin: 0; }
/* В профиле каркас используется без .card-body, поэтому отступы задаём здесь. */
.form-card { max-width: 540px; padding: 1.25rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-heading .btn { flex: none; }
.table-card { overflow: hidden; }
.table-card .table { margin: 0; }
.align-middle { vertical-align: middle !important; }
.template-title { font-weight: 650; color: var(--text); }
.template-uid { margin-top: .15rem; font-family: var(--font-mono); font-size: .68rem; color: var(--text-3); }
.template-description { max-width: 340px; color: var(--text-2); }
.template-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .35rem; }
.template-empty { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 48px 20px; text-align: center; color: var(--text-3); }
.template-empty svg { color: var(--accent); }
.template-empty h2 { margin: 0; font-size: 1.1rem; color: var(--text); }
.template-empty p { margin: 0 0 .6rem; max-width: 420px; font-size: .85rem; }
.stat-card { display: flex; align-items: center; gap: .8rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.stat-value { font-size: 1.35rem; font-weight: 700; }
.stat-label { font-size: .75rem; color: var(--text-3); }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding: 10px 4px 0; border-bottom: 1px solid var(--border); }
.chart-bar { flex: 1; min-height: 2px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--accent-2), var(--accent)); opacity: .85; position: relative; }
.chart-bar span { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: .68rem; color: var(--text-3); }
.chart-bar b { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--text-2); }
.chart-wrap { padding-bottom: 28px; }
.run-badge, .status-pill { display: inline-block; padding: .2rem .55rem; border-radius: 2rem; font-size: .72rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); }
.run-success, .status-pill.dirty { background: var(--ok-soft); color: var(--ok); }
.run-failed, .run-error { background: var(--danger-soft); color: var(--danger); }
.run-running { background: var(--info-soft); color: var(--info); }
.run-queued, .run-retry { background: var(--warn-soft); color: var(--warn); }
.log-row { display: flex; gap: .5rem; padding: .3rem 0; font-size: .8rem; border-bottom: 1px solid var(--border); }
.log-badge { min-width: 60px; font-size: .68rem; text-transform: uppercase; font-weight: 700; color: var(--text-3); }
.log-ok .log-badge { color: var(--ok); }
.log-error .log-badge { color: var(--danger); }
.log-warn .log-badge { color: var(--warn); }
.log-skipped .log-badge { color: var(--text-3); }

/* -------------------------------- editor ---------------------------------- */
#navigation .editor-toolbar { flex: 1 1 auto; justify-content: flex-end; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.editor-toolbar::-webkit-scrollbar { display: none; }
.toolbar-sep { flex: 0 0 1px; width: 1px; height: 20px; background: var(--border-strong); margin: 0 .2rem; }

#leftcard {
    position: fixed;
    top: var(--nav-h);
    bottom: 0;
    left: 0;
    width: 282px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--surface-glass);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--border);
    transition: transform .22s var(--ease, ease);
}
/* Только содержимое панели прокручивается; футер всегда закреплён снизу
   и не попадает в список нодов при небольшой высоте окна. */
#left_scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 12px;
}
#leftcard:not(.left_expanded) { transform: translateX(-100%); }
#closecard {
    position: absolute;
    top: 12px;
    right: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    z-index: 45;
}
#closecard #arrow_right { display: none; }
#leftcard:not(.left_expanded) { overflow: visible; }
#leftcard:not(.left_expanded) #left_scroll,
#leftcard:not(.left_expanded) #footer { visibility: hidden; pointer-events: none; }
#leftcard:not(.left_expanded) #closecard {
    position: fixed;
    left: 12px;
    right: auto;
    top: calc(var(--nav-h) + 12px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}
#leftcard:not(.left_expanded) #closecard #arrow_left { display: none; }
#leftcard:not(.left_expanded) #closecard #arrow_right { display: inline-flex; }
.pipe-props, .versions-panel { padding-bottom: 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.versions-panel .btn { flex: 1 1 auto; min-width: 0; white-space: normal; text-align: center; }
#node_panel { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; padding-top: 4px; }
#search { position: relative; flex: 0 0 auto; }
#search svg { position: absolute; left: 10px; top: 10px; color: var(--text-3); }
#search input { padding-left: 32px; }
#nodes_subnav { display: flex; gap: 4px; margin: 10px 0; flex-wrap: wrap; flex: 0 0 auto; }
.side { padding: .25rem .55rem; border-radius: 2rem; font-size: .75rem; cursor: pointer; color: var(--text-2); }
.side:hover, .side.navactive { background: var(--accent-soft); color: var(--accent); }
.side.navdisabled { opacity: .55; }
#blocklist {
    display: grid;
    align-content: start;
    gap: 8px;
    flex: 0 1 auto;
    min-height: 220px;
    max-height: 46vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 4px 2px 2px;
}
.blockelem {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    cursor: grab;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.blockelem:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.blockelem:active { cursor: grabbing; }
.blockelem .grabme { color: var(--text-3); }
.blockico { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent); flex: none; }
.blocktitle { font-size: .82rem; font-weight: 650; margin: 0; }
.blockdesc { font-size: .7rem; color: var(--text-3); margin: 0; }
.blocktext { min-width: 0; }
.templates { flex: 0 0 auto; }
.templates .btn { width: 100%; justify-content: flex-start; }
.template-hint { margin: 0; font-size: .72rem; line-height: 1.45; color: var(--text-3); }
.saved-template { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#footer {
    flex: 0 0 auto;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface-glass);
    font-size: .7rem;
    color: var(--text-3);
    text-align: center;
}

#canvas {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    bottom: 0;
    margin-left: 282px;
    overflow: auto;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 22px 22px;
    transition: margin-left .22s ease;
}
body:not(.left-open) #canvas { margin-left: 0; }
#canvas::before, #canvas::after { content: ""; position: fixed; z-index: -1; border-radius: 50%; filter: blur(70px); pointer-events: none; }
#canvas::before { width: 320px; height: 320px; top: 80px; left: 320px; background: rgba(124, 92, 255, .10); }
#canvas::after { width: 280px; height: 280px; right: 60px; bottom: 40px; background: rgba(14, 165, 233, .08); }
#canvas-inner { position: relative; width: 2400px; height: 1600px; }
#pipe-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.pipe-node {
    position: absolute;
    width: 236px;
    min-height: 104px;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    user-select: none;
    transition: border-color .15s, box-shadow .15s;
}
.pipe-node:hover { border-color: var(--accent); }
.pipe-node.selected { border-color: var(--accent); box-shadow: var(--ring), var(--shadow-md); }
.pipe-node.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 5; }
.pipe-node .node-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 6px; }
.pipe-node .node-kind { margin-left: auto; font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.pipe-node .node-name { font-size: .85rem; font-weight: 650; margin: 0 0 3px; }
.pipe-node .node-summary { font-size: .72rem; color: var(--text-3); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pipe-node .node-branch { display: inline-block; margin-top: 6px; font-size: .65rem; padding: .1rem .4rem; border-radius: 1rem; background: var(--surface-3); color: var(--text-2); }
.pipe-node .node-branch.yes { background: var(--ok-soft); color: var(--ok); }
.pipe-node .node-branch.no { background: var(--warn-soft); color: var(--warn); }
.pipe-port {
    position: absolute;
    top: 46px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--surface);
    cursor: crosshair;
}
.pipe-port.in { left: -8px; }
.pipe-port.out { right: -8px; }
.pipe-node.connect-target { border-color: var(--ok); box-shadow: var(--ring); }
.block-run-ok { border-color: var(--ok) !important; }
.block-run-error { border-color: var(--danger) !important; }
.block-run-active { border-color: var(--info) !important; }
.block-run-skipped { opacity: .55; border-style: dashed; }
.pipe-link { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .55; }
.pipe-link-skipped { stroke-dasharray: 5 4; opacity: .3; }

#propwrap {
    position: fixed;
    top: var(--nav-h);
    right: 0;
    bottom: 0;
    width: 320px;
    z-index: 35;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 18px 16px 40px;
    background: var(--surface-glass);
    backdrop-filter: blur(14px);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform .22s ease;
}
#propwrap.right_expanded { transform: translateX(0); box-shadow: var(--shadow-lg); }
#close_prop_panel { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer; background: var(--surface-2); }
#rightcard_header { font-size: 1rem; font-weight: 700; }
#propswitch { display: flex; gap: 4px; margin-bottom: 14px; }
.prop_nav { padding: .3rem .6rem; border-radius: var(--radius-sm); font-size: .76rem; color: var(--text-2); cursor: pointer; }
.prop_nav.propactive { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.node-field { margin-bottom: .5rem; }
.node-schema-kicker { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 14px 0 8px; }

#editor { position: fixed; top: var(--nav-h); left: 282px; right: 0; bottom: 0; padding: 24px; overflow: auto; background: var(--bg); transition: left .22s ease; }
body:not(.left-open) #editor { left: 0; }
#jsonInput { min-height: 320px; font-family: var(--font-mono); font-size: 12px; }

/* ------------------------- dialogs, toasts, logs --------------------------- */
#uiToasts { position: fixed; top: calc(var(--nav-h) + 14px); right: 18px; z-index: 100; display: grid; gap: 8px; width: min(340px, calc(100vw - 36px)); max-height: calc(100vh - var(--nav-h) - 28px); overflow-y: auto; }
.ui-toast {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem .9rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    font-size: .82rem;
    animation: pipe-in .2s ease;
}
.ui-toast-success { border-left-color: var(--ok); }
.ui-toast-error { border-left-color: var(--danger); }
.ui-toast-warning { border-left-color: var(--warn); }
.ui-toast-info { border-left-color: var(--info); }
.ui-toast__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ui-toast__close { border: 0; background: transparent; color: var(--text-3); }
@keyframes pipe-in { from { opacity: 0; transform: translateX(12px); } }

.ui-dialog-backdrop { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 12, 20, .5); backdrop-filter: blur(4px); }
.ui-dialog { position: relative; width: min(460px, 100%); max-height: 90vh; overflow: auto; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.ui-dialog h2 { font-size: 1.1rem; margin-bottom: .6rem; }
.ui-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 18px; }

.ide-panel { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 38; display: flex; flex-direction: column; width: min(680px, calc(100vw - 40px)); max-height: 42vh; min-height: 0; overflow: hidden; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-glass); backdrop-filter: blur(14px); box-shadow: var(--shadow-lg); }
.ide-panel h3 { font-size: .9rem; margin-bottom: .5rem; }
#ideLog { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
.ide-panel .ide-close { border: 0; background: transparent; color: var(--text-3); }

@media (max-width: 991px) {
    #leftcard { width: min(300px, 88vw); transform: translateX(-100%); }
    #leftcard.left_expanded { transform: translateX(0); }
    #canvas, #editor { margin-left: 0; left: 0; }
    #propwrap { width: min(320px, 92vw); }
    .editor-toolbar { max-width: 55vw; }
}

/* ------------------------------- refinements ------------------------------ */
.btn.active, .btn-outline-primary.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.form-range { width: 100%; accent-color: var(--accent); margin: .3rem 0 .8rem; }
#canvas .pipe-empty {
    position: absolute; top: 120px; left: 90px;
    padding: .7rem 1rem; border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md); color: var(--text-3); font-size: .85rem;
}
#canvas-inner { overflow: visible; }
#pipe-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pipe-link-temp { stroke-dasharray: 6 4; opacity: .8; }
.blockelem .blocktext { display: flex; flex-direction: column; min-width: 0; }
.blockelem .blocktitle, .blockelem .blockdesc { display: block; }
.blockelem .grabme { display: inline-flex; color: var(--text-3); }
#close_prop_panel svg, #closecard svg, #themeToggle svg, #logoutButton svg { display: block; }
#close_prop_panel { line-height: 1; }
#nodeProps { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
#propwrap > .d-flex, #divisionthing { flex: 0 0 auto; }
#rightcard_header { padding-right: 30px; }
.form-control-sm, .form-select-sm { padding: .3rem .55rem; font-size: .78rem; }
.ui-toast.is-leaving { opacity: 0; transform: translateX(12px); transition: opacity .2s, transform .2s; }
.ui-toast__icon { display: inline-flex; flex: none; }
.ui-dialog__close { position: absolute; top: 12px; right: 12px; border: 0; background: transparent; color: var(--text-3); }
.ui-dialog__title { padding-right: 30px; font-size: 1.05rem; font-weight: 700; margin-bottom: .7rem; }
.ui-dialog__body { font-size: .85rem; color: var(--text-2); }
.ui-dialog__text { margin-bottom: .6rem; line-height: 1.5; }
.ui-dialog__error { margin-top: .8rem; padding: .5rem .7rem; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: .8rem; }
.ui-dialog__icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: .8rem; }
.ide-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.ide-close { border: 0; background: transparent; color: var(--text-3); }
.ide-panel .log-row:last-child { border-bottom: 0; }
.pipe-node .node-head { min-height: 30px; }
.pipe-node .node-head .blockico { width: 26px; height: 26px; border-radius: 8px; font-size: 0; }
.pipe-node .node-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#navigation .navbar-nav { margin-right: auto; }
.pagination { display: flex; justify-content: center; gap: 4px; list-style: none; padding: 0; margin: 0; }
.page-item .page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: .8rem; }
.page-item .page-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.disabled .page-link { opacity: .45; pointer-events: none; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.fw-semibold { font-weight: 650; }
.text-nowrap { white-space: nowrap; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.justify-content-center { justify-content: center !important; }
.font-monospace { font-family: var(--font-mono) !important; }
.py-2 { padding-top: .5rem !important; padding-bottom: .5rem !important; }

/* -------------------------- connection hit areas -------------------------- */
#canvas-inner, .pipe-node, .pipe-port { touch-action: none; }
.pipe-port::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; }
.pipe-port.in { z-index: 2; }

/* ------------------------------- dashboard -------------------------------- */
.dashboard-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}
.dash-hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2rem;
    overflow: hidden;
    padding: 32px 34px;
    background: linear-gradient(120deg, var(--surface) 0%, var(--surface) 52%, var(--accent-soft) 100%);
}
.dash-hero__content { position: relative; z-index: 1; min-width: 0; }
.dash-eyebrow {
    display: inline-block;
    margin-bottom: .7rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
}
.dash-hero .page-title { font-size: 1.9rem; }
.dash-hero .page-subtitle { max-width: 620px; margin-bottom: 1.2rem; }
.dash-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.dash-hero__art { position: relative; flex: 0 0 260px; height: 150px; }
.dash-flow-node {
    position: absolute;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.dash-flow-node--one { top: 8px; left: 8px; }
.dash-flow-node--two { top: 68px; left: 104px; }
.dash-flow-node--three { top: 18px; left: 200px; }
.dash-flow-line { position: absolute; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .45; transform-origin: left center; }
.dash-flow-line--one { top: 62px; left: 58px; width: 76px; transform: rotate(18deg); }
.dash-flow-line--two { top: 98px; left: 154px; width: 72px; transform: rotate(-24deg); }
.dash-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.stat-card {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-value--sm { font-size: 1rem; }
.stat-label { display: block; font-size: .75rem; color: var(--text-3); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.dash-card { padding: 20px; }
.dash-card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 14px; }
.dash-card__title { font-size: 1.05rem; font-weight: 700; margin: 0 0 .2rem; }
.dash-card__subtitle { font-size: .78rem; color: var(--text-3); margin: 0; }
.dash-pipe-list { display: grid; gap: 8px; }
.dash-pipe-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
}
.dash-pipe-row:hover { border-color: var(--accent); text-decoration: none; }
.dash-pipe-row__icon { display: inline-flex; flex: none; color: var(--accent); }
.dash-pipe-row__main { flex: 1 1 auto; min-width: 0; }
.dash-pipe-row__main b, .dash-pipe-row__main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-pipe-row__main small { color: var(--text-3); }
.dash-pipe-row__meta { display: grid; justify-items: end; gap: 2px; flex: none; }
.dash-pipe-row__meta small { color: var(--text-3); }
.dash-pipe-row__go { display: inline-flex; color: var(--text-3); }
.dash-empty { padding: 28px 12px; text-align: center; color: var(--text-3); }
.dash-empty__icon { display: inline-flex; color: var(--text-3); }
.dash-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.dash-steps li { display: flex; gap: .7rem; align-items: flex-start; }
.dash-steps li > span { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 700; }
.dash-steps b, .dash-steps small { display: block; }
.dash-steps small { color: var(--text-3); }
@media (max-width: 991px) {
    .dash-hero__art { display: none; }
    .dash-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 575px) {
    .dashboard-shell { padding: 18px 12px 36px; }
    .dash-hero { padding: 22px 18px; }
    .dash-hero .page-title { font-size: 1.5rem; }
}
