:root {
    --navy: #294765;
    --navy-deep: #223d58;
    --navy-soft: #3f5f7f;
    --page: #f3f6fb;
    --card: #ffffff;
    --line: #dbe4ef;
    --text: #07152f;
    --muted: #64748b;
    --blue: #338bcc;
    --green: #11825d;
    --amber: #c98313;
    --red: #c83b4a;
}

body {
    background: var(--page);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

code {
    color: #c21d65;
    white-space: normal;
    word-break: break-word;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    transition: grid-template-columns .2s ease;
}

.app-sidebar {
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #fff;
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}

.sidebar-collapsed .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar-collapsed .app-sidebar {
    padding-inline: 14px;
    align-items: center;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .side-nav span,
.sidebar-collapsed .user-chip span:not(.avatar),
.sidebar-collapsed .sidebar-footer form {
    display: none;
}

.sidebar-collapsed .side-nav a {
    width: 56px;
    height: 52px;
    justify-content: center;
    padding: 0;
}

.sidebar-collapsed .sidebar-footer {
    justify-items: center;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    letter-spacing: .01em;
}

.sidebar-close,
.sidebar-collapse,
.menu-toggle {
    border: 0;
    background: rgba(255,255,255,.12);
    color: #fff;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: none;
    place-items: center;
}

.sidebar-collapse {
    display: grid;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #fff;
    color: var(--navy);
    font-weight: 800;
}

.brand small,
.user-chip small {
    display: block;
    color: rgba(255,255,255,.72);
    font-size: .78rem;
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: 8px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.84);
    text-decoration: none;
    padding: 14px 16px;
    border-radius: 12px;
    font-weight: 700;
}

.side-nav svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.side-nav a.active,
.side-nav a:hover {
    background: rgba(255,255,255,.13);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,.11);
    border: 1px solid rgba(255,255,255,.12);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #fff;
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 800;
}

.app-main {
    min-width: 0;
}

.topbar {
    height: 86px;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    padding: 0 44px;
    gap: 18px;
}

.menu-toggle {
    background: rgba(255,255,255,.14);
}

.sidebar-overlay {
    display: none;
}

.eyebrow {
    color: rgba(255,255,255,.68);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 800;
}

.content-wrap {
    padding: 38px 44px 56px;
    max-width: 1480px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.9rem;
    font-weight: 850;
    margin: 0;
}

.page-subtitle {
    color: var(--muted);
    margin: 6px 0 0;
}

.metric-card,
.panel-card,
.stream-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 16px 36px rgba(36, 64, 95, .06);
}

.metric-card {
    padding: 22px;
    min-height: 126px;
}

.metric-label {
    color: var(--muted);
    font-weight: 750;
    font-size: .86rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: .01em;
}

.metric-foot {
    color: var(--muted);
    font-size: .88rem;
}

.panel-card {
    padding: 22px;
}

.panel-title {
    font-weight: 800;
    margin-bottom: 14px;
}

.status-pill {
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 800;
    font-size: .78rem;
    background: #e8eef6;
    color: var(--navy);
}

.status-pill.ok {
    background: #d9f4e8;
    color: var(--green);
}

.status-pill.warn {
    background: #fff0cc;
    color: var(--amber);
}

.status-pill.danger {
    background: #ffe0e5;
    color: var(--red);
}

.status-pill.muted {
    background: #e8eef6;
    color: var(--muted);
}

.soft-alert {
    border-radius: 12px;
    border-width: 1px;
}

.table {
    --bs-table-bg: transparent;
}

.table td,
.table th {
    vertical-align: middle;
    padding: 14px 16px;
}

.table thead th {
    color: #233b54;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stream-row-link {
    color: var(--text);
    font-weight: 850;
    text-decoration: none;
}

.stream-row-link:hover {
    color: var(--blue);
}

.chart-wrap {
    height: 330px;
}

.form-control,
.form-select,
.btn {
    border-radius: 10px;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
    font-weight: 800;
}

@media (max-width: 960px) {
    body.sidebar-collapsed .app-shell,
    .app-shell {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .app-sidebar,
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 286px;
        transform: translateX(-105%);
        transition: transform .22s ease;
        border-radius: 0 20px 20px 0;
        align-items: stretch;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .side-nav span,
    body.sidebar-collapsed .user-chip span:not(.avatar),
    body.sidebar-collapsed .sidebar-footer form {
        display: initial;
    }

    body.sidebar-collapsed .side-nav a {
        width: auto;
        height: auto;
        justify-content: flex-start;
        padding: 14px 16px;
    }

    .sidebar-collapse {
        display: none;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(6, 18, 34, .45);
        z-index: 1035;
    }

    .sidebar-close,
    .menu-toggle {
        display: grid;
    }

    .topbar {
        padding: 18px;
        height: auto;
    }

    .content-wrap {
        padding: 24px 18px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
    }
}
