﻿        :root {
            --primary: #1e293b;
            --primary-hover: #0f172a;
            --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            --chat-bg: rgba(255, 255, 255, 0.8);
            --text-main: #1e293b;
            --text-muted: #64748b;
            --user-msg: #ff7b00;
            --bot-msg: #ffffff;
            --glass: rgba(255, 255, 255, 0.7);
            --glass-border: rgba(255, 255, 255, 0.3);
            --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
            --max-width: 800px;
        }

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

        body {
            font-family: 'Outfit', sans-serif;
            background: var(--bg-gradient);
            background-attachment: fixed;
            height: 100vh;
            color: var(--text-main);
            display: flex;
            flex-direction: column;
            align-items: center;
            overflow-x: hidden;
        }

        /* ================= HEADER ================= */
        header {
            width: 100%;
            max-width: var(--max-width);
            height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--glass);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--glass-border);
            padding: 0 20px;
            position: fixed;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            z-index: 100;
            border-radius: 0 0 24px 24px;
            box-shadow: var(--shadow);
        }

        .header-content {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            position: relative;
        }

        header h1 {
            font-size: 1.5rem;
            font-weight: 700;
            letter-spacing: -0.03em;
            color: var(--text-main);
        }

        .logo-picture {
            position: absolute;
            left: 0;
            display: flex;
            align-items: center;
        }

        .logo-picture img {
            width: auto;
            height: 45px;
            object-fit: contain;
        }

        .voice-btn {
            position: absolute;
            right: 0;
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: var(--user-msg);
            color: white;
            text-decoration: none;
            border-radius: 12px;
            font-weight: 600;
            font-size: 0.9rem;
            transition: all 0.2s;
            box-shadow: 0 4px 12px rgba(255, 123, 0, 0.2);
        }

        .voice-btn:hover {
            background: #e66e00;
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(255, 123, 0, 0.3);
        }

        .voice-btn svg {
            width: 18px;
            height: 18px;
        }

        @media (max-width: 640px) {
            .voice-btn span {
                display: none;
            }
            .voice-btn {
                padding: 10px;
            }
        }

        /* ================= CHAT AREA ================= */
        main {
            width: 100%;
            max-width: var(--max-width);
            flex: 1;
            display: flex;
            flex-direction: column;
            padding-top: 90px;
            padding-bottom: 100px;
            overflow: hidden;
            position: relative;
        }

        #messages {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 16px;
            scroll-behavior: smooth;
        }

        /* Custom Scrollbar */
        #messages::-webkit-scrollbar {
            width: 6px;
        }

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

        #messages::-webkit-scrollbar-thumb {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }

        .msg {
            max-width: 85%;
            padding: 14px 18px;
            border-radius: 20px;
            font-size: 0.95rem;
            line-height: 1.5;
            position: relative;
            animation: fadeIn 0.3s ease-out forwards;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
            white-space: pre-wrap;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .user {
            align-self: flex-end;
            background: var(--user-msg);
            color: white;
            border-bottom-right-radius: 4px;
            box-shadow: 0 4px 12px rgba(255, 123, 0, 0.2);
        }

        .bot {
            align-self: flex-start;
            background: var(--bot-msg);
            color: var(--text-main);
            border-bottom-left-radius: 4px;
            border: 1px solid rgba(0, 0, 0, 0.05);
            position: relative;
            padding-right: 40px;
        }

        .copy-btn {
            position: absolute;
            top: 8px;
            right: 8px;
            background: transparent;
            border: none;
            cursor: pointer;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            color: var(--text-muted);
            transition: all 0.2s ease;
            opacity: 0.5;
        }

        .copy-btn:hover {
            background: rgba(0, 0, 0, 0.05);
            color: var(--primary);
            opacity: 1;
        }

        .copy-btn svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
        }

        .copy-btn.copied {
            color: #10b981;
        }

        .action-btn {
            background: rgba(0, 0, 0, 0.05);
            border: none;
            border-radius: 6px;
            padding: 12px 18px;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-main);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s;
            margin-top: 4px;
        }

        .action-btn:hover {
            background: var(--primary);
            color: white;
        }

        .action-btn svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
        }

        /* ================= INPUT AREA ================= */
        .input-container {
            width: 100%;
            max-width: var(--max-width);
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 0 20px;
            z-index: 100;
        }

        .input-wrapper {
            background: var(--glass);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid var(--glass-border);
            border-radius: 24px;
            padding: 8px 8px 8px 16px;
            display: flex;
            align-items: center;
            gap: 12px;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            transition: all 0.3s ease;
        }

        .input-wrapper:focus-within {
            border-color: #cbd5e1;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
        }

        textarea {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            resize: none;
            padding: 12px 0;
            font-family: inherit;
            font-size: 1rem;
            color: var(--text-main);
            max-height: 150px;
        }

        textarea::placeholder {
            color: var(--text-muted);
        }

        button#sendBtn {
            width: 48px;
            height: 48px;
            background: var(--primary);
            border: none;
            border-radius: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            color: white;
            flex-shrink: 0;
        }

        button#sendBtn:hover {
            background: var(--primary-hover);
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
        }

        button#sendBtn:active {
            transform: scale(0.95);
        }

        button#sendBtn svg {
            width: 20px;
            height: 20px;
            fill: currentColor;
        }

        /* Loading indicator */
        .typing {
            display: flex;
            gap: 4px;
            padding: 10px;
        }

        .dot {
            width: 6px;
            height: 6px;
            background: var(--text-muted);
            border-radius: 50%;
            animation: bounce 1.4s infinite ease-in-out both;
        }

        .dot:nth-child(1) {
            animation-delay: -0.32s;
        }

        .dot:nth-child(2) {
            animation-delay: -0.16s;
        }

        @keyframes bounce {

            0%,
            80%,
            100% {
                transform: scale(0);
            }

            40% {
                transform: scale(1.0);
            }
        }

        /* Responsive adjustments */
        @media (max-width: 640px) {
            header {
                height: 64px;
                border-radius: 0;
            }

            .logo-picture img {
                height: 28px;
            }

            main {
                padding-top: 74px;
            }

            .msg {
                max-width: 90%;
            }

            .input-container {
                bottom: 10px;
                padding: 0 10px;
            }

            .input-wrapper {
                border-radius: 20px;
            }
        }

        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(8px);
            z-index: 2000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 0;
        }

        .modal-content {
            background: white;
            width: 100%;
            max-width: 100%;
            height: 100vh;
            border-radius: 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: none;
        }

        .modal-header {
            padding: 12px 25px;
            border-bottom: 1px solid #f1f5f9;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #fff;
            gap: 15px;
            flex-wrap: wrap;
        }

        .search-input-container {
            width: 420px;
            max-width: 100%;
        }


        @media (max-width: 768px) {
            .search-input-container {
                width: 100% !important;
            }
            .modal-header {
                padding: 10px 15px !important;
                gap: 8px !important;
                flex-wrap: wrap !important;
            }
            /* Title row stays full-width, filters wrap below */
            .modal-header > div:first-child {
                flex: 1 1 100%;
            }
            .search-filters-header-group {
                flex: 1 1 100% !important;
                width: 100% !important;
                gap: 8px !important;
                justify-content: flex-start !important;
            }
            .search-filters-header-group .search-input-container {
                margin: 0 !important;
            }
            /* Row 1 on Mobile: Buscar (50%) + Nome Orçamento (50%) */
            .search-filters-header-group .buscar-container {
                flex: 1 1 calc(50% - 4px) !important;
                max-width: none !important;
                min-width: 0 !important;
            }
            .search-filters-header-group .ident-container {
                flex: 1 1 calc(50% - 4px) !important;
                max-width: none !important;
                min-width: 0 !important;
                width: auto !important;
            }
            /* Row 2 on Mobile: UF (85px) + Filtros (flex) + Carrinho (flex) */
            .search-filters-header-group .uf-container {
                width: 85px !important;
                flex: 0 0 85px !important;
            }
            .catalog-search-input {
                font-size: 0.78rem !important;
                height: 36px !important;
                padding: 8px 10px 8px 28px !important;
            }
            #budgetUFSelect {
                padding: 8px 20px 8px 26px !important;
            }
            .search-filters-header-group .search-input-container svg {
                left: 8px !important;
                width: 14px !important;
                height: 14px !important;
            }
            #budgetUFSelect + span {
                right: 6px !important;
            }
            .filters-toggle-btn {
                padding: 8px 10px !important;
                font-size: 0.8rem !important;
                height: 36px !important;
                flex: 1 1 auto !important;
                min-width: 0 !important;
                width: auto !important;
                justify-content: center !important;
            }
        }

        .filters-toggle-btn {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 20px;
            border: 1px solid #e2e8f0;
            background: white;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #475569;
            cursor: pointer;
            height: 40px;
            box-sizing: border-box;
            transition: all 0.2s;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
            outline: none;
        }

        .filters-toggle-btn:hover {
            border-color: var(--user-msg);
            color: var(--user-msg);
            background: #f8fafc;
        }

        .filters-toggle-btn.active {
            background: var(--user-msg);
            border-color: var(--user-msg);
            color: white;
        }

        .filters-sidebar {
            width: 320px;
            min-width: 320px;
            max-width: 320px;
            height: 100%;
            background: #f8fafc;
            border-left: 1px solid #e2e8f0;
            padding: 20px 24px;
            box-sizing: border-box;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            transform: translateX(100%);
            position: absolute;
            right: 0;
            top: 0;
            z-index: 100;
            box-shadow: -4px 0 16px rgba(0, 0, 0, 0.05);
        }

        #cartSidebar {
            z-index: 101;
        }

        .filters-sidebar.active {
            transform: translateX(0);
        }
        
        .sidebar-filters-content .tabela-search-container {
            width: 100% !important;
            max-width: none !important;
            min-width: 0 !important;
            flex: none !important;
        }

        .catalog-search-input {
            width: 100%;
            padding: 12px 20px;
            border-radius: 12px;
            border: 1px solid #e2e8f0;
            font-family: inherit;
            font-size: 0.95rem;
            outline: none;
            transition: all 0.2s;
        }

        .catalog-search-input:focus {
            border-color: var(--user-msg);
            box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.05);
        }

        /* --- Searchable Dropdown: Tabela de Preço --- */
        .tabela-search-container {
            position: relative;
            flex: 1 1 200px;
            min-width: 180px;
            max-width: 350px;
        }

        .tabela-input-wrapper {
            position: relative;
            display: flex;
            align-items: center;
        }

        .tabela-search-input {
            width: 100%;
            padding: 10px 32px 10px 14px;
            border-radius: 20px;
            border: 1px solid #e2e8f0;
            background: white;
            font-size: 0.82rem;
            font-weight: 600;
            color: #1e293b;
            outline: none;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
            height: 44px;
            box-sizing: border-box;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
            transition: all 0.2s;
        }

        .tabela-search-input:focus {
            border-color: var(--user-msg);
            box-shadow: 0 0 0 3px rgba(255, 123, 0, 0.1);
        }

        .tabela-arrow {
            position: absolute;
            right: 12px;
            font-size: 0.65rem;
            color: #64748b;
            pointer-events: none;
        }

        .tabela-dropdown-menu {
            display: none;
            position: absolute;
            top: calc(100% + 4px);
            left: 0;
            width: 100%;
            max-height: 220px;
            overflow-y: auto;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
            z-index: 2050;
            padding: 6px 0;
        }

        .tabela-dropdown-menu.active,
        .tabela-dropdown-menu.open {
            display: block;
        }

        .tabela-option {
            padding: 10px 14px;
            font-size: 0.82rem;
            font-weight: 500;
            color: #334155;
            cursor: pointer;
            transition: background 0.15s;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .tabela-option:hover,
        .tabela-option.selected {
            background: #fff7ed;
            color: var(--user-msg);
            font-weight: 600;
        }

        @media (max-width: 768px) {
            .tabela-search-container {
                width: 100%;
                max-width: none;
                flex: none !important;
            }
            .filters-sidebar {
                width: 100% !important;
                min-width: 100% !important;
                max-width: 100% !important;
            }
        }

        .modal-body {
            flex: 1;
            display: flex;
            overflow: hidden;
        }

        .catalog-spinner {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.75);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
        }

        .catalog-spinner.active {
            opacity: 1;
            pointer-events: auto;
        }
        
        .spinner-circle {
            width: 42px;
            height: 42px;
            border: 4px solid #f1f5f9;
            border-top: 4px solid var(--user-msg);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .catalog-grid {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            overflow-x: hidden;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
            gap: 16px;
            align-content: start;
            background: #f8fafc;
            min-height: 0; /* critical: allows flex child to shrink and scroll */
        }

        .catalog-item {
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            padding: 12px;
            display: flex;
            flex-direction: row;
            align-items: flex-start;
            gap: 16px;
            background: white;
            transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
        }

        .catalog-item:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            border-color: #cbd5e1;
            transform: translateY(-2px);
        }

        .catalog-img {
            width: 100px;
            height: 100px;
            object-fit: cover;
            border-radius: 8px;
            background: #f1f5f9;
            flex-shrink: 0;
            border: 1px solid #e2e8f0;
        }

        .catalog-name {
            font-weight: 600;
            font-size: 0.9rem;
            color: #1e293b;
            margin-bottom: 4px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.2;
        }

        .catalog-desc {
            font-size: 0.85rem;
            color: #64748b;
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .qty-controls {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-top: 8px;
            background: #f8fafc;
            border-radius: 20px;
            padding: 4px 12px;
            width: fit-content;
            border: 1px solid #e2e8f0;
        }

        .qty-btn {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: white;
            border: 1px solid #cbd5e1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 1.2rem;
            color: var(--user-msg);
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .qty-btn:hover {
            background: #fff7ed;
            border-color: #fed7aa;
        }

        .qty-val {
            font-weight: 600;
            font-size: 1rem;
            color: #1e293b;
            min-width: 24px;
            text-align: center;
        }

        /* --- Card Actions Wrapper & Groups (Vertical Stack - Large Buttons) --- */
        .card-actions-wrapper {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
            margin-top: 8px;
        }

        .card-action-group {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        /* Doubled width for Mkp and Qtd controls container */
        .card-action-group .qty-controls {
            width: 130px;
            justify-content: space-between;
            box-sizing: border-box;
            margin-top: 0;
            padding: 4px 6px;
            gap: 4px;
            border-radius: 20px;
        }

        /* Doubled button sizes */
        .card-action-group .qty-btn {
            width: 32px !important;
            height: 32px !important;
            min-width: 32px !important;
            max-width: 32px !important;
            flex-shrink: 0 !important;
            border-radius: 50% !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            font-size: 1.2rem !important;
            line-height: 1 !important;
        }

        /* Doubled input and text inside controls */
        .card-action-group .markup-val,
        .card-action-group .qty-val {
            width: 36px !important;
            min-width: 36px !important;
            max-width: 36px !important;
            text-align: center !important;
            font-size: 1.1rem !important;
            font-weight: 600 !important;
            padding: 0 !important;
            margin: 0 !important;
            font-family: inherit !important;
        }

        .modal-footer {
            padding: 20px;
            border-top: 1px solid #e2e8f0;
            display: flex;
            flex-direction: column;
            gap: 15px;
            background: #fff;
        }

        .confirm-selection {
            width: 100%;
            padding: 16px;
            border-radius: 12px;
            background: var(--user-msg);
            color: white;
            font-weight: 700;
            font-size: 1.1rem;
            border: none;
            cursor: pointer;
            transition: background 0.2s, transform 0.1s;
            box-shadow: 0 4px 12px rgba(255, 123, 0, 0.3);
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .confirm-selection:hover {
            background: #e66e00;
            transform: translateY(-1px);
        }

        .pagination {
            display: none !important;
        }

        .page-btn {
            padding: 6px 12px;
            border: 1px solid #e2e8f0;
            background: white;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }

        .page-btn.active {
            background: var(--user-msg);
            color: white;
            border-color: var(--user-msg);
        }

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

        .close-modal {
            font-size: 1.5rem;
            cursor: pointer;
            border: none;
            background: transparent;
            color: #94a3b8;
            transition: color 0.2s;
        }

        .close-modal:hover {
            color: #1e293b;
        }

        .mobile-menu-btn {
            display: none;
            background: transparent;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #1e293b;
        }

        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 2004;
        }

        @media (max-width: 768px) {
            .catalog-grid {
                grid-template-columns: 1fr;
                padding: 15px;
                gap: 12px;
            }

            .catalog-item {
                padding: 12px;
                gap: 12px;
            }

            .catalog-img {
                width: 80px;
                height: 80px;
            }

            .modal-body {
                flex-direction: column;
            }



            .modal-content {
                height: 100vh;
                border-radius: 0;
            }

            .modal-overlay {
                padding: 0;
            }
        }
