/* ========= Login ========= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1c2e 0%, #2d3561 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 12px;
}
.login-logo {
    margin-bottom: 0.5rem;
}
.login-logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
}
.sidebar-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
}

/* ========= Sidebar ========= */
.sidebar {
    width: 240px;
    min-height: 100vh;
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed {
    width: 60px;
}
.sidebar.collapsed .sidebar-header span {
    display: none;
}
.sidebar.collapsed .sidebar-header a {
    justify-content: center;
}
.sidebar.collapsed .sidebar-logo {
    margin-right: 0 !important;
}
.sidebar.collapsed small.nav-link {
    display: none;
}
.sidebar.collapsed .nav-link {
    font-size: 0;
    text-align: center;
    padding: 0.6rem 0.5rem;
}
.sidebar.collapsed .nav-link i {
    font-size: 1.1rem;
    margin-right: 0 !important;
}
.sidebar .nav-link {
    color: #a0aec0;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    margin: 2px 0;
    font-size: 0.9rem;
    white-space: nowrap;
}
.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.sidebar .nav-link.active {
    color: #fff;
    background: #4f46e5;
}
.sidebar-header {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ========= Main Content ========= */
.main-content {
    min-height: 100vh;
    background: #f5f7fb;
}
.content-area {
    max-width: 1400px;
}

/* ========= Cards ========= */
.stat-card {
    border: none;
    border-radius: 10px;
    transition: transform 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

/* ========= Tables ========= */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #6b7280;
    border-bottom-width: 1px;
}
.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

/* ========= Upload ========= */
.upload-zone {
    border: 2px dashed #c7d2fe;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8faff;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: #4f46e5;
    background: #eef2ff;
}
.upload-zone .upload-icon {
    font-size: 3rem;
    color: #4f46e5;
}

/* ========= Analysis Results ========= */
.analysis-card {
    border: none;
    border-radius: 10px;
}
.analysis-card .card-header {
    border-radius: 10px 10px 0 0;
    font-weight: 600;
}
.cost-breakdown-table td:last-child,
.cost-breakdown-table th:last-child {
    text-align: right;
}
.total-row {
    font-weight: 700;
    font-size: 1.1rem;
    background: #f0fdf4;
}

/* ========= Badge ========= */
.badge {
    font-weight: 500;
    font-size: 0.78rem;
    padding: 0.35em 0.65em;
}

/* ========= Responsive ========= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .content-area {
        padding: 1rem !important;
    }
}

/* ========= Loading spinner ========= */
.spinner-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}
.spinner-overlay.active {
    display: flex;
}

/* ========= Chat Widget ========= */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1060;
}
.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4f46e5;
    color: #fff;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-toggle-btn:hover {
    background: #4338ca;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}
.chat-toggle-btn.chat-toggle-active {
    background: #6366f1;
}
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 420px;
    height: 540px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s ease-out;
}
@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-header {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chat-header .btn-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 2px 6px;
    font-size: 1rem;
}
.chat-header .btn-link:hover {
    color: #fff;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafbfc;
}
.chat-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-bubble.user {
    align-self: flex-end;
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
    align-self: flex-start;
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.chat-bubble.assistant p { margin: 0 0 8px; }
.chat-bubble.assistant p:last-child { margin-bottom: 0; }
.chat-bubble.assistant table {
    font-size: 0.78rem;
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
}
.chat-bubble.assistant table th,
.chat-bubble.assistant table td {
    border: 1px solid #e5e7eb;
    padding: 4px 6px;
    text-align: left;
}
.chat-bubble.assistant table th {
    background: #f3f4f6;
    font-weight: 600;
}
.chat-bubble.assistant code {
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.8rem;
}
.chat-bubble.assistant ul, .chat-bubble.assistant ol {
    margin: 4px 0;
    padding-left: 18px;
}
.chat-file-preview {
    padding: 8px 12px;
    background: #f0f4ff;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.8rem;
    color: #374151;
}
.chat-file-preview .text-truncate {
    max-width: 260px;
}
.chat-file-label {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-bottom: 2px;
}
.chat-attach-btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.chat-dragover {
    background: #eef2ff !important;
    outline: 2px dashed #4f46e5;
    outline-offset: -4px;
}
.chat-input {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.chat-input .form-control {
    border-radius: 20px;
    padding-left: 16px;
    font-size: 0.875rem;
}
.chat-input .btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: chatTyping 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: -8px;
    }
}
