* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* No-Line "Nocturnal Intelligence" System */
    --surface-void: #000000;     
    --surface-desk: #0a0a0c;     /* Main background area */
    --surface-card: #121216;     
    --surface-card-hi: #1a1a20;
    --surface-active: #222228;   

    --primary: #c084fc;          
    --secondary: #a78bfa;        
    --tertiary: #9333ea;
    
    --on-surface: #ffffff;       
    --on-surface-variant: #94a3b8; 
    
    --ghost-border: rgba(255, 255, 255, 0.05);
    
    --ok: #10b981;
    --warn: #fbbf24;
    --danger: #f43f5e;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--surface-desk);
    color: var(--on-surface-variant);
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

body.app-loaded {
    opacity: 1;
}

::-webkit-scrollbar { display: none; width: 0; height: 0; }
* { -ms-overflow-style: none; scrollbar-width: none; }

/* MASTER LAYOUT: TWO COLUMNS */
.layout-wrapper {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* SIDEBAR STYLES */
.sidebar {
    background: var(--surface-void);
    border-right: 1px solid var(--ghost-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    position: relative;
    z-index: 50;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

.brand-area {
    padding: 0 1rem 2.5rem;
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--on-surface);
}

.brand-title span {
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Side Navigation */
.side-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.side-menu a {
    text-decoration: none;
    color: var(--on-surface-variant);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
}

.side-menu a:hover {
    background: var(--surface-card);
    color: var(--on-surface);
    transform: translateX(4px);
}

.side-menu a.active {
    background: rgba(192, 132, 252, 0.1);
    color: var(--primary);
    font-weight: 600;
    border-left: 3px solid var(--primary);
    border-radius: 0 12px 12px 0;
}

.menu-icon { font-size: 1.1rem; opacity: 0.8; }

.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
}

/* Auth Meta (Status pill in sidebar) */
.auth-meta {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ok);
    margin-top: 2.5rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px;
    background: rgba(16, 185, 129, 0.05); /* más sutil */
    border: 1px solid rgba(16, 185, 129, 0.1);
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* =============================================
   ADMIN TOKEN OVERLAY: NEON MONOLITH
   ============================================= */
.admin-token-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(14, 14, 14, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-token-modal {
    background: #1f1f1f;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 0 50px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(255,255,255,0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.lock-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(147, 51, 234, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.4);
    animation: pulse-glow 2s infinite ease-in-out;
}

.neon-lock {
    font-size: 32px;
    color: #ddb8ff;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 15px rgba(147, 51, 234, 0.3); }
    50% { box-shadow: 0 0 35px rgba(221, 184, 255, 0.7); }
}

.neon-title {
    font-size: 1.5rem;
    color: #e2e2e2;
    letter-spacing: -0.02em;
    margin: 0;
}

.neon-desc {
    color: #cfc2d7;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.neon-input-group {
    display: flex;
    width: 100%;
    gap: 0.5rem;
}

.neon-input {
    flex: 1;
    background: #0e0e0e;
    border: none;
    border-radius: 8px;
    padding: 0 1rem;
    color: #e2e2e2;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 0 1px rgba(77, 67, 84, 0.3);
}

.neon-input:focus {
    box-shadow: inset 0 0 0 1px rgba(147, 51, 234, 0.6), 0 0 15px rgba(147, 51, 234, 0.2);
}

.pulse-dot-green { box-shadow: 0 0 10px var(--ok); animation: pulse 1.5s infinite alternate; }
.pulse-dot-primary { border-radius: 50%; width: 8px; height: 8px; background: var(--primary); box-shadow: 0 0 10px var(--primary); display: inline-block; animation: pulse 1.5s infinite alternate; margin-right: 6px; }

/* DEPLOY BUTTON (Massive bottom button) */
.btn-deploy {
    background: linear-gradient(135deg, var(--primary), var(--tertiary));
    color: var(--surface-void);
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(147, 51, 234, 0.3);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    width: 100%;
}
.btn-deploy:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 20px 40px rgba(147, 51, 234, 0.5);
}

/* MAIN CONTENT AREA */
.main-content {
    overflow-y: auto;
    padding: 2.5rem 3.5rem;
    position: relative;
    background: radial-gradient(circle at 100% 0%, rgba(147, 51, 234, 0.05) 0%, transparent 40%);
}

.no-scroll {
    overflow: hidden !important;
}

.main-content.no-scroll {
    display: flex;
    flex-direction: column;
}

/* Top Navigation (Breadcrumbs & Auth Input) */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
}

.breadcrumbs {
    font-size: 0.85rem;
    font-weight: 600;
}
.breadcrumbs .muted { color: var(--on-surface-variant); }
.breadcrumbs .sep { margin: 0 8px; color: var(--ghost-border); }
.breadcrumbs .active { color: var(--on-surface); }

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

.auth-bar input {
    background: var(--surface-card);
    border: 1px solid var(--ghost-border);
    color: var(--on-surface);
    font-size: 0.85rem;
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    transition: all 0.3s;
    width: 240px;
}
.auth-bar input:focus {
    width: 300px;
    border-color: var(--primary);
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5), 0 0 0 2px rgba(192, 132, 252, 0.2);
}

/* BENTO GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(100px, auto);
    gap: 1.5rem; 
}

/* CARDS */
.card {
    background: var(--surface-card);
    border-radius: 20px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background 0.4s, transform 0.4s;
}

.card:hover { /* Tonal Lift from Nocturnal AI rules */
    background: var(--surface-card-hi);
    transform: translateY(-2px);
}

/* Grid Spans */
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.row-span-2 { grid-row: auto / span 2; }

/* MASONRY (Apilado Grid) */
.masonry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

/* HERO CARD (Digital Buho Core) */
.hero-card {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 80% 50%, rgba(147, 51, 234, 0.08), transparent 50%),
                linear-gradient(135deg, var(--surface-card), rgba(147, 51, 234, 0.02));
    border: 1px solid rgba(192,132,252,0.1);
}
.card-pulse {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--on-surface-variant);
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    display: flex; align-items: center;
}
.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--on-surface);
    letter-spacing: -0.04em;
    margin-bottom: 0.5rem;
}
.hero-desc {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--on-surface-variant);
    max-width: 85%;
    margin-bottom: 2rem;
}
.hero-stats {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.03);
}
.hero-stats .stat-block { display: flex; flex-direction: column; }
.stat-line { width: 1px; height: 40px; background: var(--ghost-border); }

/* Right Stack Mini Cards */
.kpi-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.mini-banner {
    flex: 1;
    padding: 1.5rem;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}
.mini-banner .trend {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--on-surface-variant);
}
.mini-banner .trend.positive { color: var(--ok); background: rgba(16,185,129,0.1); padding: 4px 8px; border-radius: 6px; }
.mini-banner .trend.negative { color: var(--tertiary); background: rgba(147,51,234,0.1); padding: 4px 8px; border-radius: 6px; }

/* System Traffic (Middle Left) */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--on-surface);
}
.traffic-filters {
    display: flex; gap: 8px;
}
.traffic-filters .filter {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-desk);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.traffic-filters .filter.active { background: rgba(192,132,252,0.15); color: var(--primary); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.micro-stat {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface-desk);
    padding: 1rem;
    border-radius: 12px;
}

/* Shared Typography */
.label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--on-surface-variant);
}
.value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--on-surface);
}
.big-val {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--on-surface);
    display: block;
    margin-top: 4px;
}

/* Forms / Inputs (The Data Portals) */
.minimal-form { display: flex; flex-direction: column; gap: 1.2rem; }
.inline-form { display: flex; gap: 12px; align-items: flex-start; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.grid-2-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.col-span-2 { grid-column: span 2; }

.form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--on-surface-variant);
}
.form-group input, .form-group select {
    background: var(--surface-desk);
    border: 1px solid var(--ghost-border);
    color: var(--on-surface);
    font-size: 0.9rem;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    width: 100%;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 0 2px rgba(192,132,252,0.2);
}

.kpi-title { font-size: 0.75rem; font-weight: 700; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: 0.05em; }

/* General Buttons */
.btn-primary { background: linear-gradient(135deg, var(--on-surface), #cbd5e1); color: var(--surface-void); border: none; font-weight: 700; padding: 10px 16px; border-radius: 8px; cursor: pointer; transition: 0.3s; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #000; box-shadow: 0 4px 15px rgba(192,132,252,0.4); }

.btn-outline { background: var(--surface-desk); color: var(--on-surface); border: 1px solid var(--ghost-border); padding: 8px 16px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: 0.3s; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(192,132,252,0.05); }

/* Keys list */
.clean-list { display: flex; flex-direction: column; gap: 10px; }
.clean-list-item { background: var(--surface-desk); padding: 1.2rem; border-radius: 12px; font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; }

/* Text colors */
.color-ok { color: var(--ok); text-shadow: 0 0 10px rgba(16,185,129,0.3); }
.color-err { color: var(--danger); text-shadow: 0 0 10px rgba(244,63,94,0.3); }
.color-warn { color: var(--warn); }
.color-accent { color: var(--primary); }
.font-bold { font-weight: 800; }

/* Animations */
@keyframes dropIn { 0% { opacity: 0; transform: translateY(-10px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { opacity: 0.7; transform: scale(1); } 100% { opacity: 1; transform: scale(1.3); } }
.slide-in-left { animation: slideLeft 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes slideLeft { 0% { transform: translateX(-50px); opacity: 0;} 100% { transform: translateX(0); opacity: 1; } }
.fade-in-up { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
@keyframes fadeUp { 0% { transform: translateY(20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.25s; }
.delay-3 { animation-delay: 0.35s; }
.delay-4 { animation-delay: 0.45s; }
.delay-5 { animation-delay: 0.55s; }

/* TOASTS */
.toast-wrap { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 12px; z-index: 1000; }
.toast { background: rgba(192,132,252,0.15); backdrop-filter: blur(12px); border: 1px solid var(--primary); color: var(--on-surface); padding: 12px 24px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; box-shadow: 0 10px 30px rgba(147, 51, 234, 0.2); }

/* =============================================
   LIVE INTELLIGENCE STREAM (CHAT MIRROR) - STITCH DESIGN
   ============================================= */
.chat-view {
    margin: 0 -3.5rem -2.5rem -3.5rem; /* Anula el padding horizontal y bottom del main-content */
    flex: 1;
    min-height: 0;
}

.chat-layout {
    display: flex;
    height: 100%;
    background: var(--surface-desk);
    border-radius: 0;
    border-top: 1px solid var(--ghost-border);
}

.chat-sidebar {
    width: 320px;
    background: var(--surface-card);
    border-right: 1px solid var(--ghost-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-header {
    height: 64px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--ghost-border);
    position: sticky;
    top: 0;
    background: var(--surface-card);
    z-index: 10;
}

/* =============================================
   STITCH DESIGN: AETHER ONYX SIDEBAR
   ============================================= */
.chat-sidebar-right.aether-onyx-sidebar {
    background: transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    width: 300px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.sidebar-top-branding {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #e2e2e2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.aether-timeline-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-node {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
}

.node-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(147, 51, 234, 0.1);
    color: #cc97ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.2);
}

.node-icon span {
    font-size: 16px;
}

.pulse-icon {
    animation: pulse-glow 2s infinite ease-in-out;
}

.node-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aether-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #767578;
}

.aether-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fffbfe;
    letter-spacing: -0.01em;
}

.timeline-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    width: 100%;
}

.aether-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.grid-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grid-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #767578;
}

.grid-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.aether-btn-primary {
    background: #a855f7;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
    margin-top: auto;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.aether-btn-primary:hover {
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
    transform: translateY(-2px);
    background: #b871ff;
}

.chat-search-box {
    margin-left: auto;
    background: var(--surface-card-hi);
    border-radius: 99px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.chat-search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.chat-search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--on-surface);
    font-size: 0.8rem;
    width: 120px;
}

.chat-user-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.chat-user-item {
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.chat-user-item:hover {
    background: var(--surface-card);
}

.chat-user-item.active {
    background: var(--surface-card-hi);
    border: 1px solid rgba(192, 132, 252, 0.2);
}

.chat-user-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.chat-user-phone {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--on-surface);
}

.chat-user-badge {
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
}

.chat-user-badge.ai-active { color: var(--primary); background: rgba(192, 132, 252, 0.1); }
.chat-user-badge.waiting { color: var(--on-surface-variant); background: rgba(255, 255, 255, 0.05); }

.chat-user-msg {
    font-size: 0.7rem;
    color: var(--on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
}

.chat-main-header {
    height: 64px;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ghost-border);
    position: sticky;
    top: 0;
    background: var(--surface-card); /* Keep opaque so chat doesn't flow under */
    z-index: 10;
}

.chat-main-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-main-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-card-hi);
    border: 1px solid var(--ghost-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.2rem;
}

.chat-main-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--on-surface);
}

.chat-main-subtitle {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--primary);
    text-transform: uppercase;
}

.chat-stream {
    flex: 1;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chat-stream::-webkit-scrollbar {
    display: none;
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--on-surface-variant);
    opacity: 0.6;
    gap: 12px;
}

/* Chat Bubbles adapting Stitch Style */
.msg-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
}

.msg-wrapper.inbound {
    align-self: flex-start;
    align-items: flex-start;
}

.msg-wrapper.outbound {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--on-surface);
}

.msg-wrapper.inbound .msg-bubble {
    background: var(--surface-desk);
    border: 1px solid var(--ghost-border);
    border-top-left-radius: 4px;
}

.msg-wrapper.outbound .msg-bubble {
    background: linear-gradient(135deg, rgba(204, 151, 255, 0.15), rgba(158, 65, 245, 0.05));
    border: 1px solid rgba(204, 151, 255, 0.3);
    border-top-right-radius: 4px;
    box-shadow: 0 4px 20px rgba(147, 51, 234, 0.15), inset 0 0 10px rgba(204, 151, 255, 0.05);
}

.msg-meta {
    font-size: 0.6rem;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.msg-latency {
    color: var(--ok);
    font-weight: 600;
}

/* AI Pulse indicator */
.ai-pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 8px var(--primary); }
    50% { opacity: 0.4; transform: scale(1.4); }
}

/* Chat input area */
.chat-input-area {
    padding: 1rem 1rem 1.5rem;
    border-top: 1px solid var(--ghost-border);
    background: var(--surface-desk);
}

.chat-input-box {
    background: var(--surface-card-hi);
    border-radius: 12px;
    padding: 8px 8px 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--ghost-border);
}

.chat-input-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--on-surface);
    font-size: 0.85rem;
    outline: none;
}

.chat-btn-send {
    background: rgba(192, 132, 252, 0.1);
    color: var(--primary);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-btn-send:hover {
    background: rgba(192, 132, 252, 0.2);
}

/* Responsive Grid breaks */
@media (max-width: 1400px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1200px) {
    .span-4 { grid-column: span 6; }
    .span-8 { grid-column: span 12; }
}
.mobile-menu-btn, .mobile-back-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--on-surface);
    cursor: pointer;
}

@media (max-width: 768px) {
    .layout-wrapper { display: flex; flex-direction: column; overflow-x: hidden; }
    
    /* Off-canvas sidebar */
    .sidebar { 
        position: fixed; 
        left: -100%; 
        top: 0; 
        bottom: 0; 
        width: 280px;
        z-index: 1000; 
        transition: left 0.3s ease; 
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    .sidebar.active { left: 0; }
    
    .mobile-menu-btn { display: flex; align-items: center; }
    .mobile-back-btn { display: flex; align-items: center; margin-right: 8px; }
    
    .main-content { padding: 1rem; width: 100%; overflow-x: hidden; }
    .dashboard-grid { display: flex; flex-direction: column; gap: 1.5rem; }
    
    .dashboard-grid > * { width: 100% !important; grid-column: auto !important; margin: 0; }
    
    .hero-stats { flex-direction: column; align-items: flex-start; gap: 1rem; border-top: 1px solid rgba(255,255,255,0.03); padding-top: 1rem; margin-top: auto; }
    .stat-line { display: none; }
    .grid-2-cols { grid-template-columns: 1fr; }
    
    /* Fix header overflow on mobile */
    .top-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
        padding-bottom: 1rem;
        margin: -1rem -1rem 1rem -1rem; /* Negate main-content padding to stretch */
        border-bottom: 1px solid var(--ghost-border);
        position: sticky;
        top: 0;
        background: var(--surface-desk);
        z-index: 1000;
    }
    
    .auth-bar {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
        display: none; /* Hide auth bar on mobile by default to save space, or keep it compact */
    }
    
    /* Interactive SPA chat on mobile */
    .chat-view {
        margin: 0 -1rem -1rem -1rem;
        flex: 1;
        min-height: 0;
    }

    .chat-layout { 
        flex-direction: column; 
        height: 100%;
        min-height: 0;
        border:none; 
        border-radius: 0; 
        background: transparent; 
        margin: 0;
        width: 100%;
    }
    
    .chat-sidebar { 
        width: 100%; 
        height: 100%; 
        min-height: 0;
        border: none; 
        border-radius: 0; 
        display: flex; 
    }
    
    .chat-main { 
        height: 100%; 
        min-height: 0;
        border: none; 
        border-radius: 0;
        display: none; /* hidden by default on mobile */
        width: 100%;
        background: var(--surface-desk);
    }
    
    .chat-sidebar.mobile-hidden { display: none !important; }
    .chat-main.mobile-active { display: flex !important; }

    .chat-sidebar-right {
        display: none !important;
    }

    /* Fix live chat header on mobile */
    .chat-main-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        height: auto;
        padding: 10px 1rem;
    }
    
    .chat-main-header-info {
        width: 100%;
        justify-content: flex-start;
    }
    
    .chat-header-actions {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid var(--ghost-border);
        padding-top: 10px;
    }
    
    .chat-input-area {
        padding: 10px;
    }
}
