html, body {
    font-family: 'Inter', 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App shell ─────────────────────────────────────────────── */

.portal-app-bar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(12px);
}

.mud-theme-dark .portal-app-bar {
    background-color: rgba(10, 10, 10, 0.92) !important;
}

.mud-theme-light .portal-app-bar {
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

.app-bar-logo-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(0, 230, 118, 0.12);
    border: 1px solid rgba(0, 230, 118, 0.35);
    color: #00E676;
}

.app-bar-title {
    letter-spacing: -0.02em;
}

.portal-drawer {
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.mud-theme-dark .portal-drawer {
    background-color: #000000 !important;
}

.drawer-user-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.main-content-area {
    min-height: calc(100dvh - 64px);
}

.mud-theme-dark .main-content-area {
    background: #0a0a0a;
}

.page-content {
    max-width: 1200px;
}

.drawer-status-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.drawer-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00E676;
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.6);
    flex-shrink: 0;
}

/* ── Navigation pills ──────────────────────────────────────── */

.nav-menu-root {
    padding-top: 8px !important;
}

.nav-section-label {
    padding: 12px 16px 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.nav-menu-root .mud-nav-link {
    border-radius: 9999px !important;
    margin: 2px 8px !important;
    padding: 10px 16px !important;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    overflow: visible !important;
}

.nav-menu-root .mud-nav-link .mud-nav-link-text {
    overflow: visible !important;
}

.nav-menu-root .mud-nav-link:not(.mud-nav-link-active):hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

.mud-theme-dark .nav-menu-root .mud-nav-link-active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

.mud-theme-dark .nav-menu-root .mud-nav-link-active .mud-nav-link-icon {
    color: #00E676 !important;
}

.nav-chats-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.nav-link-chats.mud-nav-link {
    overflow: visible !important;
}

.nav-unread-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff3d57;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(10, 10, 10, 0.9);
}

html:not(.mud-theme-dark) .nav-unread-count {
    box-shadow: 0 0 0 2px #fff;
}

/* ── Global cards & buttons ────────────────────────────────── */

.portal-card {
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    background: var(--mud-palette-surface) !important;
}

.mud-theme-dark .portal-card {
    background: #141414 !important;
}

.devibot-manage-tabs .mud-tabs-toolbar {
    background: transparent !important;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.mud-theme-dark .mud-paper-outlined {
    border-color: rgba(255, 255, 255, 0.08) !important;
    background: #141414;
}

.mud-button-root.mud-button-filled,
.mud-button-root.mud-button-outlined {
    border-radius: 9999px;
    text-transform: none;
    font-weight: 600;
}

.mud-button-root.mud-button-filled-primary {
    color: #0a0a0a !important;
}

.mud-input-outlined-border {
    border-radius: 12px !important;
}

/* ── Page layout ───────────────────────────────────────────── */

.portal-page-header {
    margin-bottom: 24px;
}

.portal-page-title {
    letter-spacing: -0.03em;
    font-weight: 700 !important;
}

.portal-hero-banner {
    border-radius: 20px;
    padding: 28px 32px;
    margin-bottom: 28px;
    background: linear-gradient(135deg, #0d2818 0%, #123d24 45%, #0a1a10 100%);
    border: 1px solid rgba(0, 230, 118, 0.2);
    position: relative;
    overflow: hidden;
}

.portal-hero-banner::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -10%;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 230, 118, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.portal-hero-banner__inner {
    position: relative;
    z-index: 1;
}

.portal-hero-banner__title {
    color: #ffffff !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}

.portal-hero-banner__text {
    color: rgba(255, 255, 255, 0.78) !important;
    max-width: 640px;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(0, 230, 118, 0.45);
    color: #00E676;
    background: rgba(0, 230, 118, 0.08);
}

.portal-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.portal-action-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    background: #141414;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.mud-theme-light .portal-action-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
}

.portal-action-card:hover {
    border-color: rgba(0, 230, 118, 0.35);
}

/* ── Auth layout ───────────────────────────────────────────── */

.auth-viewport.mud-layout-root {
    min-height: 100dvh;
}

.auth-shell {
    min-height: 100dvh;
    background-color: var(--mud-palette-background);
}

.auth-hero-column {
    background: linear-gradient(145deg, #0a1f14 0%, #0d3320 45%, #051410 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.auth-hero-column::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(0, 230, 118, 0.15) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.auth-hero-inner {
    position: relative;
    z-index: 1;
}

.auth-hero-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: rgba(0, 230, 118, 0.12);
    border: 1px solid rgba(0, 230, 118, 0.35);
    backdrop-filter: blur(8px);
}

.auth-hero-icon {
    color: #00E676 !important;
}

.auth-hero-text {
    color: #fff !important;
}

.auth-hero-text-dim {
    color: rgba(255, 255, 255, 0.78) !important;
}

.auth-hero-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}

.auth-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(0, 230, 118, 0.1);
    border: 1px solid rgba(0, 230, 118, 0.25);
    flex-shrink: 0;
    color: #00E676;
}

.auth-preview-card {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    backdrop-filter: blur(8px);
    border-radius: 16px !important;
}

.auth-preview-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.auth-preview-dot--green {
    background: #00E676;
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.6);
}

.auth-preview-bar {
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
}

.auth-preview-bar--full { width: 100%; }
.auth-preview-bar--three-quarters { width: 75%; }
.auth-preview-bar--half { width: 50%; }

.auth-form-card {
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 20px !important;
    background: var(--mud-palette-surface) !important;
}

.mud-theme-dark .auth-form-card {
    background: #141414 !important;
}

.mud-theme-dark .auth-shell .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* ── Landing page ──────────────────────────────────────────── */

.landing-hero {
    min-height: calc(100dvh - 64px);
    display: flex;
    align-items: center;
}

.landing-hero-card {
    border-radius: 24px;
    padding: 48px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, #141414 0%, #0a0a0a 100%);
    max-width: 720px;
}

.mud-theme-light .landing-hero-card {
    background: linear-gradient(135deg, #ffffff 0%, #f4f4f5 100%);
    border-color: rgba(0, 0, 0, 0.08);
}

/* ── Chats inbox ───────────────────────────────────────────── */

.page-content:has(.chats-page) {
    max-width: none;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: calc(100dvh - 64px - 2rem);
    max-height: calc(100dvh - 64px - 2rem);
    box-sizing: border-box;
}

@media (min-width: 960px) {
    .page-content:has(.chats-page) {
        height: calc(100dvh - 64px - 3rem);
        max-height: calc(100dvh - 64px - 3rem);
    }
}

.chats-page {
    width: 100%;
    max-width: 1600px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.chats-page .portal-page-header {
    margin-bottom: 0 !important;
    flex-shrink: 0;
}

.chats-shell {
    display: grid;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: hidden;
}

.chats-list.mud-paper,
.chats-pane.mud-paper {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    height: 100% !important;
    border-radius: 16px !important;
    overflow: hidden;
}

.chats-list {
    padding: 10px !important;
}

.chats-list-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px;
}

.chats-list-item {
    border-radius: 12px !important;
    margin-bottom: 6px !important;
    padding: 14px 16px !important;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chats-list-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.chats-list-item.is-active {
    background: rgba(0, 230, 118, 0.14) !important;
    border-color: rgba(0, 230, 118, 0.35);
}

html:not(.mud-theme-dark) .chats-list-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

html:not(.mud-theme-dark) .chats-list-item.is-active {
    background: rgba(0, 140, 80, 0.1) !important;
    border-color: rgba(0, 140, 80, 0.25);
}

.chats-list-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.chats-list-meta {
    font-size: 0.8rem;
    opacity: 0.72;
    margin-top: 2px;
}

.chats-list-preview {
    font-size: 0.88rem;
    opacity: 0.78;
    margin-top: 4px;
}

.chats-list-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--mud-palette-primary);
    color: #04140a;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chats-pane {
    padding: 0 !important;
}

.chats-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

html:not(.mud-theme-dark) .chats-pane-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.chats-pane-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.chats-pane-subtitle {
    font-size: 0.8rem;
    opacity: 0.65;
    margin-top: 2px;
}

.chats-thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background:
        radial-gradient(ellipse at top, rgba(0, 230, 118, 0.05), transparent 55%),
        transparent;
}

#chats-thread-end {
    height: 1px;
    width: 100%;
    flex-shrink: 0;
}

.chats-bubble {
    max-width: min(72%, 760px);
    padding: 14px 18px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.chats-bubble--visitor {
    align-self: flex-start;
    background: rgba(66, 133, 244, 0.14);
    border-color: rgba(66, 133, 244, 0.28);
    border-bottom-left-radius: 6px;
}

.chats-bubble--ai {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.06);
    border-bottom-right-radius: 6px;
}

.chats-bubble--staff {
    align-self: flex-end;
    background: rgba(0, 230, 118, 0.14);
    border-color: rgba(0, 230, 118, 0.32);
    border-bottom-right-radius: 6px;
}

.chats-bubble--system {
    align-self: center;
    max-width: 92%;
    background: transparent;
    border-style: dashed;
    opacity: 0.85;
    text-align: center;
}

html:not(.mud-theme-dark) .chats-bubble {
    border-color: rgba(0, 0, 0, 0.08);
}

html:not(.mud-theme-dark) .chats-bubble--visitor {
    background: rgba(66, 133, 244, 0.1);
}

html:not(.mud-theme-dark) .chats-bubble--ai {
    background: rgba(0, 0, 0, 0.04);
}

html:not(.mud-theme-dark) .chats-bubble--staff {
    background: rgba(0, 140, 80, 0.12);
    border-color: rgba(0, 140, 80, 0.28);
}

.chats-bubble__meta {
    font-size: 0.78rem;
    opacity: 0.65;
    margin-bottom: 6px;
}

.chats-bubble__body {
    font-size: 1.02rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.chats-composer {
    flex-shrink: 0;
    padding: 16px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.16);
}

.chats-composer-row {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.chats-reply-input {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font: inherit;
    font-size: 1rem;
    padding: 14px 16px;
    outline: none;
}

.chats-reply-input:focus {
    border-color: rgba(0, 230, 118, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.25);
}

.chats-reply-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chats-send-btn {
    flex-shrink: 0;
    min-width: 110px;
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: var(--mud-palette-primary);
    color: #04140a;
}

.chats-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

html:not(.mud-theme-dark) .chats-composer {
    border-top-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
}

html:not(.mud-theme-dark) .chats-reply-input {
    border-color: rgba(0, 0, 0, 0.14);
    background: #fff;
}

.chats-empty-pane {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

@media (max-width: 960px) {
    .chats-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }

    .chats-list.mud-paper {
        min-height: 300px;
        max-height: 38vh;
        height: 38vh !important;
    }

    .chats-pane.mud-paper {
        min-height: 64vh;
        height: 64vh !important;
    }

    .chats-bubble {
        max-width: 92%;
    }
}
