body{
    font-family:"Manrope",sans-serif;
    background:#F4F7FB;
    color:#1E293B;
    transition:.3s;
}

/* ============ LAYOUT ============ */

.app-wrapper{
    display:flex;
    min-height:100vh;
}

:root{
    --sidebar-width: 264px;
    --brand-green: #1E3A8A;
    --brand-green-dark: #172554;
    --navy-950: #0A1A33;
    --navy-tint: #EFF6FF;
    --navy-accent: #60A5FA;
}

/* ============ SIDEBAR ============ */

.sidebar{
    position:fixed;
    top:0;
    left:0;
    height:100vh;
    width:var(--sidebar-width);
    background:var(--navy-950);
    color:#fff;
    display:flex;
    flex-direction:column;
    z-index:1050;
    transform:translateX(-100%);
    transition:transform .3s ease;
}

.sidebar.show{
    transform:translateX(0);
}

.sidebar-brand{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:24px 22px;
    border-bottom:1px solid rgba(255,255,255,.08);
}

.brand-link{
    display:flex;
    align-items:center;
    gap:12px;
    text-decoration:none;
    color:#fff;
}

.brand-mark{
    width:38px;
    height:38px;
    border-radius:12px;
    background:var(--brand-green);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    font-size:.95rem;
    flex-shrink:0;
}

.brand-text{
    font-weight:800;
    font-size:1.15rem;
}

.sidebar-close{
    background:transparent;
    border:none;
    color:#fff;
    font-size:1.1rem;
}

.sidebar-nav{
    flex:1;
    padding:18px 14px;
    display:flex;
    flex-direction:column;
    gap:4px;
    overflow-y:auto;
}

.sidebar-link{
    display:flex;
    align-items:center;
    gap:14px;
    padding:12px 14px;
    border-radius:12px;
    color:#CBD5E1;
    text-decoration:none;
    font-weight:600;
    font-size:.95rem;
    transition:.2s;
}

.sidebar-link i{
    font-size:1.1rem;
    width:20px;
    text-align:center;
}

.sidebar-link:hover{
    background:rgba(255,255,255,.06);
    color:#fff;
}

.sidebar-link.active{
    background:var(--brand-green);
    color:#fff;
}

.sidebar-footer{
    padding:18px 14px 22px;
    border-top:1px solid rgba(255,255,255,.08);
}

.sidebar-footer-text{
    color:#94A3B8;
    font-size:.8rem;
    margin-bottom:0;
    text-align:center;
}

.theme-toggle-btn{
    width:100%;
    display:flex;
    align-items:center;
    gap:12px;
    background:rgba(255,255,255,.06);
    border:none;
    color:#fff;
    padding:12px 14px;
    border-radius:12px;
    font-weight:600;
    font-size:.9rem;
}

.sidebar-overlay{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.5);
    z-index:1040;
}

.sidebar-overlay.show{
    display:block;
}

/* ============ TOPBAR (mobile only) ============ */

.topbar{
    background:#fff;
    border-bottom:1px solid #E5E7EB;
    padding:14px 18px;
    align-items:center;
    gap:14px;
    position:sticky;
    top:0;
    z-index:1030;
}

.menu-btn{
    background:transparent;
    border:none;
    font-size:1.5rem;
    color:#0F172A;
}

.topbar-brand{
    font-weight:800;
    font-size:1.2rem;
    color:var(--brand-green-dark);
    text-decoration:none;
}

/* ============ MAIN WRAPPER ============ */

.main-wrapper{
    flex:1;
    min-width:0;
    margin-left:0;
}

@media (min-width:992px){
    .sidebar{
        transform:translateX(0);
    }
    .main-wrapper{
        margin-left:var(--sidebar-width);
    }
}

/* ============ CARDS ============ */

.card{
    border:none;
    border-radius:20px;
    box-shadow:0 10px 30px rgba(15,23,42,.06);
    transition:.25s ease;
    background:#fff;
}

.card:hover{
    transform:translateY(-6px);
    box-shadow:0 20px 45px rgba(15,23,42,.1);
}

/* ============ STAT CARDS ============ */

.stat-card{
    position:relative;
    overflow:hidden;
    background:#fff;
    border:1px solid #EEF2F6;
    border-radius:20px;
    padding:22px;
    box-shadow:0 4px 14px rgba(15,23,42,.04);
    height:100%;
    transition:.2s ease;
}

.stat-card:hover{
    transform:translateY(-6px);
    box-shadow:0 20px 45px rgba(15,23,42,.1);
}

.stat-icon{
    width:52px;
    height:52px;
    border-radius:16px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:1.4rem;
    margin-bottom:18px;
}

.stat-value{
    font-weight:800;
    font-size:2rem;
    margin-bottom:2px;
}

.stat-label{
    color:#64748B;
    font-weight:600;
    font-size:.85rem;
    margin-bottom:0;
}

.stat-blob{
    position:absolute;
    width:110px;
    height:110px;
    border-radius:50%;
    right:-30px;
    bottom:-30px;
    opacity:.5;
    z-index:0;
}

.stat-card > *:not(.stat-blob){
    position:relative;
    z-index:1;
}

.stat-card--green .stat-icon{ background:#E8EEFA; color:#1E3A8A; }
.stat-card--green .stat-blob{ background:#E8EEFA; }

.stat-card--blue .stat-icon{ background:#EFF6FF; color:#3B82F6; }
.stat-card--blue .stat-blob{ background:#EFF6FF; }

.stat-card--teal .stat-icon{ background:#F0F9FF; color:#0284C7; }
.stat-card--teal .stat-blob{ background:#F0F9FF; }

.stat-card--amber .stat-icon{ background:#FFFBEB; color:#D97706; }
.stat-card--amber .stat-blob{ background:#FFFBEB; }

/* ============ BUTTONS ============ */

.btn{
    border-radius:12px;
    font-weight:600;
    padding:10px 22px;
    transition:.25s ease;
}

.btn:hover{
    transform:translateY(-2px);
}

.btn-success{
    background:var(--brand-green);
    border:none;
}

.btn-success:hover{
    background:var(--brand-green-dark);
}

/* ============ BADGES ============ */

.badge{
    border-radius:20px;
    padding:8px 12px;
    font-weight:600;
}

/* ============ PROGRESS ============ */

.progress{
    background:#edf2f7;
}

.progress-bar{
    font-weight:600;
}

/* ============ FOOTER ============ */

footer{
    background:var(--navy-950);
    color:#fff;
    margin-top:80px;
    padding:70px 0;
}

footer h4{
    font-weight:800;
}

footer p{
    color:#CBD5E1;
}

footer small{
    color:#94A3B8;
}

/* ============ DARK MODE ============ */

.dark-mode{
    background:#0f172a;
    color:#fff;
}

.dark-mode .card,
.dark-mode .stat-card{
    background:#1e293b;
    color:#fff;
}

.dark-mode .text-muted,
.dark-mode .stat-label{
    color:#b8c0cc !important;
}

.dark-mode .topbar{
    background:#111827 !important;
    border-color:#1f2937;
}

.dark-mode footer{
    background:#111827 !important;
}

.dark-mode .list-group-item{
    background:#1e293b;
    color:#fff;
    border-color:#334155;
}

.dark-mode .btn-outline-primary{
    color:#fff;
    border-color:#fff;
}

.dark-mode .btn-outline-warning{
    color:#ffd54f;
}

.dark-mode .progress{
    background:#374151;
}

.dark-mode input,
.dark-mode select,
.dark-mode textarea{
    background:#334155;
    color:#fff;
    border:none;
}

.dark-mode input::placeholder{
    color:#cbd5e1;
}

.sidebar-user{
    display:flex;
    align-items:center;
    gap:12px;
}
.sidebar-user-avatar{
    width:38px;
    height:38px;
    border-radius:50%;
    background:var(--brand-green);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:700;
    color:#fff;
    flex-shrink:0;
}
.sidebar-user-info{
    min-width:0;
}
.sidebar-user-info p{
    color:#fff;
    font-size:.9rem;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.logout-form{
    margin:0;
}
.logout-btn{
    background:none;
    border:none;
    color:#94A3B8;
    font-size:.78rem;
    padding:0;
    text-decoration:underline;
}
.logout-btn:hover{
    color:#fff;
}

/* ============ AUTH LANDING PAGE ============ */

.auth-landing{
    display:flex;
    min-height:100vh;
    font-family:"Manrope",sans-serif;
}

.auth-left{
    flex:1;
    background:linear-gradient(160deg,#050E1F 0%,#0A1F44 55%,#123A78 100%);
    display:flex;
    align-items:center;
    padding:60px;
    color:#fff;
}

.auth-left-inner{
    max-width:520px;
}

.auth-brand{
    display:flex;
    align-items:center;
    gap:12px;
    margin-bottom:48px;
}

.auth-brand-text{
    font-weight:800;
    font-size:1.3rem;
}

.auth-headline{
    font-weight:800;
    font-size:2.6rem;
    line-height:1.2;
    margin-bottom:22px;
}

.text-highlight{
    color:var(--navy-accent);
}

.auth-subtext{
    color:#CBD5E1;
    font-size:1.05rem;
    margin-bottom:36px;
}

.auth-checklist{
    list-style:none;
    padding:0;
    margin:0;
    display:flex;
    flex-direction:column;
    gap:18px;
}

.auth-checklist li{
    display:flex;
    align-items:center;
    gap:14px;
    color:#E2E8F0;
    font-weight:500;
}

.check-dot{
    width:26px;
    height:26px;
    border-radius:50%;
    background:rgba(34,211,238,.15);
    color:var(--navy-accent);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:.8rem;
    flex-shrink:0;
}

.auth-right{
    flex:1;
    display:flex;
    align-items:center;
    justify-content:center;
    background:#F4F7FB;
    padding:40px;
}

.auth-card{
    background:#fff;
    border-radius:24px;
    padding:44px;
    width:100%;
    max-width:440px;
    box-shadow:0 20px 60px rgba(15,23,42,.1);
}

.auth-card-brand{
    font-weight:800;
    font-size:1.5rem;
    color:#0F172A;
}

.auth-tabs{
    display:flex;
    background:#F1F5F9;
    border-radius:12px;
    padding:4px;
    margin-bottom:26px;
}

.auth-tab{
    flex:1;
    border:none;
    background:transparent;
    padding:10px;
    border-radius:9px;
    font-weight:700;
    font-size:.9rem;
    color:#64748B;
    transition:.2s;
}

.auth-tab.active{
    background:#fff;
    color:#0F172A;
    box-shadow:0 2px 8px rgba(15,23,42,.08);
}

.auth-form{
    display:none;
}

.auth-form.active{
    display:block;
}

.auth-divider{
    display:flex;
    align-items:center;
    text-align:center;
    color:#94A3B8;
    font-size:.8rem;
    font-weight:600;
    margin:22px 0;
}

.auth-divider::before,
.auth-divider::after{
    content:"";
    flex:1;
    height:1px;
    background:#E2E8F0;
}

.auth-divider span{
    padding:0 14px;
}

/* Loading overlay */

.auth-loading{
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.85);
    display:none;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    z-index:2000;
    gap:22px;
}

.auth-loading.show{
    display:flex;
}

.auth-spinner{
    width:56px;
    height:56px;
    border-radius:50%;
    border:4px solid rgba(255,255,255,.15);
    border-top-color:var(--brand-green);
    animation:auth-spin .8s linear infinite;
}

@keyframes auth-spin{
    to{ transform:rotate(360deg); }
}

.auth-loading-text{
    color:#fff;
    font-weight:800;
    font-size:1.1rem;
    letter-spacing:.3px;
}

/* Mobile: stack panels */

@media (max-width:991px){
    .auth-landing{
        flex-direction:column;
    }
    .auth-left{
        padding:40px 24px;
    }
    .auth-headline{
        font-size:2rem;
    }
    .auth-right{
        padding:24px;
    }
    .auth-card{
        padding:30px;
    }
}

.auth-tagline{
    color:var(--navy-accent);
    font-weight:700;
    font-size:.85rem;
    text-transform:uppercase;
    letter-spacing:1.2px;
    margin-bottom:14px;
}

.ai-answer-text{
    background:var(--navy-tint);
    border-radius:14px;
    padding:18px 20px;
    line-height:1.7;
}

/* ============ AI CHAT ============ */

.ai-chat-wrapper{
    flex:1;
    display:flex;
    flex-direction:column;
    min-width:0;
}

.ai-chat-header{
    padding-bottom:18px;
}

.ai-chat-messages{
    flex:1;
    overflow-y:auto;
    padding:10px 4px 20px;
    display:flex;
    flex-direction:column;
    gap:16px;
}

.ai-bubble{
    display:flex;
    gap:12px;
    max-width:80%;
}

.ai-bubble--user{
    align-self:flex-end;
    flex-direction:row-reverse;
}

.ai-bubble--ai{
    align-self:flex-start;
}

.ai-bubble-avatar{
    width:34px;
    height:34px;
    border-radius:50%;
    background:var(--brand-green);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:700;
    font-size:.72rem;
    flex-shrink:0;
}

.ai-bubble-content{
    padding:14px 18px;
    border-radius:18px;
    line-height:1.6;
}

.ai-bubble--user .ai-bubble-content{
    background:var(--brand-green);
    color:#fff;
    border-bottom-right-radius:4px;
}

.ai-bubble--ai .ai-bubble-content{
    background:#fff;
    box-shadow:0 4px 16px rgba(15,23,42,.06);
    border-bottom-left-radius:4px;
}

.ai-empty-state{
    margin:auto;
    text-align:center;
    padding:60px 20px;
}

.ai-chat-input-bar{
    display:flex;
    align-items:flex-end;
    gap:10px;
    background:#fff;
    border-radius:20px;
    padding:10px 10px 10px 20px;
    box-shadow:0 8px 24px rgba(15,23,42,.08);
}

.ai-chat-input-bar textarea{
    flex:1;
    border:none;
    outline:none;
    resize:none;
    max-height:120px;
    font-family:"Manrope",sans-serif;
    font-size:.95rem;
    padding:10px 0;
    background:transparent;
}

.ai-chat-input-bar textarea:focus{
    outline:none;
    box-shadow:none;
}

.ai-chat-input-bar button{
    width:42px;
    height:42px;
    border-radius:50%;
    border:none;
    background:var(--brand-green);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    transition:.2s;
}

.ai-chat-input-bar button:hover{
    background:var(--brand-green-dark);
}

@media (max-width:768px){
    .ai-chat-wrapper{
        height:calc(100vh - 160px);
    }
    .ai-bubble{
        max-width:92%;
    }
}

.ai-page{
    display:flex;
    gap:20px;
    height:calc(100vh - 110px);
}

.ai-chat-list{
    width:260px;
    flex-shrink:0;
    background:#fff;
    border-radius:18px;
    box-shadow:0 4px 16px rgba(15,23,42,.06);
    padding:16px;
    display:flex;
    flex-direction:column;
    gap:14px;
    overflow-y:auto;
}

.ai-new-chat-btn{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    background:var(--brand-green);
    color:#fff;
    border-radius:12px;
    padding:10px;
    font-weight:600;
    text-decoration:none;
    font-size:.9rem;
}

.ai-new-chat-btn:hover{
    background:var(--brand-green-dark);
    color:#fff;
}

.ai-chat-list-items{
    display:flex;
    flex-direction:column;
    gap:4px;
    overflow-y:auto;
}

.ai-chat-list-item{
    display:flex;
    align-items:center;
    justify-content:space-between;
    border-radius:10px;
}

.ai-chat-list-item.active,
.ai-chat-list-item:hover{
    background:#F1F5F9;
}

.ai-chat-list-link{
    display:flex;
    align-items:center;
    gap:10px;
    color:#334155;
    text-decoration:none;
    font-size:.85rem;
    padding:8px 10px;
    flex:1;
    min-width:0;
}

.ai-chat-list-link span{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.ai-chat-delete{
    color:#94A3B8;
    padding:8px 10px;
    font-size:.85rem;
}

.ai-chat-delete:hover{
    color:#DC2626;
}

@media (max-width:768px){
    .ai-page{
        flex-direction:column;
        height:auto;
    }
    .ai-chat-list{
        width:100%;
        max-height:160px;
    }
    .ai-chat-wrapper{
        height:calc(100vh - 320px);
    }
}

.ai-attach-btn{
    width:38px;
    height:38px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    color:#64748B;
    cursor:pointer;
    flex-shrink:0;
    transition:.2s;
}

.ai-attach-btn:hover{
    background:#F1F5F9;
    color:var(--brand-green);
}

.ai-file-preview{
    font-size:.78rem;
    color:#64748B;
    padding:6px 20px 0;
    margin:0;
}

.ai-attachment-image{
    max-width:220px;
    border-radius:12px;
    display:block;
    margin-bottom:8px;
}

.ai-attachment-file{
    display:flex;
    align-items:center;
    gap:8px;
    background:rgba(255,255,255,.15);
    border-radius:10px;
    padding:8px 12px;
    margin-bottom:8px;
    color:inherit;
    text-decoration:none;
    font-size:.85rem;
}

.ai-bubble--ai .ai-attachment-file{
    background:#F1F5F9;
}

.ai-mic-btn{
    width:38px;
    height:38px;
    border-radius:50%;
    border:none;
    background:transparent;
    color:#64748B;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    transition:.2s;
}

.ai-mic-btn:hover{
    background:#F1F5F9;
    color:var(--brand-green);
}

.ai-mic-btn.listening{
    background:#FEE2E2;
    color:#DC2626;
    animation:mic-pulse 1s infinite;
}

@keyframes mic-pulse{
    0%, 100%{ transform:scale(1); }
    50%{ transform:scale(1.12); }
}

/* ============ GLOBAL RESPONSIVE SAFETY ============ */

html, body{
    overflow-x:hidden;
    max-width:100%;
}

*{
    min-width:0;
}

h1, h2, h3, h4, h5, h6, p, span, a, .card-body{
    overflow-wrap:break-word;
    word-break:break-word;
}

.auth-headline{
    font-size:clamp(1.6rem, 5vw, 2.6rem);
}

.stat-value{
    font-size:clamp(1.4rem, 4vw, 2rem);
}

.stat-card,
.card{
    min-width:0;
}

.row > *{
    min-width:0;
}

.sidebar-user-info,
.ai-chat-list-link span,
.brand-text{
    overflow-wrap:normal;
}

@media (max-width:576px){
    .card-body{
        padding:1.25rem !important;
    }
    .stat-icon{
        width:44px;
        height:44px;
        font-size:1.1rem;
    }
    .auth-card{
        padding:24px !important;
    }
    .ai-chat-messages{
        padding:6px 2px 14px;
    }
}

.dashboard-greeting{
    padding:4px 2px;
}

.greeting-date{
    color:#94A3B8;
    font-size:.78rem;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.6px;
    margin-bottom:6px;
}


/* ============ NAVY THEME: BOOTSTRAP OVERRIDES ============ */

:root{
    --bs-primary: #1E3A8A;
    --bs-primary-rgb: 30, 58, 138;
    --bs-primary-text-emphasis: #172554;
    --bs-primary-bg-subtle: #DBEAFE;
    --bs-primary-border-subtle: #BFDBFE;

    --bs-success: #1E3A8A;
    --bs-success-rgb: 30, 58, 138;
    --bs-success-text-emphasis: #172554;
    --bs-success-bg-subtle: #DBEAFE;
    --bs-success-border-subtle: #BFDBFE;

    --bs-link-color: #1E3A8A;
    --bs-link-color-rgb: 30, 58, 138;
    --bs-link-hover-color: #172554;
    --bs-link-hover-color-rgb: 23, 37, 84;
}

.btn-success,
.btn-primary{
    --bs-btn-bg: #1E3A8A;
    --bs-btn-border-color: #1E3A8A;
    --bs-btn-hover-bg: #172554;
    --bs-btn-hover-border-color: #172554;
    --bs-btn-active-bg: #0F1D44;
    --bs-btn-active-border-color: #0F1D44;
    --bs-btn-disabled-bg: #1E3A8A;
    --bs-btn-disabled-border-color: #1E3A8A;
    --bs-btn-focus-shadow-rgb: 30, 58, 138;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}

.btn-outline-success,
.btn-outline-primary{
    --bs-btn-color: #1E3A8A;
    --bs-btn-border-color: #1E3A8A;
    --bs-btn-hover-bg: #1E3A8A;
    --bs-btn-hover-border-color: #1E3A8A;
    --bs-btn-active-bg: #172554;
    --bs-btn-active-border-color: #172554;
}

.form-control:focus,
.form-select:focus{
    border-color: #1E3A8A;
    box-shadow: 0 0 0 .2rem rgba(30, 58, 138, .18);
}

.form-check-input:checked{
    background-color: #1E3A8A;
    border-color: #1E3A8A;
}
