html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    /* Radzen 11.3.2's own theme CSS only sets this (":root:has(.rz-layout) body { color:
       var(--rz-text-color); background-color: var(--rz-body-background-color); ... }") when the
       page uses Radzen's own <RadzenLayout>. This app uses its own hand-rolled .app-layout shell
       instead, so that selector never matches and plain text (headings, paragraphs, labels —
       anything outside a themed Radzen component) silently fell back to the browser default black
       text color. That's invisible in the light theme (black-on-white) but unreadable in
       standard-dark (black-on-near-black) — this is the actual root cause of the "page headings
       and body text stay dark on dark background" defect. Body background is already handled by
       a separate, unscoped decorative rule in the same theme CSS, so only color needs setting
       here. */
    color: var(--rz-text-color);
}

.app-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "header header"
        "sidebar content"
        "footer footer";
    min-height: 100vh;
}

.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    /* Deliberately the same always-dark background/light text as RadzenPanelMenu's own sidebar
       (--rz-sidebar-background-color / --rz-sidebar-color are white in BOTH the standard and
       standard-dark themes — Radzen's sidebar is designed to stay dark regardless of the active
       theme), so the header stays readable without needing per-theme overrides. */
    background: var(--rz-sidebar-background-color);
    color: var(--rz-sidebar-color);
}

.app-header .app-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.app-header .app-logo {
    height: 28px;
}

.app-header .app-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.app-header .app-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-header .app-username {
    font-size: 0.9rem;
}

.app-header .app-console-link {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--rz-primary), var(--rz-primary-light));
    color: var(--rz-on-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
}

.app-sidebar {
    grid-area: sidebar;
    /* Same always-dark background/light text as .app-header above, and as RadzenPanelMenu's own
       item colors — keeps the search box's surrounding rail (outside the RadzenPanelMenu itself)
       consistent with it in both themes instead of showing through the ambient (theme-dependent)
       body background. */
    background: var(--rz-sidebar-background-color);
    color: var(--rz-sidebar-color);
    border-right: 1px solid var(--rz-border-color);
    overflow-y: auto;
    padding: 0.5rem;
}

.app-sidebar .app-search {
    padding: 0.25rem 0.25rem 0.75rem;
}

.app-content {
    grid-area: content;
    padding: 1rem;
    overflow: auto;
}

.app-footer {
    grid-area: footer;
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--rz-text-secondary-color);
    border-top: 1px solid var(--rz-border-color);
}

.nav-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

.text-danger {
    color: var(--rz-danger);
}

/* Manage/Endpoint & Manage/DataStore pages (phase 1): Radzen's standard-base theme ships
   rz-display-flex/rz-mb-*/rz-p-*/etc. utility classes but no flex-wrap or monospace helper. */
.rz-flex-wrap {
    flex-wrap: wrap;
}

.font-monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "sidebar"
            "content"
            "footer";
    }

    .app-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--rz-border-color);
        max-height: 40vh;
    }

    .app-footer {
        flex-direction: column;
        gap: 0.15rem;
    }
}
