:root,
html[data-theme="light"],
html[data-theme="dark"] {
    --primary: #155eef;
    --secondary: #13243b;
    --accent: #60a5fa;
    --primary-fg: #f8fafc;
    --body-fg: #e6edf7;
    --body-bg: #06111f;
    --body-quiet-color: #94a3b8;
    --body-medium-color: #c2ccda;
    --body-loud-color: #f8fafc;
    --header-color: #f8fafc;
    --header-branding-color: #f8fafc;
    --header-bg: #071525;
    --header-link-color: #dbeafe;
    --breadcrumbs-fg: #94a3b8;
    --breadcrumbs-link-fg: #cbd5e1;
    --breadcrumbs-bg: transparent;
    --link-fg: #4f9cff;
    --link-hover-color: #7db7ff;
    --link-selected-fg: #8bc0ff;
    --hairline-color: #1c3047;
    --border-color: #24384f;
    --error-fg: #fca5a5;
    --message-success-bg: #073b2b;
    --message-warning-bg: #422d0a;
    --message-error-bg: #481b25;
    --darkened-bg: #0a1829;
    --selected-bg: #102b55;
    --selected-row: #0d2139;
    --button-fg: #fff;
    --button-bg: #155eef;
    --button-hover-bg: #2872ff;
    --default-button-bg: #155eef;
    --default-button-hover-bg: #2872ff;
    --delete-button-bg: #a33243;
    --delete-button-hover-bg: #c24155;
    --object-tools-fg: #fff;
    --object-tools-bg: #155eef;
    --object-tools-hover-bg: #2872ff;
    color-scheme: dark;
}

html,
body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at 78% 0%, rgba(22, 94, 239, 0.08), transparent 34rem),
        #06111f;
    color: var(--body-fg);
    font-family: Arial, Helvetica, sans-serif;
}

/* Krumli uses color, controls and focus states for interaction—not underlines. */
body a,
body a:link,
body a:visited,
body a:hover,
body a:focus,
body a:active {
    text-decoration: none !important;
}

body:not(.login) #container {
    box-sizing: border-box;
    min-height: 100vh;
    padding-left: 252px;
}

body:not(.login) #header.krumli-sidebar {
    align-items: stretch;
    background: #071525 url("../brand/page-menu-background.338f4ba60a92.png") center / auto 100% no-repeat;
    border-right: 1px solid #20344b;
    bottom: auto;
    box-sizing: border-box;
    color: #e5edf8;
    display: flex;
    flex-direction: column;
    left: 0;
    height: min(100vh, 1024px);
    max-height: 1024px;
    padding: 26px 14px 18px;
    position: fixed;
    top: 0;
    width: 252px;
    z-index: 50;
}

.krumli-branding {
    margin: 0 8px 28px;
}

.krumli-branding img {
    display: block;
    filter: brightness(0) invert(1);
    height: auto;
    max-width: 190px;
    width: 100%;
}

.krumli-global-nav {
    display: grid;
    gap: 5px;
}

.krumli-global-nav a {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #d6e0ed;
    display: flex;
    font-size: 0.9rem;
    gap: 11px;
    min-height: 38px;
    padding: 0 11px;
    text-decoration: none;
}

.krumli-global-nav a span {
    color: #a9b8ca;
    display: inline-grid;
    font-size: 1rem;
    place-items: center;
    width: 20px;
}

.krumli-global-nav a:hover,
.krumli-global-nav a:focus-visible {
    background: rgba(39, 91, 168, 0.18);
    color: #fff;
}

.krumli-global-nav a.active {
    background: linear-gradient(135deg, #155eef, #1644ad);
    border-color: rgba(96, 165, 250, 0.32);
    box-shadow: 0 8px 24px rgba(0, 70, 200, 0.18);
    color: #fff;
}

.krumli-global-nav a.active span {
    color: #fff;
}

.krumli-nav-label {
    color: #78899f;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    margin: 26px 12px 8px;
    text-transform: uppercase;
}

.krumli-sidebar-spacer {
    flex: 1 1 40px;
    min-height: 30px;
}

.krumli-user-card {
    align-items: center;
    background: rgba(8, 25, 43, 0.88);
    border: 1px solid #20364e;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    padding: 11px;
}

.krumli-user-card strong,
.krumli-user-card span {
    display: block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.krumli-user-card strong {
    color: #f8fafc;
    font-size: 0.82rem;
}

.krumli-user-card span {
    color: #91a2b8;
    font-size: 0.72rem;
    margin-top: 3px;
}

.krumli-avatar {
    align-items: center;
    background: #1d2d43;
    border: 1px solid #344a63;
    border-radius: 50%;
    color: #fff;
    display: flex;
    flex: 0 0 34px;
    font-size: 0.78rem;
    height: 34px;
    justify-content: center;
    text-transform: uppercase;
}

.krumli-sidebar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 10px 5px 0;
}

.krumli-sidebar-actions a,
.krumli-sidebar-actions button {
    background: transparent;
    border: 0;
    color: #91a2b8;
    cursor: pointer;
    font: inherit;
    font-size: 0.69rem;
    margin: 0;
    padding: 0;
    text-decoration: none;
}

.krumli-sidebar-actions a:hover,
.krumli-sidebar-actions button:hover {
    color: #fff;
}

.krumli-agent-launcher {
    align-items: center;
    background: linear-gradient(135deg, #1768f4, #1649bd);
    border: 1px solid #367cf1;
    border-radius: 999px;
    bottom: 22px;
    box-shadow: 0 12px 32px rgba(0, 53, 145, 0.35);
    color: #fff;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    gap: 9px;
    padding: 8px 14px 8px 9px;
    position: fixed;
    right: 22px;
    z-index: 80;
}

.krumli-agent-mini,
.krumli-agent-avatar {
    background: #050b13;
    border: 2px solid #dbe9f8;
    box-shadow: 0 0 18px rgba(38, 139, 255, 0.35);
    display: inline-block;
    position: relative;
}

.krumli-agent-mini { border-radius: 10px; height: 23px; width: 27px; }
.krumli-agent-mini i,
.krumli-agent-avatar i { background: #39bfff; border-radius: 999px; position: absolute; }
.krumli-agent-mini i { height: 3px; top: 9px; width: 6px; }
.krumli-agent-mini i:first-child { left: 5px; }
.krumli-agent-mini i:last-child { right: 5px; }

.krumli-agent-drawer {
    background: #0b1828;
    border-left: 1px solid #263b52;
    bottom: 0;
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.28);
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    position: fixed;
    right: 0;
    top: 0;
    transform: translateX(102%);
    transition: transform 180ms ease;
    width: min(380px, 100vw);
    z-index: 90;
}

.krumli-agent-open .krumli-agent-drawer { transform: translateX(0); }
.krumli-agent-open .krumli-agent-launcher { opacity: 0; pointer-events: none; }

.krumli-agent-drawer > header {
    align-items: center;
    border-bottom: 1px solid #20344b;
    display: flex;
    justify-content: space-between;
    padding: 18px;
}

.krumli-agent-identity { align-items: center; display: flex; gap: 12px; }
.krumli-agent-identity strong,
.krumli-agent-identity small { display: block; }
.krumli-agent-identity strong { color: #fff; font-size: 0.95rem; }
.krumli-agent-identity small { color: #8fa0b5; font-size: 0.72rem; margin-top: 3px; }
.krumli-agent-avatar { border-radius: 16px; height: 42px; width: 48px; }
.krumli-agent-avatar i { height: 4px; top: 17px; width: 10px; }
.krumli-agent-avatar i:first-child { left: 8px; }
.krumli-agent-avatar i:nth-child(2) { right: 8px; }
.krumli-agent-avatar b { border-bottom: 2px solid #39bfff; border-radius: 50%; bottom: 8px; height: 5px; left: 18px; position: absolute; width: 12px; }

.krumli-agent-controls { display: flex; gap: 5px; }
.krumli-agent-controls button,
.krumli-agent-controls a {
    align-items: center;
    background: transparent;
    border: 0;
    color: #93a5ba;
    cursor: pointer;
    display: flex;
    font-size: 1.25rem;
    height: 34px;
    justify-content: center;
    padding: 0;
    text-decoration: none;
    width: 34px;
}
.krumli-agent-controls button:hover,
.krumli-agent-controls a:hover,
.krumli-agent-controls button.is-active { color: #56a3ff; }

.krumli-agent-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 20px 18px;
}
.krumli-agent-message {
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.55;
    max-width: 88%;
    padding: 11px 13px;
    white-space: pre-wrap;
}
.krumli-agent-message.is-agent { align-self: flex-start; background: #12243a; border: 1px solid #213a55; color: #dce7f4; }
.krumli-agent-message.is-user { align-self: flex-end; background: #155eef; color: #fff; }
.krumli-agent-message.is-pending { color: #8fa0b5; }
.krumli-agent-message.is-error { border-color: #7e3040; color: #fca5a5; }
.krumli-agent-error-action { color: #7db7ff; display: block; font-weight: 600; margin-top: 9px; }

.krumli-agent-composer {
    align-items: flex-end;
    border-top: 1px solid #20344b;
    display: flex;
    gap: 8px;
    padding: 14px;
}
.krumli-agent-composer textarea { box-sizing: border-box; max-height: 150px; min-height: 48px; resize: vertical; width: 100%; }
.krumli-agent-composer button { align-items: center; display: flex; height: 48px; justify-content: center; min-width: 48px; padding: 0; }
.krumli-agent-drawer > footer { color: #697d94; font-size: 0.65rem; padding: 0 18px 15px; text-align: center; }

@media (min-width: 1280px) {
    body.krumli-agent-pinned:not(.login) #container { padding-right: 380px; }
    body.krumli-agent-pinned .krumli-agent-drawer { transform: translateX(0); }
}

body:not(.login) nav[aria-label="Breadcrumbs"] {
    background: rgba(6, 17, 31, 0.82);
    border-bottom: 1px solid #162a40;
    min-height: 48px;
}

body:not(.login) .breadcrumbs {
    background: transparent;
    color: #7f91a8;
    font-size: 0.8rem;
    padding: 16px 34px;
}

body:not(.login) .main,
body:not(.login) main.content {
    background: transparent;
}

body:not(.login) #content {
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    max-width: 1500px;
    padding: 28px 34px 48px;
    width: 100%;
}

/* Django's stock dashboard stylesheet fixes #content at 600px. */
body:not(.login).dashboard #content {
    width: 100%;
}

h1,
h2,
h3,
h4,
h5 {
    color: #f8fafc;
    font-family: Arial, Helvetica, sans-serif;
}

h1 {
    font-size: 1.65rem;
    font-weight: 600;
}

.module,
.inline-group,
.connection-section,
.flowhub-home-section,
.flowhub-settings-section {
    background: rgba(10, 25, 43, 0.82);
    border: 1px solid #20344b;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

table {
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    background: #0c1c2f;
    border-bottom: 1px solid #23384f;
    color: #aebdd0;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: none;
}

tbody tr {
    background: transparent;
}

tbody tr:hover {
    background: rgba(34, 75, 126, 0.13);
}

td,
th {
    border-color: #1d3147;
}

input,
textarea,
select,
.vTextField {
    background: #09182a;
    border: 1px solid #2a3d54;
    border-radius: 7px;
    color: #eef4fb;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #3982ff;
    box-shadow: 0 0 0 3px rgba(57, 130, 255, 0.14);
    outline: 0;
}

.button,
input[type="submit"],
input[type="button"],
.submit-row input,
a.button {
    border-radius: 7px;
    font-weight: 600;
}

.messagelist {
    margin: 0 34px 18px;
    padding-top: 18px;
}

.messagelist li {
    border-radius: 7px;
}

@media (max-width: 900px) {
    body:not(.login) #container {
        padding-left: 0;
        padding-top: 64px;
    }

    body:not(.login) #header.krumli-sidebar {
        align-items: center;
        background-image: none;
        border-bottom: 1px solid #20344b;
        border-right: 0;
        bottom: auto;
        flex-direction: row;
        height: 64px;
        overflow-x: auto;
        padding: 10px 16px;
        right: 0;
        width: auto;
    }

    .krumli-branding {
        flex: 0 0 150px;
        margin: 0 12px 0 0;
    }

    .krumli-global-nav {
        display: flex;
        flex: 0 0 auto;
    }

    .krumli-global-nav a {
        min-height: 40px;
        white-space: nowrap;
    }

    .krumli-settings-nav,
    .krumli-nav-label,
    .krumli-sidebar-spacer,
    .krumli-user-card,
    .krumli-sidebar-actions {
        display: none;
    }

    .krumli-agent-controls [data-krumli-agent-pin] { display: none; }

    body:not(.login) #content {
        padding: 22px 18px 40px;
    }

    body:not(.login) .breadcrumbs {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (max-width: 560px) {
    .krumli-branding {
        flex-basis: 118px;
    }

    .krumli-global-nav a {
        font-size: 0;
        gap: 0;
        padding: 0 10px;
    }

    .krumli-global-nav a span {
        font-size: 1.05rem;
    }
}
