:root {
    --ai-bg: #f5f7fb;
    --ai-bg-soft: #eef3fb;
    --ai-surface: #ffffff;
    --ai-surface-2: #f8fafc;
    --ai-text: #0b1220;
    --ai-text-soft: #334155;
    --ai-muted: #64748b;
    --ai-border: #e2e8f0;
    --ai-border-strong: #cbd5e1;
    --ai-sidebar: #07111f;
    --ai-sidebar-2: #0b1730;
    --ai-primary: #2563eb;
    --ai-primary-2: #06b6d4;
    --ai-primary-dark: #1d4ed8;
    --ai-purple: #7c3aed;
    --ai-success: #16a34a;
    --ai-warning: #f59e0b;
    --ai-danger: #dc2626;
    --ai-info: #0891b2;
    --ai-radius-sm: 10px;
    --ai-radius: 16px;
    --ai-radius-lg: 24px;
    --ai-shadow-sm: 0 6px 18px rgba(15, 23, 42, .06);
    --ai-shadow: 0 16px 45px rgba(15, 23, 42, .10);
    --ai-sidebar-width: 292px;
    --ai-topbar-height: 92px;
    --ai-focus: 0 0 0 .22rem rgba(37, 99, 235, .18);
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .10), transparent 34rem),
        radial-gradient(circle at top right, rgba(6, 182, 212, .10), transparent 28rem),
        var(--ai-bg);
    color: var(--ai-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ai-primary); }
a:hover { color: var(--ai-primary-dark); }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    width: calc(100% - var(--ai-sidebar-width));
    min-height: 100vh;
    margin-left: var(--ai-sidebar-width);
}

.app-content {
    padding: 30px;
    max-width: 1680px;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--ai-sidebar-width);
    min-height: 100vh;
    overflow: hidden;
    color: #e5eefc;
    background:
        linear-gradient(180deg, rgba(7, 17, 31, .98), rgba(9, 20, 42, .98)),
        radial-gradient(circle at 20% 0%, rgba(37, 99, 235, .45), transparent 18rem);
    border-right: 1px solid rgba(148, 163, 184, .12);
    box-shadow: 18px 0 55px rgba(15, 23, 42, .22);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 22px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 8px 10px 20px;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand:hover { color: #fff; }

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 1), rgba(6, 182, 212, 1));
    box-shadow: 0 15px 35px rgba(37, 99, 235, .32);
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 13px;
}

.brand-mark span {
    font-weight: 900;
    letter-spacing: -.04em;
    z-index: 1;
}

.brand-copy strong {
    display: block;
    color: #fff;
    font-size: 1.05rem;
    letter-spacing: -.03em;
}

.brand-copy small {
    display: block;
    color: #93a4bd;
    font-size: .75rem;
    font-weight: 700;
}

.sidebar-tenant-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 6px 18px;
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 18px;
    background: rgba(15, 23, 42, .62);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.tenant-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34, 197, 94, .12);
}

.tenant-label {
    color: #8ea2bf;
    font-size: .70rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 800;
}

.tenant-name {
    max-width: 205px;
    color: #f8fafc;
    font-size: .86rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 2px 6px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, .32) transparent;
}

.sidebar-section {
    margin: 20px 10px 8px;
    color: #7689a6;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 900;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 11px 12px;
    border-radius: 14px;
    color: #c7d4e8;
    text-decoration: none;
    font-weight: 750;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(148, 163, 184, .11);
    transform: translateX(2px);
}

.sidebar-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(37, 99, 235, .95), rgba(6, 182, 212, .78));
    box-shadow: 0 16px 32px rgba(37, 99, 235, .24);
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 11px;
    bottom: 11px;
    width: 4px;
    border-radius: 999px;
    background: #67e8f9;
}

.nav-glyph {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 24px;
    background: rgba(148, 163, 184, .14);
    border: 1px solid rgba(148, 163, 184, .12);
}

.nav-glyph::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: currentColor;
    opacity: .95;
}

.glyph-ai::before { border-radius: 999px; box-shadow: 0 -6px 0 -3px currentColor, 0 6px 0 -3px currentColor; }
.glyph-risk::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.glyph-vault::before { width: 12px; height: 8px; border-radius: 2px; }
.glyph-docs::before { width: 9px; height: 12px; border-radius: 2px; }
.glyph-controls::before { clip-path: polygon(45% 75%, 90% 15%, 100% 25%, 48% 90%, 0 52%, 10% 42%); border-radius: 0; }
.glyph-audit::before { width: 13px; height: 13px; border-radius: 999px; background: transparent; border: 3px solid currentColor; }
.glyph-report::before { width: 12px; height: 12px; border-radius: 2px 2px 0 0; }
.glyph-users::before { width: 12px; height: 8px; border-radius: 999px 999px 3px 3px; }
.glyph-license::before { width: 14px; height: 9px; border-radius: 3px; }

.sidebar-footer {
    padding: 14px 6px 0;
    border-top: 1px solid rgba(148, 163, 184, .12);
}

.compliance-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 12px;
    border-radius: 999px;
    color: #c7d2fe;
    background: rgba(37, 99, 235, .12);
    border: 1px solid rgba(96, 165, 250, .20);
    font-size: .78rem;
    font-weight: 800;
}

.chip-pulse {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #38bdf8;
    box-shadow: 0 0 0 6px rgba(56, 189, 248, .12);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--ai-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 30px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226, 232, 240, .86);
}

.topbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 16px;
}

.page-heading { min-width: 0; }

.page-eyebrow {
    color: var(--ai-primary);
    font-size: .70rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 900;
}

.page-title {
    margin: 0;
    color: #0f172a;
    font-size: 1.34rem;
    line-height: 1.12;
    font-weight: 900;
    letter-spacing: -.035em;
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--ai-muted);
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-search {
    position: relative;
    width: min(380px, 30vw);
}

.topbar-search input {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 42px;
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    background: rgba(248, 250, 252, .88);
    color: var(--ai-text);
    outline: 0;
    transition: border .18s ease, box-shadow .18s ease, background .18s ease;
}

.topbar-search input:focus {
    background: #fff;
    border-color: rgba(37, 99, 235, .48);
    box-shadow: var(--ai-focus);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    width: 13px;
    height: 13px;
    transform: translateY(-50%);
    border: 2px solid #94a3b8;
    border-radius: 999px;
}
.search-icon::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: -5px;
    width: 7px;
    height: 2px;
    background: #94a3b8;
    transform: rotate(45deg);
    border-radius: 999px;
}

.icon-button {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--ai-border);
    box-shadow: var(--ai-shadow-sm);
}
.icon-button::before {
    content: "";
    width: 14px;
    height: 16px;
    border: 2px solid #475569;
    border-radius: 9px 9px 5px 5px;
}
.notification-dot {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--ai-danger);
    border: 2px solid #fff;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 7px 4px 4px;
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    background: #fff;
    box-shadow: var(--ai-shadow-sm);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    font-size: .82rem;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-purple));
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 170px;
}
.user-meta strong,
.user-meta small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.user-meta strong { color: #0f172a; font-size: .82rem; }
.user-meta small { color: var(--ai-muted); font-size: .72rem; }
.user-chevron {
    width: 7px;
    height: 7px;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    transform: rotate(45deg) translateY(-2px);
    margin-right: 6px;
}

.sidebar-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--ai-border);
    border-radius: 13px;
    background: #fff;
    box-shadow: var(--ai-shadow-sm);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
}
.sidebar-toggle span {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 999px;
    background: #0f172a;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .52);
    z-index: 1030;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}

.app-alert {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--ai-shadow-sm);
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .20), transparent 28rem),
        radial-gradient(circle at bottom right, rgba(6, 182, 212, .16), transparent 30rem),
        #07111f;
}

@media (max-width: 1200px) {
    .topbar-search { display: none; }
}

@media (max-width: 992px) {
    .app-sidebar {
        transform: translateX(-105%);
        transition: transform .22s ease;
    }

    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .app-backdrop { opacity: 1; pointer-events: auto; }

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle { display: inline-flex; }

    .app-topbar { padding: 0 18px; height: 78px; }
    .page-subtitle, .page-eyebrow { display: none; }
    .page-title { font-size: 1.12rem; }
    .app-content { padding: 20px; }
    .user-meta, .user-chevron { display: none; }
}

@media (max-width: 576px) {
    .topbar-actions { gap: 8px; }
    .icon-button { display: none; }
    .app-content { padding: 16px; }
}
