/* ── VelaPanel Design System ─────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html, body {
    font-family: 'Inter', 'Roboto', sans-serif;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ── Design tokens ───────────────────────────────────────────────────── */
:root {
    --vela-shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
    --vela-shadow-md: 0 2px 8px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.06);
    --vela-shadow-lg: 0 12px 32px rgba(16,24,40,0.14), 0 4px 8px rgba(16,24,40,0.08);
    --vela-card-border: 1px solid var(--mud-palette-divider);
    --vela-ring: 0 0 0 3px rgba(21,101,192,0.28);
    --vela-transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --vela-transition-med:  0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mud-dark {
    --vela-shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --vela-shadow-md: 0 2px 8px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.4);
    --vela-shadow-lg: 0 12px 32px rgba(0,0,0,0.55), 0 4px 8px rgba(0,0,0,0.4);
    --vela-ring: 0 0 0 3px rgba(94,146,243,0.35);
}

/* ── Keyboard focus rings (accessibility + polish) ───────────────────── */
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-nav-link:focus-visible,
a:focus-visible,
.vela-cmdk-item:focus-visible {
    outline: none;
    box-shadow: var(--vela-ring) !important;
    border-radius: 6px;
}

/* ── Page headers ────────────────────────────────────────────────────── */
.vela-page-header {
    border-bottom: 1px solid var(--mud-palette-divider);
    padding-bottom: 14px;
    margin-bottom: 22px;
}

.vela-page-header .mud-typography-h4 {
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.vela-page-header .mud-typography-body2 {
    margin-top: 3px;
    font-size: 0.8rem;
}

.vela-page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    row-gap: 8px;
}

.vela-page-header-text {
    min-width: 0;
}

.vela-page-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Stat cards ──────────────────────────────────────────────────────── */
.vela-stat-card {
    border-radius: 8px !important;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    overflow: hidden;
}

.vela-stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.09) !important;
    transform: translateY(-2px);
}

/* Coloured top-accent stripe per metric type */
.vela-stat-accent-blue   { border-top: 3px solid #1565C0 !important; }
.vela-stat-accent-slate  { border-top: 3px solid #546E7A !important; }
.vela-stat-accent-green  { border-top: 3px solid #2E7D32 !important; }
.vela-stat-accent-orange { border-top: 3px solid #E65100 !important; }
.vela-stat-accent-purple { border-top: 3px solid #6A1B9A !important; }
.vela-stat-accent-teal   { border-top: 3px solid #00695C !important; }
.vela-stat-accent-red    { border-top: 3px solid #C62828 !important; }

.vela-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Slightly thicker progress bar for better visibility */
.vela-stat-progress .mud-progress-linear {
    height: 6px !important;
    border-radius: 3px !important;
}

/* Card section header — used in Recent Events, dashboard panels */
.vela-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-background);
}

.vela-card-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Event type inline badges */
.vela-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.vela-badge-info    { background: #E3F2FD; color: #1565C0; }
.vela-badge-success { background: #E8F5E9; color: #2E7D32; }
.vela-badge-warning { background: #FFF8E1; color: #E65100; }
.vela-badge-error   { background: #FFEBEE; color: #C62828; }
.vela-badge-neutral { background: #F5F5F5; color: #616161; }
.mud-dark .vela-badge-info    { background: rgba(21,101,192,0.25); color: #90caf9; }
.mud-dark .vela-badge-success { background: rgba(46,125,50,0.25);  color: #a5d6a7; }
.mud-dark .vela-badge-warning { background: rgba(230,81,0,0.25);   color: #ffcc80; }
.mud-dark .vela-badge-error   { background: rgba(198,40,40,0.25);  color: #ef9a9a; }
.mud-dark .vela-badge-neutral { background: rgba(255,255,255,0.1); color: #bdbdbd; }

/* ── Command palette (Ctrl-K) ────────────────────────────────────────── */
.vela-cmdk-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}

.vela-cmdk-panel {
    width: 100%;
    max-width: 560px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.28);
    overflow: hidden;
}

.vela-cmdk-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.vela-cmdk-search-icon {
    font-size: 20px !important;
    color: var(--mud-palette-text-secondary);
}

.vela-cmdk-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--mud-palette-text-primary);
    font-family: inherit;
}

.vela-cmdk-kbd {
    font-size: 0.65rem;
    padding: 2px 6px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 4px;
    color: var(--mud-palette-text-secondary);
}

.vela-cmdk-list {
    max-height: 50vh;
    overflow-y: auto;
    padding: 6px;
}

.vela-cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.vela-cmdk-item.active {
    background: rgba(21, 101, 192, 0.12);
}

.vela-cmdk-item-icon {
    font-size: 19px !important;
    color: var(--mud-palette-text-secondary);
}

.vela-cmdk-item.active .vela-cmdk-item-icon {
    color: var(--mud-palette-primary);
}

.vela-cmdk-item-label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--mud-palette-text-primary);
}

.vela-cmdk-item-group {
    font-size: 0.7rem;
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.vela-cmdk-empty {
    padding: 24px;
    text-align: center;
    color: var(--mud-palette-text-secondary);
    font-size: 0.85rem;
}

.mud-dark .vela-cmdk-item.active {
    background: rgba(94, 146, 243, 0.18);
}

/* ── Error pages ─────────────────────────────────────────────────────── */
.vela-error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
    padding: 32px 24px;
}

.vela-error-icon {
    font-size: 64px !important;
    color: var(--mud-palette-text-disabled);
}

.vela-error-code {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--mud-palette-text-secondary);
    line-height: 1.1;
    margin-top: 8px;
}

.vela-error-msg {
    max-width: 440px;
}

/* ── Loading skeletons ───────────────────────────────────────────────── */
.vela-skeleton-row {
    border-radius: 6px;
    margin-bottom: 10px;
}

/* ── Empty states ────────────────────────────────────────────────────── */
.vela-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    border: 1px dashed var(--mud-palette-divider);
    border-radius: 8px;
    background: var(--mud-palette-background);
}

.vela-empty-state-icon {
    font-size: 48px !important;
    color: var(--mud-palette-text-disabled);
}

.vela-empty-state-msg {
    max-width: 420px;
}

/* ── Navigation ──────────────────────────────────────────────────────── */
.vela-nav {
    padding-bottom: 24px;
}

.vela-nav-section-label {
    font-size: 0.625rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    color: var(--mud-palette-text-disabled) !important;
    text-transform: uppercase;
    display: block;
    margin-top: 4px;
}

.mud-nav-link {
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 6px !important;
    margin: 1px 6px !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    transition: background 0.12s ease, color 0.12s ease;
}

.mud-nav-link:hover {
    background: rgba(21, 101, 192, 0.07) !important;
    color: #1565C0 !important;
}

.mud-nav-link.active {
    background: rgba(21, 101, 192, 0.11) !important;
    color: #1565C0 !important;
    font-weight: 600;
    position: relative;
}

/* Left accent bar on the active nav item */
.mud-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #1565C0;
}

.mud-dark .mud-nav-link.active::before {
    background: #5e92f3;
}

.mud-nav-link.active .mud-nav-link-icon {
    color: #1565C0 !important;
}

.mud-nav-link:hover .mud-nav-link-icon {
    color: #1565C0 !important;
}

/* ── AppBar logo area ────────────────────────────────────────────────── */
.vela-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

/* ── Impersonation banner ────────────────────────────────────────────── */
.vela-impersonate-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #F57C00;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1400;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.vela-impersonate-return {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px;
    padding: 4px 14px;
    cursor: pointer;
    font-weight: 600;
    color: #fff;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.vela-impersonate-return:hover {
    background: rgba(255,255,255,0.3);
}

/* ── MudPaper default rounding ───────────────────────────────────────── */
.mud-paper {
    border-radius: 8px !important;
}

/* Elevated papers get a crisp border + soft shadow (SaaS look) */
.mud-paper.mud-elevation-1,
.mud-paper.mud-elevation-2 {
    border: var(--vela-card-border);
    box-shadow: var(--vela-shadow-sm) !important;
}

/* ── App bar: flat + hairline border instead of heavy drop shadow ────── */
.mud-appbar.mud-elevation-2 {
    box-shadow: none !important;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.mud-drawer {
    border-right: 1px solid var(--mud-palette-divider);
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.mud-table-head .mud-table-cell {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mud-palette-text-secondary);
    border-bottom: 2px solid var(--mud-palette-divider) !important;
    background: var(--mud-palette-background);
    white-space: nowrap;
}

.mud-table-cell {
    padding-top: 9px;
    padding-bottom: 9px;
}

/* Row hover highlight for scannability */
.mud-table-body .mud-table-row:hover {
    background: rgba(21,101,192,0.04);
}

.mud-dark .mud-table-body .mud-table-row:hover {
    background: rgba(94,146,243,0.06);
}

.vela-events-table .mud-table-row:last-child td {
    border-bottom: none;
}

/* Subtle row dividers */
.mud-table-body .mud-table-row td {
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* ── Chips ───────────────────────────────────────────────────────────── */
.mud-chip {
    font-weight: 500;
    font-size: 0.75rem;
}

/* ── Drawer header ───────────────────────────────────────────────────── */
.mud-drawer-header {
    padding: 12px 16px 0 16px;
}

/* ── Scrollbar polish ────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.18);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.mud-button-root {
    letter-spacing: normal;
    text-transform: none !important;
    transition: box-shadow 0.15s ease, transform 0.1s ease, background-color 0.15s ease;
}

/* Subtle lift on filled buttons */
.mud-button-filled:hover {
    box-shadow: var(--vela-shadow-md) !important;
    transform: translateY(-1px);
}

.mud-button-filled:active {
    transform: translateY(0);
    box-shadow: var(--vela-shadow-sm) !important;
}

/* ── Form fields ─────────────────────────────────────────────────────── */
.mud-input-outlined .mud-notched-outline {
    border-radius: 6px;
}

/* ── Snackbar ────────────────────────────────────────────────────────── */
.mud-snackbar {
    border-radius: 8px !important;
}

/* ── Cards in lists ──────────────────────────────────────────────────── */
.mud-card {
    border-radius: 8px !important;
    transition: box-shadow 0.2s ease;
}

.mud-card:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.06) !important;
}

/* ── Progress bars ───────────────────────────────────────────────────── */
.mud-progress-linear {
    border-radius: 4px;
}

/* ── Dialog / popover depth ──────────────────────────────────────────── */
.mud-dialog {
    border-radius: 10px !important;
    box-shadow: var(--vela-shadow-lg) !important;
    border: var(--vela-card-border);
}

.mud-popover {
    border-radius: 8px !important;
    box-shadow: var(--vela-shadow-lg) !important;
    border: var(--vela-card-border);
}

.mud-overlay-dialog {
    backdrop-filter: blur(2px);
}

/* ── Dark mode adjustments ───────────────────────────────────────────── */
.mud-dark .mud-nav-link:hover {
    background: rgba(94, 146, 243, 0.08) !important;
}

.mud-dark .mud-nav-link.active {
    background: rgba(94, 146, 243, 0.15) !important;
    color: #5e92f3 !important;
}

.mud-dark .mud-nav-link.active .mud-nav-link-icon {
    color: #5e92f3 !important;
}

.mud-dark ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

.mud-dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* ── Tabs polish ────────────────────────────────────────────────────── */
.mud-tabs-header {
    border-bottom: 2px solid var(--mud-palette-divider);
}

.mud-tab {
    font-weight: 500 !important;
    font-size: 0.8125rem !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    min-width: auto !important;
    padding: 8px 16px !important;
    transition: color var(--vela-transition-fast), background var(--vela-transition-fast);
}

.mud-tab:hover {
    background: rgba(21,101,192,0.05);
}

.mud-dark .mud-tab:hover {
    background: rgba(94,146,243,0.08);
}

.mud-tab.mud-tab-active {
    font-weight: 600 !important;
}

/* ── Alerts — softer, rounder ───────────────────────────────────────── */
.mud-alert {
    border-radius: 8px !important;
    font-size: 0.8125rem;
}

.mud-alert-text {
    line-height: 1.5;
}

/* ── Avatar (profile dropdown) ──────────────────────────────────────── */
.vela-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #1565C0 0%, #5e92f3 100%);
    cursor: pointer;
    transition: box-shadow var(--vela-transition-fast), transform var(--vela-transition-fast);
    user-select: none;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.vela-avatar:hover {
    box-shadow: 0 2px 8px rgba(21,101,192,0.4);
    transform: scale(1.06);
}

.mud-dark .vela-avatar {
    background: linear-gradient(135deg, #1A237E 0%, #5e92f3 100%);
}

/* ── Profile menu ───────────────────────────────────────────────────── */
.vela-profile-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--mud-palette-divider);
    display: flex;
    align-items: center;
    gap: 12px;
}

.vela-profile-header-info {
    min-width: 0;
}

.vela-profile-name {
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vela-profile-role {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mud-palette-text-secondary);
}

/* ── Drawer footer ──────────────────────────────────────────────────── */
.vela-drawer-footer {
    margin-top: auto;
    padding: 10px 16px 14px;
    border-top: 1px solid var(--mud-palette-divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.vela-drawer-footer-version {
    font-size: 0.625rem;
    color: var(--mud-palette-text-disabled);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.vela-drawer-footer-plan {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.625rem;
    font-weight: 600;
    background: rgba(21,101,192,0.1);
    color: #1565C0;
}

.mud-dark .vela-drawer-footer-plan {
    background: rgba(94,146,243,0.15);
    color: #90caf9;
}

/* ── Login page ─────────────────────────────────────────────────────── */
.vela-login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #EBF2FA;
    padding: 24px;
}

.vela-login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 16px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
    padding: 40px 36px !important;
    animation: vela-login-appear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes vela-login-appear {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.vela-login-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1565C0 0%, #42A5F5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 4px 14px rgba(21,101,192,0.35);
}

/* ── Section divider for card groups ────────────────────────────────── */
.vela-section {
    margin-bottom: 24px;
}

.vela-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--mud-palette-text-disabled);
    margin-bottom: 12px;
    padding-left: 2px;
}

/* ── Smooth page transitions ────────────────────────────────────────── */
.mud-main-content {
    animation: vela-page-in 0.2s ease-out;
}

@keyframes vela-page-in {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

/* ── Drawer smooth transitions ──────────────────────────────────────── */
.mud-drawer {
    transition: width var(--vela-transition-med), transform var(--vela-transition-med) !important;
}

/* ── Tooltip polish ─────────────────────────────────────────────────── */
.mud-tooltip {
    font-size: 0.75rem !important;
    border-radius: 6px !important;
    padding: 4px 10px !important;
}

/* ── Responsive: tighter padding on smaller viewports ───────────────── */
@media (max-width: 960px) {
    .vela-page-header .mud-typography-h4 {
        font-size: 1.25rem;
    }

    .vela-stat-card {
        padding: 14px !important;
    }

    .vela-stat-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .vela-login-card {
        padding: 32px 24px !important;
    }
}

/* ── MudSelect / MudAutocomplete polish ─────────────────────────────── */
.mud-select .mud-input-outlined .mud-notched-outline,
.mud-autocomplete .mud-input-outlined .mud-notched-outline {
    transition: border-color var(--vela-transition-fast);
}

/* ── Loading shimmer for table rows ─────────────────────────────────── */
@keyframes vela-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.vela-skeleton-row .mud-skeleton {
    background: linear-gradient(90deg,
        var(--mud-palette-background) 25%,
        var(--mud-palette-surface) 50%,
        var(--mud-palette-background) 75%);
    background-size: 200% 100%;
    animation: vela-shimmer 1.5s infinite ease-in-out;
}

/* ── Stat card number animation ─────────────────────────────────────── */
.vela-stat-card .mud-typography-h4,
.vela-stat-card .mud-typography-h5 {
    font-variant-numeric: tabular-nums;
}

/* ── MudChip tweaks ─────────────────────────────────────────────────── */
.mud-chip.mud-chip-size-small {
    height: 24px;
    font-size: 0.7rem;
}

/* ── Consistent card header for all pages ───────────────────────────── */
.mud-card-header {
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* ── Cleaner MudDivider ─────────────────────────────────────────────── */
.mud-divider {
    border-color: var(--mud-palette-divider) !important;
}
