:root {
    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, .84);
    --surface-solid: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(15, 23, 42, .09);
    --accent: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --sidebar: #ffffff;
}

[data-theme="dark"] {
    --bg: #0B1120;
    --surface: rgba(30, 41, 59, .78);
    --surface-solid: #1E293B;
    --text: #e5eefc;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, .18);
    --accent: #3B82F6;
    --success: #22C55E;
    --danger: #EF4444;
    --sidebar: #111827;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, .16), transparent 32rem),
        linear-gradient(135deg, var(--bg), var(--bg));
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a { color: inherit; }
.text-muted { color: var(--muted) !important; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    flex: 0 0 280px;
    min-height: 100vh;
    padding: 1.25rem;
    position: sticky;
    top: 0;
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #10b981);
    box-shadow: 0 0 30px rgba(37, 99, 235, .35);
}
.nav-pill {
    align-items: center;
    border-radius: 8px;
    color: var(--muted);
    display: flex;
    gap: .75rem;
    padding: .75rem .9rem;
    text-decoration: none;
    transition: .18s ease;
}
.nav-pill:hover, .nav-pill.active {
    background: rgba(59, 130, 246, .13);
    color: var(--text);
    transform: translateX(3px);
}
.main { flex: 1; min-width: 0; }
.topbar {
    backdrop-filter: blur(18px);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(2, 8, 23, .08);
}
.metric-card {
    min-height: 150px;
    overflow: hidden;
    position: relative;
}
.metric-card:after {
    background: linear-gradient(135deg, rgba(59, 130, 246, .2), rgba(34, 197, 94, .12));
    content: "";
    height: 120px;
    position: absolute;
    right: -30px;
    top: -40px;
    transform: rotate(18deg);
    width: 120px;
}
.btn-accent {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-color: #fff;
}
.form-control, .form-select {
    background-color: var(--surface-solid);
    border-color: var(--border);
    color: var(--text);
}
.table { --bs-table-color: var(--text); --bs-table-bg: transparent; }
.badge-soft { background: rgba(59, 130, 246, .14); color: var(--accent); }
.avatar {
    align-items: center;
    background: linear-gradient(135deg, #2563eb, #14b8a6);
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-weight: 700;
    height: 38px;
    justify-content: center;
    width: 38px;
}
.empty-state {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
}
.auth-card { max-width: 460px; width: 100%; }
.builder-frame { height: calc(100vh - 220px); min-height: 620px; border: 1px solid var(--border); }
.page-loader {
    background: var(--bg);
    inset: 0;
    position: fixed;
    z-index: 2000;
    display: grid;
    place-items: center;
    transition: opacity .3s ease, visibility .3s ease;
}
.page-loader.loaded { opacity: 0; visibility: hidden; }

@media (max-width: 991.98px) {
    .app-shell { display: block; }
    .sidebar {
        min-height: auto;
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 50;
        width: 280px;
    }
    .sidebar.show { transform: translateX(0); }
}
