html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f6f6fa;
}

.brainyx-main {
    background: #f6f6fa;
    min-height: 100vh;
    padding-top: 80px !important;
}
.mud-appbar { z-index: 1100 !important; }
.mud-drawer { z-index: 1200 !important; }

/* ===== Brainyx shell custom (HTML/CSS puro, SSR-compatible) ===== */
.bx-shell { min-height: 100vh; background: #f6f6fa; }

.bx-appbar {
    position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 1100;
    background: linear-gradient(135deg, #6E5AAA 0%, #4a3b85 100%);
    color: white; display: flex; align-items: center; padding: 0 16px; gap: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.bx-appbar-burger {
    background: transparent; border: 0; color: white; cursor: pointer;
    padding: 8px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    transition: background 120ms ease;
}
.bx-appbar-burger:hover { background: rgba(255,255,255,.15); }
.bx-appbar-brand { flex: 1; display: flex; align-items: baseline; }
.bx-appbar-actions { display: flex; align-items: center; gap: 8px; }
.bx-chip {
    background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 16px;
    font-size: .85rem; display: inline-flex; align-items: center;
}
.bx-icon-btn {
    background: transparent; border: 0; color: white; cursor: pointer;
    padding: 8px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; transition: background 120ms ease;
}
.bx-icon-btn:hover { background: rgba(255,255,255,.15); color: white; }

.bx-drawer {
    position: fixed; top: 64px; left: 0; bottom: 0; width: 260px;
    background: white; border-right: 1px solid #e2e8f0; padding: 8px;
    overflow-y: auto; z-index: 1050;
    transition: width 220ms ease;
}
.bx-drawer-brand {
    font-weight: 700; font-size: 1rem; color: #6E5AAA; padding: 12px 16px 8px 16px;
    letter-spacing: 0.04em; white-space: nowrap; overflow: hidden;
}
.bx-nav { display: flex; flex-direction: column; gap: 2px; }
.bx-navlink {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    border-radius: 8px; text-decoration: none; color: #334155; font-size: .92rem;
    transition: background 120ms ease, color 120ms ease;
    white-space: nowrap;
}
.bx-navlink:hover { background: #f1f5f9; color: #6E5AAA; }
.bx-navlink.bx-disabled { color: #cbd5e1; cursor: not-allowed; }
.bx-navlink.bx-disabled:hover { background: transparent; color: #cbd5e1; }
.bx-navlabel { transition: opacity 180ms ease; }
.bx-navgroup { border: 0; }
.bx-navgroup summary {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    border-radius: 8px; cursor: pointer; list-style: none; color: #334155; font-size: .92rem; font-weight: 500;
    transition: background 120ms ease;
}
.bx-navgroup summary::-webkit-details-marker { display: none; }
.bx-navgroup summary::marker { display: none; }
.bx-navgroup summary:hover { background: #f1f5f9; }
.bx-navchevron { margin-left: auto; transition: transform 220ms ease; font-size: 20px !important; }
.bx-navgroup[open] > summary .bx-navchevron { transform: rotate(180deg); }
.bx-subnav { padding-left: 20px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.bx-divider { height: 1px; background: #e2e8f0; margin: 12px 8px; }

.bx-main {
    margin-left: 260px; padding: 88px 24px 24px 24px;
    transition: margin-left 220ms ease;
    min-height: 100vh;
}

/* Drawer collapsed state (toggle via JS) */
body.bx-drawer-collapsed .bx-drawer { width: 64px; }
body.bx-drawer-collapsed .bx-drawer .bx-navlabel,
body.bx-drawer-collapsed .bx-drawer .bx-navchevron,
body.bx-drawer-collapsed .bx-drawer .bx-drawer-brand { opacity: 0; pointer-events: none; }
body.bx-drawer-collapsed .bx-main { margin-left: 64px; }
body.bx-drawer-collapsed .bx-drawer:hover { width: 260px; }
body.bx-drawer-collapsed .bx-drawer:hover .bx-navlabel,
body.bx-drawer-collapsed .bx-drawer:hover .bx-navchevron,
body.bx-drawer-collapsed .bx-drawer:hover .bx-drawer-brand { opacity: 1; pointer-events: auto; }

/* ===== Filters bar ===== */
.bx-filters {
    background: white; border-radius: 12px; padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(15,23,42,.05); margin-bottom: 16px;
    position: sticky; top: 72px; z-index: 90;
}
.bx-filters-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.bx-filters-icon { color: #6E5AAA; font-size: 20px; }
.bx-select {
    background: white; border: 1px solid #cbd5e1; border-radius: 8px;
    padding: 6px 28px 6px 12px; font-size: .9rem; color: #0f172a; cursor: pointer;
    font-family: inherit; appearance: auto;
}
.bx-select:focus { outline: none; border-color: #6E5AAA; box-shadow: 0 0 0 3px rgba(110,90,170,.15); }
.bx-date {
    background: white; border: 1px solid #cbd5e1; border-radius: 8px;
    padding: 6px 10px; font-size: .9rem; color: #0f172a; font-family: inherit;
}
.bx-date:focus { outline: none; border-color: #6E5AAA; box-shadow: 0 0 0 3px rgba(110,90,170,.15); }
.bx-sep { color: #94a3b8; font-weight: 600; }
.bx-range-label { color: #64748b; font-size: .85rem; }
.bx-filter-btn {
    background: white; border: 1px solid #cbd5e1; border-radius: 20px;
    padding: 6px 14px; font-size: .85rem; color: #475569; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.bx-filter-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.bx-filter-btn.active { background: #6E5AAA; border-color: #6E5AAA; color: white; }
.bx-filter-btn.danger { color: #dc2626; border-color: #fecaca; }
.bx-filter-btn.danger:hover { background: #fef2f2; border-color: #dc2626; }
.bx-filter-chips {
    margin-top: 12px; padding-top: 12px; border-top: 1px solid #e2e8f0;
    display: flex; flex-wrap: wrap; gap: 6px;
}
.bx-chip {
    background: white; border: 1px solid #cbd5e1; border-radius: 16px;
    padding: 4px 12px; font-size: .8rem; color: #475569; cursor: pointer;
    font-family: inherit; transition: all 120ms ease;
}
.bx-chip:hover { background: #f1f5f9; border-color: #94a3b8; }
.bx-chip.selected { background: #6E5AAA; border-color: #6E5AAA; color: white; }
.bx-chip-meta { opacity: .6; font-size: .7rem; margin-left: 4px; }

/* ===== TV / Wallboard mode ===== */
.tv-shell {
    min-height: 100vh; background: #f6f6fa; color: #0f172a;
    display: flex; flex-direction: column; font-family: 'Inter', sans-serif;
}
.tv-shell.tv-dark { background: #0f172a; color: #f1f5f9; }

.tv-header {
    display: flex; align-items: center; gap: 16px; padding: 12px 24px;
    background: linear-gradient(135deg, #6E5AAA 0%, #4a3b85 100%);
    color: white; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.tv-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.3rem; letter-spacing: 0.04em; }
.tv-tenant { font-size: .8rem; opacity: .8; font-weight: 400; letter-spacing: 0; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.3); }
.tv-tab-row { display: flex; gap: 8px; flex: 1; justify-content: center; }
.tv-tab {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: white;
    padding: 8px 18px; border-radius: 24px; cursor: pointer; font-family: inherit; font-size: .9rem;
    display: inline-flex; align-items: center; gap: 8px; transition: all 120ms ease;
}
.tv-tab:hover { background: rgba(255,255,255,.18); }
.tv-tab.active { background: #FFD93D; border-color: #FFD93D; color: #0f172a; font-weight: 600; }
.tv-controls { display: flex; align-items: center; gap: 8px; }
.tv-clock { font-family: 'JetBrains Mono', monospace; font-size: .9rem; opacity: .9; margin-right: 8px; }
.tv-btn {
    background: rgba(255,255,255,.1); border: 0; color: white; cursor: pointer;
    padding: 6px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.tv-btn:hover { background: rgba(255,255,255,.2); }

.tv-progress { height: 3px; background: rgba(110,90,170,.15); }
.tv-progress-bar { height: 100%; background: #FFD93D; transition: width 1s linear; }

.tv-main { flex: 1; padding: 24px 32px; overflow: auto; }
.tv-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 60vh; color: inherit; opacity: .6;
}
.tv-spinner {
    width: 56px; height: 56px; border: 5px solid rgba(110,90,170,.2);
    border-top-color: #6E5AAA; border-radius: 50%; animation: tv-spin 1s linear infinite;
    margin-bottom: 16px;
}
@keyframes tv-spin { to { transform: rotate(360deg); } }

.tv-grid { display: flex; flex-direction: column; gap: 20px; }
.tv-kpi-band { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.tv-kpi-mega {
    background: white; border-radius: 14px; padding: 24px;
    box-shadow: 0 4px 16px rgba(15,23,42,.08);
    border-top: 4px solid #6E5AAA;
}
.tv-dark .tv-kpi-mega { background: #1e293b; border-top-color: #FFD93D; }
.tv-kpi-label { font-size: .85rem; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; font-weight: 600; }
.tv-dark .tv-kpi-label { color: #94a3b8; }
.tv-kpi-value { font-size: 2.6rem; font-weight: 700; line-height: 1.1; margin-top: 6px; color: #0f172a; }
.tv-dark .tv-kpi-value { color: white; }
.tv-kpi-sub { font-size: .85rem; color: #64748b; margin-top: 8px; }
.tv-dark .tv-kpi-sub { color: #94a3b8; }

.tv-up { color: #16a34a !important; font-weight: 600; }
.tv-down { color: #dc2626 !important; font-weight: 600; }
.tv-up-bg { background: #16a34a; }
.tv-warn-bg { background: #f59e0b; }
.tv-down-bg { background: #dc2626; }

.tv-panels-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tv-panel {
    background: white; border-radius: 14px; padding: 20px;
    box-shadow: 0 4px 16px rgba(15,23,42,.08);
}
.tv-dark .tv-panel { background: #1e293b; }
.tv-panel-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; }
.tv-panel-insight { border-left: 5px solid #FFD93D; padding-left: 24px; }
.tv-insight-title { font-size: 1.4rem; font-weight: 700; margin: 8px 0; color: #6E5AAA; }
.tv-dark .tv-insight-title { color: #FFD93D; }
.tv-insight-summary { font-size: 1.05rem; line-height: 1.5; opacity: .85; }

.tv-rank-list { display: flex; flex-direction: column; gap: 10px; }
.tv-rank-item { display: grid; grid-template-columns: 1fr 2fr auto; gap: 12px; align-items: center; }
.tv-rank-name { font-weight: 600; font-size: .95rem; }
.tv-rank-team { opacity: .6; font-weight: 400; font-size: .8rem; }
.tv-rank-bar { background: rgba(110,90,170,.1); border-radius: 10px; height: 18px; overflow: hidden; position: relative; }
.tv-dark .tv-rank-bar { background: rgba(255,255,255,.08); }
.tv-rank-fill { height: 100%; border-radius: 10px; transition: width 400ms ease; }
.tv-rank-pct { font-weight: 700; font-size: 1rem; min-width: 60px; text-align: right; }

.tv-footer {
    padding: 12px 24px; background: rgba(110,90,170,.08); display: flex; gap: 16px;
    font-size: .85rem; color: #64748b; border-top: 1px solid #e2e8f0;
}
.tv-dark .tv-footer { background: rgba(15,23,42,.5); color: #94a3b8; border-top-color: #334155; }
.tv-spacer { flex: 1; }

/* ===== Dark mode (body.bx-dark) ===== */
body.bx-dark { background: #0f172a; color: #f1f5f9; }
body.bx-dark .bx-shell { background: #0f172a; }
body.bx-dark .bx-drawer { background: #1e293b; border-right-color: #334155; }
body.bx-dark .bx-drawer-brand { color: #FFD93D; }
body.bx-dark .bx-navlink { color: #cbd5e1; }
body.bx-dark .bx-navlink:hover { background: #334155; color: #FFD93D; }
body.bx-dark .bx-navlink.bx-disabled { color: #475569; }
body.bx-dark .bx-navgroup summary { color: #cbd5e1; }
body.bx-dark .bx-navgroup summary:hover { background: #334155; }
body.bx-dark .bx-divider { background: #334155; }
body.bx-dark .bx-main { background: #0f172a; color: #f1f5f9; }

body.bx-dark .mud-paper,
body.bx-dark .mud-card,
body.bx-dark .mud-table-container { background-color: #1e293b !important; color: #f1f5f9 !important; }
body.bx-dark .mud-table-cell, body.bx-dark .mud-table-cell * { color: #f1f5f9 !important; }
body.bx-dark .mud-table-head .mud-table-cell, body.bx-dark .mud-table-head .mud-table-cell * { color: #94a3b8 !important; }
body.bx-dark .mud-table-row:hover { background: #334155 !important; }
body.bx-dark .mud-typography { color: #f1f5f9; }
body.bx-dark .mud-typography-caption { color: #94a3b8 !important; }
body.bx-dark .mud-chip-filled { background: #334155; color: #f1f5f9; }
body.bx-dark .mud-progress-linear .mud-progress-linear-bar { background-color: #FFD93D; }
body.bx-dark .mud-expand-panel { background: #1e293b; color: #f1f5f9; }
body.bx-dark .mud-input-control input { color: #f1f5f9; }
body.bx-dark .mud-divider { border-color: #334155; }
body.bx-dark .mud-alert { background-color: #1e293b; color: #f1f5f9; }
body.bx-dark .mud-alert-outlined { border-color: #334155; }

body.bx-dark .kpi-card { background: #1e293b; box-shadow: 0 2px 4px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.2); }
body.bx-dark .kpi-label { color: #94a3b8; }
body.bx-dark .kpi-value { color: #f1f5f9; }

body.bx-dark .insight-card { background: #1e293b; color: #f1f5f9; }
body.bx-dark .insight-card .mud-typography { color: #f1f5f9; }

body.bx-dark .dash-card { background: #1e293b !important; }
body.bx-dark .dash-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.4); }

body.bx-dark .bx-filters { background: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
body.bx-dark .bx-select, body.bx-dark .bx-date { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.bx-dark .bx-filter-btn { background: #0f172a; color: #cbd5e1; border-color: #334155; }
body.bx-dark .bx-filter-btn:hover { background: #334155; }
body.bx-dark .bx-filter-btn.active { background: #FFD93D; color: #0f172a; border-color: #FFD93D; }
body.bx-dark .bx-chip { background: #0f172a; color: #cbd5e1; border-color: #334155; }
body.bx-dark .bx-chip:hover { background: #334155; }
body.bx-dark .bx-chip.selected { background: #FFD93D; color: #0f172a; border-color: #FFD93D; }
body.bx-dark .bx-range-label { color: #94a3b8; }
body.bx-dark .brainyx-section-header { color: #f1f5f9; }

body.bx-dark h1, body.bx-dark h2, body.bx-dark h3, body.bx-dark h4, body.bx-dark h5, body.bx-dark h6 { color: #f1f5f9; }
body.bx-dark a { color: #FFD93D; }

body.bx-dark .markdown-body { color: #f1f5f9; }
body.bx-dark .markdown-body code { background: #0f172a; color: #FFD93D; }
body.bx-dark .markdown-body pre { background: #0f172a; }

body.bx-dark .chat-bubble.assistant { background: #334155; color: #f1f5f9; }
body.bx-dark .chat-bubble.user { background: #6E5AAA; }

/* Dark icon swap in toggle button */
.bx-dark-icon-light { display: inline-flex !important; }
.bx-dark-icon-dark { display: none !important; }
body.bx-dark .bx-dark-icon-light { display: none !important; }
body.bx-dark .bx-dark-icon-dark { display: inline-flex !important; }

/* Mobile */
@media (max-width: 768px) {
    .bx-drawer { transform: translateX(-100%); }
    body:not(.bx-drawer-collapsed) .bx-drawer { transform: translateX(0); }
    .bx-main { margin-left: 0; }
}

.brainyx-brand {
    font-weight: 700;
    letter-spacing: 0.04em;
    background: linear-gradient(90deg, #6E5AAA 0%, #FFD93D 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.4rem;
}

.kpi-card {
    border-radius: 14px;
    padding: 16px 20px;
    background: white;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
    transition: transform 120ms ease;
    height: 100%;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
}
.kpi-card:hover { transform: translateY(-2px); }

.kpi-card .kpi-label { font-size: 0.85rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-card .kpi-value { font-size: 1.85rem; font-weight: 700; color: #0f172a; line-height: 1.1; }
.kpi-delta-up   { color: #16a34a; font-weight: 600; }
.kpi-delta-down { color: #dc2626; font-weight: 600; }

/* Forçar MudItem stretch — cards alinhados */
.mud-grid-item { display: flex; }
.mud-grid-item > * { width: 100%; }

.brainyx-section-header { font-weight: 600; color: #0f172a; margin: 12px 0 8px 0; }

.insight-card {
    border-left: 4px solid #6E5AAA;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
}
.insight-card.critical { border-left-color: #dc2626; }
.insight-card.warning  { border-left-color: #f59e0b; }
.insight-card.opportunity { border-left-color: #16a34a; }
.insight-card.info     { border-left-color: #6E5AAA; }

.chat-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    margin: 6px 0;
    max-width: 80%;
    line-height: 1.45;
}
.chat-bubble.user { background: #6E5AAA; color: white; margin-left: auto; }
.chat-bubble.assistant { background: #f1f5f9; color: #0f172a; margin-right: auto; }
.chat-bubble pre {
    background: rgba(0,0,0,0.04); padding: 8px; border-radius: 6px; overflow-x: auto;
}
.chat-bubble.user pre { background: rgba(255,255,255,0.15); }

.brainyx-bg-grad {
    background: linear-gradient(135deg, #6E5AAA 0%, #4a3b85 100%);
    color: white;
}

a, .btn-link { color: #6E5AAA; }

h1, h2, h3, h4, h5, h6 { color: #0f172a; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after {
    content: "Ocorreu um erro inesperado."
}

/* ===== Identity pages wrapper ===== */
.brainyx-auth-card h1,
.brainyx-auth-card h2 {
    font-size: 1.5rem !important;
    font-weight: 700;
    margin: 0 0 16px 0;
    color: #0f172a;
    border: none;
    line-height: 1.3;
}
.brainyx-auth-card h3 {
    font-size: 1.05rem !important;
    font-weight: 600;
    margin: 16px 0 12px 0;
    color: #334155;
}
.brainyx-auth-card h4 {
    font-size: 0.95rem !important;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #475569;
}
.brainyx-auth-card hr { margin: 16px 0; border-color: #e2e8f0; }
.brainyx-auth-card .form-floating { margin-bottom: 12px; }
.brainyx-auth-card .form-control {
    border-radius: 8px;
    border-color: #cbd5e1;
    font-size: 0.95rem;
    padding: 0.6rem 0.75rem;
}
.brainyx-auth-card .form-control:focus {
    border-color: #6E5AAA;
    box-shadow: 0 0 0 0.2rem rgba(110, 90, 170, 0.15);
}
.brainyx-auth-card .form-floating > label { color: #94a3b8; }
.brainyx-auth-card .btn-primary,
.brainyx-auth-card .btn-lg {
    background: #6E5AAA;
    border-color: #6E5AAA;
    border-radius: 8px;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}
.brainyx-auth-card .btn-primary:hover { background: #4a3b85; border-color: #4a3b85; }
.brainyx-auth-card .btn-link, .brainyx-auth-card a { color: #6E5AAA; font-weight: 500; text-decoration: none; }
.brainyx-auth-card .btn-link:hover, .brainyx-auth-card a:hover { color: #4a3b85; text-decoration: underline; }
.brainyx-auth-card label { font-size: 0.9rem; color: #475569; }
.brainyx-auth-card .text-danger { font-size: 0.85rem; color: #dc2626; }
.brainyx-auth-card .row { margin-left: -8px; margin-right: -8px; }
.brainyx-auth-card .row > * { padding-left: 8px; padding-right: 8px; }
.brainyx-auth-card .col-md-4,
.brainyx-auth-card .col-md-6,
.brainyx-auth-card .col-md-8 { padding: 0 12px; }
.brainyx-auth-card .form-check-input:checked {
    background-color: #6E5AAA;
    border-color: #6E5AAA;
}
.brainyx-auth-card .form-check-label { font-size: 0.9rem; color: #475569; }
.brainyx-auth-card section { margin-bottom: 8px; }
.brainyx-auth-card p { margin-bottom: 12px; color: #475569; font-size: 0.9rem; }
