/* MCOT Smart Sales - Main Styles
   Extracted from V9 single-file build. */

* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
body {
            font-family: 'Sarabun', sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
            color: #1e293b;
            overflow-x: hidden;
        }

        @supports (height: 100dvh) {
            body { min-height: 100dvh; }
            #sidebar, .sidebar-trigger { height: 100dvh; }
        }

        @media (pointer: coarse) {
            button,
            [role="button"],
            select,
            input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]) {
                min-height: 44px;
            }

            .modal-content {
                max-height: calc(100dvh - 24px);
                overscroll-behavior: contain;
            }
        }

        /* ===== Sidebar ===== */
        #sidebar {
            position: fixed;
            left: 0;
            top: 0;
            height: 100vh;
            width: 64px;
            background: linear-gradient(135deg, #0d3b66 0%, #1c5bb8 100%);
            color: white;
            z-index: 50;
            transition: width 0.3s ease;
            overflow: hidden;
            white-space: nowrap;
            box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        }
        
        #sidebar.expanded {
            width: 256px;
        }
        
        .sidebar-trigger {
            position: fixed;
            left: 0;
            top: 0;
            width: 14px;
            height: 100vh;
            background: transparent;
            z-index: 100;
            cursor: pointer;
        }
        
        .sidebar-trigger:hover {
            background: rgba(37, 99, 235, 0.1);
        }
        
        .sidebar-trigger::after {
            content: '';
            position: absolute;
            left: 4px;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 50px;
            background: rgba(255,255,255,0.3);
            border-radius: 4px;
            transition: all 0.2s;
        }
        
        .sidebar-trigger:hover::after {
            background: #f9a826;
            width: 6px;
            left: 3px;
            height: 60px;
        }
        
        #sidebar:not(.expanded) .sidebar-text {
            display: none;
        }
        
        #sidebar:not(.expanded) .menu-item {
            justify-content: center;
            padding: 14px 0;
        }
        
        #sidebar:not(.expanded) .menu-item i {
            margin: 0;
            font-size: 1.3rem;
        }
        
        #sidebar:not(.expanded) .sidebar-header h1,
        #sidebar:not(.expanded) .sidebar-header p,
        #sidebar:not(.expanded) .command-title,
        #sidebar:not(.expanded) .footer-text {
            display: none;
        }
        
        #sidebar:not(.expanded) .sidebar-header {
            padding: 20px 0;
        }
        
        #sidebar:not(.expanded) .sidebar-header .logo {
            margin: 0 auto;
            width: 42px;
            height: 42px;
            padding: 8px;
        }
        
        #main-content {
            margin-left: 64px;
            transition: margin-left 0.3s ease, width 0.3s ease;
            width: calc(100% - 64px);
        }
        
        #main-content.expanded {
            margin-left: 256px;
            width: calc(100% - 256px);
        }
        
        @media (max-width: 768px) {
            #sidebar {
                transform: translateX(-100%);
                width: 280px !important;
                box-shadow: 4px 0 20px rgba(0,0,0,0.3);
                transition: transform 0.3s ease;
                z-index: 1000;
            }
            
            #sidebar.expanded {
                transform: translateX(0) !important;
            }
            
            #main-content,
            #main-content.expanded {
                margin-left: 0 !important;
                width: 100% !important;
            }
            
            .sidebar-trigger {
                display: none;
            }
            
            .mobile-menu-btn {
                display: flex !important;
                position: fixed;
                top: 16px;
                left: 16px;
                z-index: 1001;
                background: linear-gradient(135deg, #0d3b66 0%, #1c5bb8 100%);
                color: white;
                border: none;
                border-radius: 12px;
                padding: 16px 18px;
                cursor: pointer;
                box-shadow: 0 6px 15px rgba(0,0,0,0.2);
                font-size: 1.4rem;
                align-items: center;
                justify-content: center;
                transition: all 0.2s;
                border: 2px solid rgba(255,255,255,0.2);
            }
            
            .mobile-menu-btn:active {
                transform: scale(0.95);
                background: #1c5bb8;
            }
            
            .mobile-menu-overlay {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                z-index: 999;
                display: none;
                backdrop-filter: blur(3px);
            }
            
            .mobile-menu-overlay.active {
                display: block !important;
            }
            
            #main-content {
                padding-top: 70px !important;
            }
            
            .mobile-w-full { width: 100% !important; }
            input, select, textarea { font-size: 16px !important; }
        }

        @media (min-width: 769px) {
            .mobile-menu-btn { display: none !important; }
        }
        
        .menu-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 20px;
            color: white;
            transition: all 0.2s;
            border-left: 4px solid transparent;
            width: 100%;
            background: transparent;
            border: none;
            cursor: pointer;
            font-size: 0.95rem;
        }
        
        .menu-item:hover { background: rgba(255, 255, 255, 0.15); }
        .menu-item.active {
            border-left-color: #f9a826;
            background: rgba(255, 255, 255, 0.2);
        }
        .menu-item i { width: 24px; text-align: center; font-size: 1.1rem; }
        
        .sidebar-header {
            display: flex; flex-direction: column; align-items: center;
            padding: 24px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .logo {
            background: white; padding: 10px; border-radius: 18px; margin-bottom: 12px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }
        .logo i { font-size: 1.8rem; color: #1c5bb8; }
        
        .command-title {
            font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.4);
            text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px;
        }
        
        .footer-text {
            font-size: 10px; text-align: center; color: rgba(255, 255, 255, 0.5);
            font-weight: 500; line-height: 1.5;
        }
        
        h1, h2, h3, h4, h5, h6 { font-family: 'Prompt', sans-serif; }
        .mcot-gradient { background: linear-gradient(135deg, #0d3b66 0%, #1c5bb8 100%); }
        .gold-border { border-color: #f9a826; }
        
        .animate-fadeIn { animation: fadeIn 0.3s ease-in-out; }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        @media print {
            @page {
                size: A4 portrait;
                margin: 1cm;
            }
            .no-print { display: none !important; }
            body { background: white !important; font-size: 10pt; }
            .print-report { display: block !important; width: 100%; margin: 0; padding: 0; }
            .print-report table { width: 100%; border-collapse: collapse; font-size: 8pt; }
            .print-report th {
                background-color: #e2e8f0 !important; color: black !important;
                -webkit-print-color-adjust: exact; print-color-adjust: exact;
            }
        }
        
        .custom-scrollbar::-webkit-scrollbar { width: 6px; }
        .custom-scrollbar::-webkit-scrollbar-track { background: #f1f5f9; }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: #cbd5e1; border-radius: 3px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
        
        .time-slot-btn {
            transition: all 0.2s;
            font-size: 0.7rem;
            cursor: pointer;
        }
        .time-slot-btn.selected {
            transform: scale(1.02);
            box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
        }
        
        .weekday-btn { 
            transition: all 0.2s; 
            cursor: pointer;
        }
        .weekday-btn.selected { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
        
        .order-type-btn.active {
            background-color: white;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
            color: #2563eb;
        }
        
        .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
        
        .product-category-tab { transition: all 0.2s; }
        .product-category-tab.active {
            background-color: #2563eb; color: white; border-color: #2563eb;
        }
        
        .package-product-item {
            transition: all 0.2s;
            cursor: default;
        }
        .package-product-item.selected {
            background-color: #eff6ff;
            border-color: #2563eb;
            border-width: 2px;
        }
        .package-product-item input[type="checkbox"] {
            cursor: pointer;
            pointer-events: auto;
            width: 18px;
            height: 18px;
        }
        .package-product-item label {
            cursor: pointer;
        }
        

        /* ===== AI Sales Assistant ===== */
        .ai-advisor-card {
            background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 100%);
            border: 1px solid #bfdbfe;
            border-left: 5px solid #2563eb;
            border-radius: 14px;
            padding: 14px;
            box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
        }
        .ai-advisor-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 10px;
        }
        .ai-advisor-title {
            font-weight: 900;
            color: #1e3a8a;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .ai-advisor-list {
            display: grid;
            gap: 8px;
        }
        .ai-advisor-item {
            display: flex;
            gap: 8px;
            align-items: flex-start;
            padding: 8px 10px;
            border-radius: 10px;
            font-size: 13px;
            line-height: 1.35;
        }
        .ai-advisor-item.warning { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
        .ai-advisor-item.suggest { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
        .ai-advisor-item.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
        .ai-advisor-action {
            background: #2563eb;
            color: white;
            border: none;
            border-radius: 10px;
            padding: 8px 12px;
            font-size: 12px;
            font-weight: 800;
            cursor: pointer;
            white-space: nowrap;
        }
        .ai-advisor-action:hover { background: #1d4ed8; }
        @media (max-width: 768px) {
            .ai-advisor-head { flex-direction: column; align-items: stretch; }
            .ai-advisor-action { width: 100%; }
        }

        .modal {
            display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(0, 0, 0, 0.5); z-index: 1000;
            align-items: center; justify-content: center;
        }
        .modal.show { display: flex; }
        .modal-content {
            background-color: white; border-radius: 1rem; padding: 2rem;
            max-width: 90%; max-height: 90%; overflow-y: auto;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        }
        
        .report-container { display: none; }
        .report-container.print-active { display: block; }
        .form-hidden { display: none !important; }

        .switch {
            position: relative; display: inline-block; width: 50px; height: 24px;
        }
        .switch input {
            opacity: 0; width: 0; height: 0;
        }
        .slider {
            position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
            background-color: #ccc; transition: .4s; border-radius: 24px;
        }
        .slider:before {
            position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px;
            background-color: white; transition: .4s; border-radius: 50%;
        }
        input:checked + .slider { background-color: #f97316; }
        input:checked + .slider:before { transform: translateX(26px); }
        
        .promotion-badge {
            background: linear-gradient(135deg, #f97316, #fb923c);
            color: white;
            font-weight: bold;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.75rem;
            display: inline-block;
        }
        

        /* ===== ควบคุมโปรโมชันต่อรายการในหน้า Order ===== */
        .order-promotion-control {
            background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
            border: 2px solid #fed7aa;
            border-radius: 12px;
            padding: 14px 16px;
            margin-top: -8px;
        }
        .order-promotion-control.disabled-state {
            background: #f8fafc;
            border-color: #e2e8f0;
            color: #64748b;
        }
        .order-promotion-title {
            font-size: 14px;
            font-weight: 800;
            color: #9a3412;
        }
        .order-promotion-desc {
            font-size: 12px;
            color: #7c2d12;
            margin-top: 2px;
        }
        .order-promotion-control.disabled-state .order-promotion-title,
        .order-promotion-control.disabled-state .order-promotion-desc {
            color: #64748b;
        }

        .promotion-message {
            background-color: #d1fae5;
            color: #065f46;
            padding: 0.5rem;
            border-radius: 0.5rem;
            font-size: 0.875rem;
            font-weight: 600;
            margin-top: 0.5rem;
        }
        
        .order-detail-modal {
            max-width: 800px;
            width: 90%;
        }
        
        .detail-section {
            background-color: #f8fafc;
            border-radius: 0.5rem;
            padding: 1rem;
            margin-bottom: 1rem;
        }
        
        .detail-label {
            font-size: 0.75rem;
            color: #64748b;
            text-transform: uppercase;
            font-weight: 600;
        }
        
        .detail-value {
            font-size: 1rem;
            font-weight: 600;
            color: #0f172a;
        }
        
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 3rem;
            color: #94a3b8;
            text-align: center;
        }
        
        .empty-state i {
            font-size: 3rem;
            margin-bottom: 1rem;
            opacity: 0.3;
        }
        
        .empty-state p {
            font-size: 1rem;
            margin-bottom: 1rem;
        }
        
        .recommendation-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 1.5rem;
            border-radius: 1rem;
            margin-bottom: 1rem;
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
            transition: all 0.3s ease;
            animation: slideIn 0.5s ease-out;
        }
        
        .recommendation-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 35px rgba(102, 126, 234, 0.4);
        }
        
        .benefit-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem;
            background: rgba(255,255,255,0.1);
            border-radius: 0.5rem;
            margin-bottom: 0.5rem;
            transition: all 0.3s ease;
        }
        
        .benefit-item:hover {
            background: rgba(255,255,255,0.2);
            transform: translateX(5px);
        }
        
        @media (min-width: 640px) {
            .time-slot-btn { font-size: 0.8rem; }
        }

        /* ===== สไตล์สำหรับใบเสนอราคาแนวนอน ===== */
        .quotation-landscape {
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 15px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }

        .quotation-portrait {
            max-width: 210mm;
            padding: 10px;
        }

        .quotation-portrait .quotation-table {
            font-size: 6.5px;
        }

        .quotation-portrait .quotation-table th,
        .quotation-portrait .quotation-table td {
            padding: 1px;
        }
        
        .quotation-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 8px;
        }
        
        .quotation-table th {
            background-color: #e2e8f0;
            border: 1px solid #cbd5e1;
            padding: 3px 2px;
            text-align: center;
            font-weight: 600;
            white-space: nowrap;
        }
        
        .quotation-table td {
            border: 1px solid #cbd5e1;
            padding: 2px;
            white-space: nowrap;
        }
        
        .quotation-table .text-right {
            text-align: right;
        }
        
        .quotation-table .text-center {
            text-align: center;
        }
        
        .print-controls {
            display: flex;
            gap: 10px;
            margin: 10px 0;
        }
        
        /* ===== สไตล์สำหรับรายงาน PDF ===== */
        .pdf-report {
            font-family: 'Sarabun', sans-serif;
            max-width: 210mm;
            margin: 0 auto;
            padding: 10mm;
            background: white;
            font-size: 11px;
            line-height: 1.4;
        }
        
        .pdf-report h1 {
            font-size: 18px;
            margin-bottom: 5px;
            color: #4c1d95;
        }
        
        .pdf-report h2 {
            font-size: 14px;
            margin: 10px 0 5px;
            color: #6b21a8;
        }
        
        .pdf-report .header {
            text-align: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #8b5cf6;
        }
        
        .pdf-report .info-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-bottom: 15px;
            background: #f8fafc;
            padding: 10px;
            border-radius: 5px;
        }
        
        .pdf-report .info-item {
            margin-bottom: 3px;
        }
        
        .pdf-report .info-label {
            font-weight: 600;
            color: #4b5563;
            font-size: 10px;
        }
        
        .pdf-report .info-value {
            font-weight: 500;
            color: #1e293b;
        }
        
        .pdf-report .package-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin: 10px 0;
        }
        
        .pdf-report .package-item {
            background: #f3e8ff;
            padding: 8px;
            border-radius: 5px;
            border-left: 3px solid #8b5cf6;
        }
        
        .pdf-report .total-box {
            background: #f1f5f9;
            padding: 10px;
            border-radius: 5px;
            margin: 10px 0;
            text-align: right;
        }
        
        .pdf-report .footer {
            margin-top: 20px;
            padding-top: 10px;
            border-top: 1px solid #e2e8f0;
            text-align: center;
            font-size: 9px;
            color: #64748b;
        }
        
        .pdf-report .benefit-list {
            list-style: none;
            padding: 0;
            margin: 5px 0;
        }
        
        .pdf-report .benefit-list li {
            padding: 3px 0;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .pdf-report .benefit-list i {
            color: #10b981;
            font-size: 12px;
        }
        
        .pdf-report .promo-list {
            background: #fef3c7;
            padding: 8px;
            border-radius: 5px;
            margin: 10px 0;
        }
        
        .pdf-report .promo-item {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 3px 0;
        }
        
        .pdf-report .promo-item i {
            color: #f59e0b;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .recommender-option-group {
            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
            border-radius: 12px;
            padding: 15px;
            margin-top: 10px;
            border: 1px solid #e2e8f0;
        }
        
        .recommender-option-group h4 {
            font-size: 14px;
            font-weight: 600;
            color: #4c1d95;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .recommender-option-group h4 i {
            color: #f97316;
        }
        
        .badge-gov {
            background: linear-gradient(135deg, #0d3b66, #1c5bb8);
            color: white;
        }
        
        .badge-private {
            background: linear-gradient(135deg, #059669, #10b981);
            color: white;
        }
        
        .badge-service {
            background: linear-gradient(135deg, #b45309, #f59e0b);
            color: white;
        }

        .spinner {
            border: 4px solid rgba(0, 0, 0, 0.1);
            border-left-color: #3b82f6;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* สไตล์ PDF สำหรับรายงานแนะนำแพ็กเกจ (กระชับ 1 หน้า) */
        .pdf-recommend {
            font-family: 'Sarabun', sans-serif;
            max-width: 210mm;
            margin: 0 auto;
            padding: 5mm;
            background: white;
            font-size: 9px;
            line-height: 1.3;
        }
        .pdf-recommend .header {
            text-align: center;
            margin-bottom: 5px;
            padding-bottom: 3px;
            border-bottom: 1px solid #8b5cf6;
        }
        .pdf-recommend .header h1 {
            font-size: 14px;
            margin-bottom: 0;
        }
        .pdf-recommend .info-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 4px;
            margin-bottom: 6px;
            background: #f8fafc;
            padding: 5px;
            border-radius: 3px;
        }
        .pdf-recommend .package-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 4px;
            margin: 6px 0;
        }
        .pdf-recommend .package-item {
            background: #f3e8ff;
            padding: 4px;
            border-radius: 3px;
            border-left: 2px solid #8b5cf6;
        }
        .pdf-recommend .total-box {
            background: #f1f5f9;
            padding: 5px;
            border-radius: 3px;
            margin: 6px 0;
            text-align: right;
        }
        .pdf-recommend .promo-list, .pdf-recommend .benefit-list {
            background: #fef3c7;
            padding: 4px;
            border-radius: 3px;
            margin: 6px 0;
        }
        .pdf-recommend .footer {
            margin-top: 8px;
            padding-top: 3px;
            border-top: 1px solid #e2e8f0;
            text-align: center;
            font-size: 7px;
            color: #64748b;
        }
    
        /* ===== ใบเสนอราคาแบบเอกสารแนวตั้ง ===== */
        .quotation-doc {
            width: 100%;
            max-width: 860px;
            margin: 0 auto;
            background: white;
            padding: 16px 18px;
            border-radius: 12px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.08);
            font-size: 13px;
            line-height: 1.35;
        }
        .quotation-doc-header {
            text-align: center;
            border-bottom: 1px solid #1e3a8a;
            padding-bottom: 6px;
            margin-bottom: 8px;
        }
        .quotation-doc-header h1 {
            font-size: 22px;
            color: #1e3a8a;
            margin: 0 0 2px;
            line-height: 1.1;
        }
        .quotation-doc-company {
            font-size: 12px;
            font-weight: 700;
            color: #0f172a;
            line-height: 1.2;
        }
        .quotation-doc-meta {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px 12px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 10px 12px;
            margin-bottom: 10px;
        }
        .quotation-doc-section {
            margin-bottom: 12px;
        }
        .quotation-doc-section-title {
            font-size: 15px;
            font-weight: 800;
            color: #1d4ed8;
            margin-bottom: 6px;
            line-height: 1.2;
        }
        .quotation-doc-item {
            border: 1px solid #dbeafe;
            border-radius: 12px;
            padding: 12px;
            margin-bottom: 10px;
            background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
            page-break-inside: avoid;
            break-inside: avoid;
        }
        .quotation-doc-item-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 8px;
            border-bottom: 1px solid #dbeafe;
            padding-bottom: 6px;
            margin-bottom: 8px;
        }
        .quotation-doc-item-title {
            font-size: 16px;
            font-weight: 800;
            color: #0f172a;
            line-height: 1.2;
        }
        .quotation-doc-badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 999px;
            font-size: 10px;
            font-weight: 700;
            background: #dbeafe;
            color: #1d4ed8;
            white-space: nowrap;
        }
        .quotation-doc-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px 10px;
            margin-bottom: 8px;
        }
        .quotation-doc-stat {
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            padding: 8px 10px;
        }
        .quotation-doc-label {
            font-size: 10px;
            font-weight: 700;
            color: #64748b;
            margin-bottom: 2px;
            line-height: 1.2;
        }
        .quotation-doc-value {
            font-size: 13px;
            font-weight: 800;
            color: #0f172a;
            line-height: 1.25;
        }
        .quotation-doc-subsection {
            border-top: 1px dashed #cbd5e1;
            padding-top: 8px;
            margin-top: 8px;
        }
        .quotation-doc-timeslots {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-top: 6px;
        }
        .quotation-doc-chip {
            display: inline-flex;
            align-items: center;
            padding: 3px 8px;
            border-radius: 999px;
            background: #eff6ff;
            border: 1px solid #bfdbfe;
            color: #1d4ed8;
            font-size: 10px;
            font-weight: 700;
            line-height: 1.2;
        }
        .quotation-doc-summary {
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            border-radius: 12px;
            padding: 12px;
            page-break-inside: auto;
            break-inside: auto;
        }
        .quotation-doc-summary-row {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            gap: 12px;
            padding: 4px 0;
            border-bottom: 1px solid #e2e8f0;
            font-size: 12px;
            line-height: 1.25;
        }
        .quotation-doc-summary-row:last-child {
            border-bottom: none;
        }
        .quotation-doc-summary-row span {
            flex: 1 1 auto;
            min-width: 0;
            padding-right: 8px;
        }
        .quotation-doc-summary-row strong {
            flex: 0 0 auto;
            white-space: nowrap;
        }

        .quotation-doc-net {
            background: #1e293b;
            color: #facc15;
            padding: 8px 12px;
            border-radius: 8px;
            font-size: 17px;
            font-weight: 900;
            margin-top: 8px;
            line-height: 1.2;
        }
        .quotation-doc-package-section {
            margin: 10px 0 12px;
            border: 1px solid #94a3b8;
            page-break-inside: avoid;
            break-inside: avoid;
            background: #ffffff;
        }
        .quotation-doc-package-head {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            padding: 10px 12px;
            background: #f8fafc;
            border-bottom: 1px solid #94a3b8;
        }
        .quotation-doc-package-eyebrow {
            font-size: 10px;
            font-weight: 900;
            color: #1d4ed8;
            text-transform: uppercase;
        }
        .quotation-doc-package-title {
            font-size: 16px;
            font-weight: 900;
            color: #111827;
            line-height: 1.2;
        }
        .quotation-doc-package-campaign {
            margin-top: 2px;
            font-size: 12px;
            font-weight: 800;
            color: #92400e;
        }
        .quotation-doc-package-price {
            min-width: 136px;
            text-align: right;
        }
        .quotation-doc-package-price span,
        .quotation-doc-package-price em {
            display: block;
            font-size: 10px;
            color: #64748b;
            font-style: normal;
            line-height: 1.2;
        }
        .quotation-doc-package-price strong {
            display: block;
            font-size: 17px;
            color: #111827;
            line-height: 1.2;
        }
        .quotation-doc-package-meta {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            border-bottom: 1px solid #cbd5e1;
        }
        .quotation-doc-package-meta div {
            padding: 7px 9px;
            border-right: 1px solid #cbd5e1;
        }
        .quotation-doc-package-meta div:last-child {
            border-right: 0;
        }
        .quotation-doc-package-meta span {
            display: block;
            font-size: 9px;
            font-weight: 800;
            color: #64748b;
        }
        .quotation-doc-package-meta strong {
            display: block;
            font-size: 11px;
            color: #111827;
            line-height: 1.2;
        }
        .quotation-doc-package-table {
            width: 100%;
            table-layout: fixed;
            border-collapse: collapse;
            font-size: 11px;
        }
        .quotation-doc-package-table th,
        .quotation-doc-package-table td {
            border-right: 1px solid #cbd5e1;
            border-bottom: 1px solid #cbd5e1;
            padding: 6px 8px;
            vertical-align: top;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .quotation-doc-package-table th:last-child,
        .quotation-doc-package-table td:last-child {
            border-right: 0;
        }
        .quotation-doc-package-table th {
            background: #eff6ff;
            color: #1e3a8a;
            font-weight: 900;
            text-align: left;
        }
        .quotation-doc-package-table th:nth-child(1) {
            width: 28%;
        }
        .quotation-doc-package-table th:nth-child(4) {
            width: 18%;
        }
        .quotation-doc-final-page {
            page-break-before: auto;
            break-before: auto;
        }
        .quotation-doc-final-section {
            page-break-before: auto;
            break-before: auto;
            page-break-inside: auto;
            break-inside: auto;
        }
        .quotation-doc-note-box {
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 8px;
            padding: 8px 10px;
            margin-top: 8px;
            font-size: 11px;
            line-height: 1.35;
        }
        .quotation-doc-footer-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin-top: 10px;
        }
        .quotation-doc-signatures {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 28px;
            margin-top: 18px;
            align-items: start;
        }
        .quotation-doc-signatures.single-signature {
            grid-template-columns: minmax(260px, 48%);
            justify-content: end;
        }
        .quotation-doc-sign {
            width: 100%;
            text-align: center;
            padding-top: 10px;
        }
        .quotation-doc-sign-line {
            border-top: 1px solid #334155;
            padding-top: 5px;
            font-size: 10.5px;
            font-weight: 700;
            line-height: 1.2;
            min-height: 18px;
        }
        .quotation-doc-sign-meta {
            margin-top: 3px;
            font-size: 9.6px;
            color: #475569;
            line-height: 1.25;
            font-weight: 600;
        }
        .quotation-doc-sign-meta .label {
            color: #64748b;
            font-weight: 700;
        }

        .quotation-doc-detail-box {
            background: #f0f9ff;
            border: 1px solid #bae6fd;
            border-radius: 10px;
            padding: 8px 10px;
            margin-top: 8px;
            font-size: 11px;
            line-height: 1.35;
            color: #0f172a;
        }
        .quotation-doc-detail-box .detail-title {
            font-weight: 800;
            color: #0369a1;
            margin-bottom: 4px;
        }
        .quotation-doc-detail-box ul {
            margin: 0;
            padding-left: 18px;
        }
        .quotation-doc-detail-box li {
            margin: 2px 0;
        }

        /* ===== Formal MCOT quotation document ===== */
        .quotation-doc {
            max-width: 820px;
            padding: 22px 26px;
            border-radius: 8px;
            color: #111827;
            line-height: 1.45;
        }
        .quotation-doc-header {
            border-bottom: 0;
            color: #111827;
            margin-bottom: 16px;
            padding-bottom: 0;
            font-size: 13px;
        }
        .quotation-doc-topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 18px;
            padding-bottom: 14px;
            border-bottom: 3px solid #f97316;
        }
        .quotation-doc-logo-wrap {
            flex: 0 0 150px;
            display: flex;
            align-items: center;
        }
        .quotation-doc-logo {
            display: block;
            width: 138px;
            max-height: 74px;
            object-fit: contain;
        }
        .quotation-doc-org-block {
            flex: 1 1 auto;
            text-align: right;
            color: #374151;
            line-height: 1.35;
        }
        .quotation-doc-header h1 {
            margin: 0;
            font-size: 28px;
            color: #111827;
            text-decoration: none;
            line-height: 1.1;
        }
        .quotation-doc-company {
            font-size: 15px;
            color: #111827;
            font-weight: 900;
        }
        .quotation-doc-title-row {
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
            gap: 18px;
            padding: 14px 0 0;
        }
        .quotation-doc-subtitle {
            margin-top: 2px;
            color: #6b7280;
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
        }
        .quotation-doc-issue-card {
            min-width: 180px;
            padding: 8px 10px;
            border: 1px solid #d1d5db;
            background: #f9fafb;
            text-align: right;
        }
        .quotation-doc-issue-card span {
            display: block;
            color: #6b7280;
            font-size: 11px;
            font-weight: 700;
        }
        .quotation-doc-issue-card strong {
            display: block;
            color: #111827;
            font-size: 13px;
        }
        .quotation-doc-divider {
            margin: 8px auto 4px;
            color: #374151;
            letter-spacing: 1px;
            white-space: nowrap;
            overflow: hidden;
        }
        .quotation-doc-issue-date {
            margin-top: 2px;
            text-align: right;
            font-size: 13px;
        }
        .quotation-doc-letter {
            margin: 10px 0 12px;
            font-size: 13px;
        }
        .quotation-doc-letter p {
            margin: 5px 0;
        }
        .quotation-doc-airtime-table,
        .quotation-doc-rate-table {
            width: calc(100% - 1px);
            max-width: calc(100% - 1px);
            table-layout: fixed;
            border-collapse: collapse;
            outline: 1px solid #4b5563;
            outline-offset: -1px;
            margin: 8px 0 12px;
            font-size: 12px;
        }
        .quotation-doc-airtime-table th,
        .quotation-doc-airtime-table td,
        .quotation-doc-rate-table th,
        .quotation-doc-rate-table td {
            border: 1px solid #4b5563;
            padding: 6px 8px;
            vertical-align: top;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .quotation-doc-airtime-table th:last-child,
        .quotation-doc-airtime-table td:last-child,
        .quotation-doc-rate-table th:last-child,
        .quotation-doc-rate-table td:last-child {
            border-right: 1px solid #4b5563;
        }
        .quotation-doc-airtime-table th {
            width: 32%;
            text-align: left;
            background: #f3f4f6;
        }
        .quotation-doc-rate-table th {
            text-align: center;
            background: #f3f4f6;
            font-weight: 800;
        }
        .quotation-doc-rate-table th:nth-child(1) {
            width: 22%;
        }
        .quotation-doc-rate-table th:nth-child(3) {
            width: 20%;
        }
        .quotation-doc-month-section {
            margin-top: 12px;
            page-break-inside: avoid;
            break-inside: avoid;
        }
        .quotation-doc-month-title {
            margin: 2px 0 6px;
            font-weight: 800;
            text-align: center;
            text-decoration: underline;
        }
        .quotation-doc-date-cell {
            text-align: center;
            line-height: 1.35;
        }
        .quotation-doc-muted {
            color: #4b5563;
            font-size: 11px;
            line-height: 1.35;
        }
        .quotation-doc-total-row td,
        .quotation-doc-net-row td {
            font-weight: 800;
        }
        .quotation-doc-net-row {
            background: #f9fafb;
        }
        .quotation-doc-summary {
            margin-top: 8px;
            background: #ffffff;
            border: 1px solid #4b5563;
            border-radius: 0;
            padding: 7px 8px;
        }
        .quotation-doc-summary-row {
            font-size: 12px;
            border-bottom-color: #d1d5db;
        }
        .quotation-doc-net {
            background: #111827;
            color: #ffffff;
            border-radius: 0;
            text-align: right;
        }
        .quotation-doc-note-box,
        .quotation-doc-detail-box {
            background: #ffffff;
            border: 1px solid #9ca3af;
            border-radius: 0;
            color: #111827;
        }
        .quotation-doc-detail-box {
            margin-top: 6px;
        }
        .quotation-doc-detail-box .detail-title {
            color: #111827;
        }
        .quotation-doc-signatures {
            margin-top: 20px;
            gap: 34px;
        }
        .quotation-doc-sign-line {
            border-top-color: #111827;
            font-weight: 800;
        }
        .quotation-doc-sign-name {
            margin-top: 4px;
            font-size: 10px;
            font-weight: 700;
        }
        .quotation-doc-internal-approval {
            margin-top: 10px;
            padding: 7px 8px;
            border: 1px solid #f59e0b;
            background: #fffbeb;
            text-align: left;
            font-size: 10.5px;
            line-height: 1.35;
        }
        .quotation-doc-internal-approval-row span {
            display: block;
            color: #92400e;
            font-weight: 800;
        }
        .quotation-doc-internal-approval-row strong {
            display: block;
            color: #111827;
        }
        .quotation-doc-internal-approval-row em {
            display: block;
            color: #4b5563;
            font-style: normal;
        }
        .quotation-bullet {
            position: relative;
            padding-left: 14px;
            margin: 2px 0;
        }
        .quotation-bullet::before {
            content: "•";
            position: absolute;
            left: 0;
            top: 0;
        }
        .quotation-doc-dotted-line {
            margin-top: 4px;
            font-size: 9.8px;
            font-weight: 700;
            letter-spacing: 0;
        }
        .quotation-doc-signature-slot {
            min-height: 48px;
            display: flex;
            align-items: flex-end;
            justify-content: center;
        }
        .quotation-doc-signature-blank {
            width: 74%;
            height: 34px;
            border-bottom: 1px dotted #6b7280;
            margin: 0 auto 4px;
        }
        .quotation-doc-signature-image {
            display: block;
            width: 138px;
            height: 50px;
            max-height: 50px;
            object-fit: contain;
            margin: 2px auto 2px;
        }
        .quotation-doc-signature-image path {
            fill: none;
            stroke: #111827;
            stroke-width: 5;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .quotation-doc-signature-image.staff-signature {
            margin-top: 2px;
            margin-bottom: 1px;
        }
        .signature-canvas-wrap {
            width: 100%;
            border: 1px dashed #94a3b8;
            background: #ffffff;
            border-radius: 10px;
            overflow: hidden;
            touch-action: none;
        }
        #quotation-signature-canvas {
            display: block;
            width: 100%;
            height: 260px;
            background: #ffffff;
            touch-action: none;
        }

        /* ===== Responsive Upgrade for Mobile / Tablet ===== */
        .responsive-card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 1rem;
        }
        @media (max-width: 1024px) {
            #main-content { padding: 1rem !important; }
            .modal-content { max-width: 96%; padding: 1.25rem; }
            .quotation-landscape, .quotation-doc { max-width: 100%; }
            .table-container { width: 100%; overflow-x: auto; }
            table { max-width: 100%; }
            #orders-tab .order-schedule-compact { grid-template-columns: 1fr !important; }
            #orders-tab input,
            #orders-tab select,
            #orders-tab textarea {
                min-width: 0;
            }
        }
        @media (max-width: 640px) {
            #main-content { padding: 0.75rem !important; padding-top: 96px !important; padding-bottom: 96px !important; }
            header.mb-6, header.mb-10 { margin-bottom: 1rem !important; }
            #page-title { font-size: 1.35rem !important; line-height: 1.25 !important; }
            .bg-white.rounded-xl, .bg-white.rounded-2xl { border-radius: 0.9rem !important; }
            .p-4, .lg\:p-6, .lg\:p-8 { padding: 0.9rem !important; }
            .grid { gap: 0.75rem !important; }
            .flex { min-width: 0; }
            input, select, textarea, button { max-width: 100%; }
            button { white-space: normal; }
            .time-slot-btn { min-height: 42px; font-size: 11px !important; }
            #time-slots-container { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
            #orders-tab .grid.grid-cols-2,
            #orders-tab .grid.grid-cols-3,
            #orders-tab .grid.grid-cols-4 {
                grid-template-columns: 1fr !important;
            }
            #orders-tab #time-slots-container {
                grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
            }
            #orders-tab #selected-slots-count {
                display: block;
                width: 100%;
                text-align: center;
            }
            .quotation-doc { padding: 12px; font-size: 12px; border-radius: 10px; }
            .quotation-doc-header h1 { font-size: 19px; }
            .quotation-doc-topbar, .quotation-doc-title-row { align-items: flex-start; flex-direction: column; gap: 10px; }
            .quotation-doc-org-block, .quotation-doc-issue-card { text-align: left; width: 100%; }
            .quotation-doc-logo-wrap { flex-basis: auto; }
            .quotation-doc-logo { width: 112px; }
            .quotation-doc-meta, .quotation-doc-grid, .quotation-doc-footer-grid, .quotation-doc-signatures { grid-template-columns: 1fr !important; }
            .quotation-doc-item-header { flex-direction: column; }
            .quotation-doc-signatures.single-signature { justify-content: stretch; }
            .quotation-doc-sign { width: 100%; padding-top: 16px; }
            .quotation-doc-net { font-size: 14px; }
            .quotation-table { font-size: 7px; min-width: 980px; }
            .quotation-landscape { padding: 10px; overflow-x: auto; }
            .modal-content { width: 96%; max-height: 88%; padding: 1rem; }
            #customer-form-container,
            #product-form-container,
            #package-form-container,
            #promotion-form-container {
                scroll-margin-top: 96px;
                scroll-margin-bottom: 96px;
            }
            .notification {
                top: auto !important;
                bottom: 58px !important;
                left: 12px !important;
                right: 12px !important;
                text-align: center !important;
                z-index: 1200 !important;
                pointer-events: none !important;
            }
        }
        @media (max-height: 620px) and (orientation: landscape) {
            #main-content { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
            .time-slot-btn { min-height: 34px; font-size: 10px !important; }
            #orders-tab .order-schedule-compact { gap: 0.75rem !important; }
        }
        @media (max-width: 768px) {
            .quotation-doc { padding: 14px; }
            .quotation-doc-meta, .quotation-doc-grid, .quotation-doc-footer-grid { grid-template-columns: 1fr; }
            .quotation-doc-item-header { flex-direction: column; }
            .quotation-doc-signatures, .quotation-doc-signatures.single-signature { grid-template-columns: 1fr; justify-content: stretch; }
            .quotation-doc-sign { width: 100%; }
        }


/* ===== V9.6 Order UX Fix: Full weekday names + rectangular buttons ===== */
#weekdays-container {
    gap: 8px;
}

/* CRM extension */
.crm-summary-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.crm-summary-card {
    min-height: 86px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}

.crm-summary-card > i { font-size: 1.2rem; color: #2563eb; }
.crm-summary-card strong { display: block; color: #0f172a; font-size: 1.25rem; line-height: 1.1; }
.crm-summary-card span { display: block; margin-top: 4px; color: #64748b; font-size: .72rem; line-height: 1.25; }
.crm-tone-emerald > i { color: #059669; }
.crm-tone-indigo > i { color: #4f46e5; }
.crm-tone-amber > i { color: #d97706; }
.crm-tone-rose > i { color: #e11d48; }
.crm-tone-cyan > i { color: #0891b2; }
.crm-tone-violet > i { color: #7c3aed; }

.crm-chip-row, .crm-link-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.crm-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: .7rem; font-weight: 700; }
.crm-chip-muted { background: #f1f5f9; color: #64748b; }
.crm-link-row a { color: #1d4ed8; font-size: .78rem; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.crm-link-row button { color: #1d4ed8; font-size: .76rem; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.crm-link-row .crm-danger-link { color: #e11d48; }
.crm-icon-btn { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.crm-icon-btn:hover { background: #f1f5f9; }

.crm-role-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.crm-check-option { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; cursor: pointer; }
.crm-check-option input { width: 18px; height: 18px; accent-color: #2563eb; }
.crm-check-option span { font-size: .82rem; font-weight: 700; color: #334155; }

body.crm-modal-open { overflow: hidden; }
.crm-modal { position: fixed; inset: 0; z-index: 2100; align-items: center; justify-content: center; padding: 18px; background: rgba(15, 23, 42, .72); }
.crm-modal-panel { width: min(980px, 100%); max-height: calc(100dvh - 36px); display: flex; flex-direction: column; overflow: hidden; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(15, 23, 42, .28); }
.crm-profile-panel { width: min(1120px, 100%); }
.crm-import-panel { width: min(1040px, 100%); }
.crm-duplicate-panel { width: min(760px, 100%); }
.crm-modal-head { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid #e2e8f0; }
.crm-modal-head h2 { color: #0f172a; font-size: 1.12rem; font-weight: 900; }
.crm-modal-head p { margin-top: 3px; color: #64748b; font-size: .8rem; }
.crm-close-btn { flex: 0 0 44px; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: #f1f5f9; color: #334155; }
.crm-modal-body { min-height: 0; overflow: auto; padding: 20px; overscroll-behavior: contain; }

.crm-profile-actions, .crm-action-row { display: flex; flex-wrap: wrap; gap: 9px; }
.crm-profile-actions { position: sticky; top: -20px; z-index: 4; margin: -20px -20px 18px; padding: 12px 20px; border-bottom: 1px solid #dbeafe; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.crm-btn, .crm-small-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border-radius: 8px; font-size: .82rem; font-weight: 800; }
.crm-btn:disabled { cursor: not-allowed; opacity: .5; }
.crm-btn-primary { background: #2563eb; color: #fff; }
.crm-btn-secondary { border: 1px solid #cbd5e1; background: #fff; color: #334155; }
.crm-btn-warning { background: #f59e0b; color: #111827; }
.crm-small-btn { min-height: 36px; padding: 6px 10px; background: #eff6ff; color: #1d4ed8; }

.crm-profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.crm-section { margin-top: 14px; padding: 16px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
.crm-profile-grid .crm-section { margin-top: 0; }
.crm-section h3 { margin-bottom: 12px; color: #0f172a; font-size: .95rem; font-weight: 900; }
.crm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crm-detail-list, .crm-compare-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.crm-detail-list div, .crm-compare-list div { min-width: 0; }
.crm-detail-list dt, .crm-compare-list dt { color: #64748b; font-size: .7rem; font-weight: 700; }
.crm-detail-list dd, .crm-compare-list dd { overflow-wrap: anywhere; color: #1e293b; font-size: .85rem; font-weight: 700; }
.crm-list-item { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.crm-list-item:last-child { border-bottom: 0; }
.crm-list-item strong { color: #1e293b; font-size: .85rem; }
.crm-list-item span, .crm-list-item small { color: #64748b; font-size: .75rem; }
.crm-empty { color: #94a3b8; font-size: .82rem; }

.crm-form-panel { background: #f8fafc; }
.crm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.crm-form-grid label, .crm-settings-label { display: flex; flex-direction: column; gap: 6px; color: #334155; font-size: .8rem; font-weight: 800; }
.crm-form-grid input, .crm-form-grid select, .crm-form-grid textarea, .crm-settings-label input, .crm-settings-label textarea, .crm-import-table select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #0f172a; outline: none; }
.crm-form-grid textarea, .crm-settings-label textarea { min-height: 92px; resize: vertical; }
.crm-span-all { grid-column: 1 / -1; }

.crm-timeline-item { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; }
.crm-timeline-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #dbeafe; color: #2563eb; }
.crm-timeline-item strong, .crm-timeline-item time { display: block; }
.crm-timeline-item strong { color: #1e293b; font-size: .82rem; }
.crm-timeline-item time { color: #94a3b8; font-size: .7rem; }
.crm-timeline-item p { margin-top: 4px; color: #475569; font-size: .82rem; white-space: pre-wrap; }

.crm-duplicate-reason, .crm-import-summary { margin-bottom: 14px; padding: 10px 12px; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: .82rem; font-weight: 800; }
.crm-compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.crm-compare-grid > div { padding: 14px; border: 1px solid #e2e8f0; border-radius: 8px; }
.crm-compare-grid h3 { margin-bottom: 10px; font-weight: 900; }
.crm-file-picker { min-height: 74px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 2px dashed #93c5fd; border-radius: 8px; background: #eff6ff; color: #1d4ed8; font-weight: 900; cursor: pointer; }
.crm-file-picker input { display: none; }
.crm-import-preview { max-height: 52dvh; overflow: auto; }
.crm-import-table { width: 100%; min-width: 700px; border-collapse: collapse; }
.crm-import-table th, .crm-import-table td { padding: 10px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; font-size: .78rem; }
.crm-import-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #475569; }
.crm-duplicate-badge, .crm-new-badge { display: inline-flex; margin-bottom: 4px; padding: 3px 7px; border-radius: 999px; font-size: .68rem; font-weight: 800; }
.crm-duplicate-badge { background: #ffedd5; color: #c2410c; }
.crm-new-badge { background: #dcfce7; color: #15803d; }
.crm-image-preview { width: 88px; height: 88px; object-fit: contain; margin-top: 6px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.crm-signature-preview { width: 160px; object-position: center; }
.crm-image-preview.is-empty { opacity: .45; }

@media (max-width: 1280px) {
    .crm-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .crm-role-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .crm-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-modal { padding: 0; align-items: stretch; }
    .crm-modal-panel { width: 100%; max-height: 100dvh; min-height: 100dvh; border-radius: 0; }
    .crm-modal-head { padding: 13px 14px; }
    .crm-modal-body { padding: 14px; }
    .crm-profile-actions { top: -14px; margin: -14px -14px 14px; padding: 10px 14px; overflow-x: auto; flex-wrap: nowrap; }
    .crm-profile-actions .crm-btn { flex: 0 0 auto; }
    .crm-profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .crm-summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .crm-summary-card { min-height: 76px; padding: 11px; }
    .crm-role-grid, .crm-form-grid, .crm-compare-grid, .crm-detail-list { grid-template-columns: 1fr; }
    .crm-action-row .crm-btn { width: 100%; }
}

.weekday-btn {
    min-width: 86px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #475569;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    cursor: pointer;
}

.weekday-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.weekday-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}

/* Weekend hint: softer red text only. Hover still works on every day. */
.weekday-btn[data-day="0"],
.weekday-btn[data-day="6"] {
    color: #dc2626;
    border-color: #fecaca;
    background: #fff7f7;
}

.weekday-btn[data-day="0"]:hover,
.weekday-btn[data-day="6"]:hover {
    color: #b91c1c;
    border-color: #f87171;
    background: #fff1f2;
}

.weekday-btn.selected,
.weekday-btn.selected:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.weekday-btn.selected::before {
    content: "✓";
    margin-right: 6px;
    font-size: 11px;
    line-height: 1;
}

@media (max-width: 640px) {
    #weekdays-container {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .weekday-btn {
        min-width: 0;
        width: 100%;
        min-height: 42px;
        font-size: 13px;
    }
}


/* ===== V9.7 Sidebar stability + Order date/weekday compact layout ===== */
#sidebar {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
}
#sidebar > .sidebar-header { flex: 0 0 auto !important; }
#sidebar > nav,
#sidebar > .sidebar-menu {
    position: relative !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}
#sidebar > .sidebar-footer,
#sidebar > div.sidebar-footer,
#sidebar > div.absolute.bottom-0,
#sidebar > div[class*="bottom-0"] {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-height: 194px !important;
    overflow: visible !important;
    padding: 10px 12px 12px !important;
    border-top: 1px solid rgba(255,255,255,0.12) !important;
    background: rgba(0,0,0,0.16) !important;
    box-shadow: 0 -8px 18px rgba(0,0,0,0.08) !important;
}
#sidebar.expanded .sidebar-header { padding-top: 12px !important; padding-bottom: 10px !important; }
#sidebar.expanded .menu-item { min-height: 40px !important; padding-top: 9px !important; padding-bottom: 9px !important; }
#sidebar:not(.expanded) > div[class*="bottom-0"] .grid,
#sidebar:not(.expanded) > .sidebar-footer .grid,
#sidebar:not(.expanded) > div[class*="bottom-0"] .command-title,
#sidebar:not(.expanded) > .sidebar-footer .command-title,
#sidebar:not(.expanded) > div[class*="bottom-0"] .footer-text,
#sidebar:not(.expanded) > .sidebar-footer .footer-text,
#sidebar:not(.expanded) > div[class*="bottom-0"] button:not(:first-of-type),
#sidebar:not(.expanded) > .sidebar-footer button:not(:first-of-type) { display: none !important; }
@media (max-height: 760px) and (min-width: 769px) {
    #sidebar.expanded .logo { width: 38px !important; height: 38px !important; margin-bottom: 5px !important; }
    #sidebar.expanded .sidebar-header h1 { font-size: 0.88rem !important; }
    #sidebar.expanded .sidebar-header p { font-size: 0.64rem !important; }
    #sidebar.expanded .menu-item { min-height: 36px !important; padding-top: 7px !important; padding-bottom: 7px !important; font-size: 0.86rem !important; }
    #sidebar.expanded > .sidebar-footer,
    #sidebar.expanded > div[class*="bottom-0"] { max-height: 174px !important; padding-top: 8px !important; padding-bottom: 9px !important; }
    #sidebar.expanded > .sidebar-footer button,
    #sidebar.expanded > div[class*="bottom-0"] button { min-height: 30px !important; padding-top: 6px !important; padding-bottom: 6px !important; }
}
.order-schedule-compact {
    display: grid !important;
    grid-template-columns: minmax(240px, 0.48fr) minmax(420px, 1fr) !important;
    gap: 18px !important;
    align-items: start !important;
}
.order-date-stack { min-width: 0 !important; }
.order-date-grid-stack { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; }
.order-weekday-panel { min-width: 0 !important; }
.order-weekdays-full-row { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; align-items: center !important; }
.order-weekdays-full-row .weekday-btn { flex: 0 1 auto !important; }
@media (min-width: 1280px) {
    .order-weekdays-full-row { flex-wrap: nowrap !important; }
    .order-weekdays-full-row .weekday-btn { min-width: 78px !important; padding-left: 10px !important; padding-right: 10px !important; }
}
@media (max-width: 1024px) {
    .order-schedule-compact { grid-template-columns: 1fr !important; }
    .order-date-grid-stack { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 640px) {
    .order-date-grid-stack { grid-template-columns: 1fr !important; }
    .order-weekdays-full-row { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}


/* ===== V9.8 Sidebar footer + visible scroll + order type active fix ===== */
#sidebar > nav,
#sidebar > .sidebar-menu {
    scrollbar-width: auto !important;
    scrollbar-color: rgba(255,255,255,0.62) rgba(255,255,255,0.10) !important;
}
#sidebar > nav::-webkit-scrollbar,
#sidebar > .sidebar-menu::-webkit-scrollbar { width: 8px !important; }
#sidebar > nav::-webkit-scrollbar-track,
#sidebar > .sidebar-menu::-webkit-scrollbar-track { background: rgba(255,255,255,0.10) !important; border-radius: 999px !important; }
#sidebar > nav::-webkit-scrollbar-thumb,
#sidebar > .sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.55) !important; border-radius: 999px !important; border: 2px solid rgba(0,0,0,0.05) !important; }
#sidebar > nav::-webkit-scrollbar-thumb:hover,
#sidebar > .sidebar-menu::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.78) !important; }

#sidebar:not(.expanded) > .sidebar-footer,
#sidebar:not(.expanded) > div[class*="bottom-0"] {
    display: flex !important; flex-direction: column !important; align-items: center !important; gap: 7px !important;
    padding: 8px 6px 9px !important; max-height: none !important; overflow: visible !important;
}
#sidebar:not(.expanded) > .sidebar-footer .grid,
#sidebar:not(.expanded) > div[class*="bottom-0"] .grid {
    display: flex !important; flex-direction: column !important; gap: 7px !important; width: 100% !important; margin: 0 !important;
}
#sidebar:not(.expanded) > .sidebar-footer .command-title,
#sidebar:not(.expanded) > div[class*="bottom-0"] .command-title,
#sidebar:not(.expanded) > .sidebar-footer .footer-text,
#sidebar:not(.expanded) > div[class*="bottom-0"] .footer-text { display: none !important; }
#sidebar:not(.expanded) > .sidebar-footer button,
#sidebar:not(.expanded) > div[class*="bottom-0"] button,
#sidebar:not(.expanded) > .sidebar-footer .grid button,
#sidebar:not(.expanded) > div[class*="bottom-0"] .grid button {
    display: flex !important; width: 42px !important; height: 36px !important; min-height: 36px !important;
    padding: 0 !important; margin: 0 auto !important; border-radius: 12px !important; align-items: center !important; justify-content: center !important; gap: 0 !important;
}
#sidebar:not(.expanded) > .sidebar-footer button i,
#sidebar:not(.expanded) > div[class*="bottom-0"] button i { margin: 0 !important; font-size: 0.95rem !important; }
#sidebar:not(.expanded) > .sidebar-footer button .sidebar-text,
#sidebar:not(.expanded) > div[class*="bottom-0"] button .sidebar-text { display: none !important; }
#sidebar:not(.expanded) button[onclick*="logout"],
#sidebar:not(.expanded) button[onclick*="Logout"],
#sidebar:not(.expanded) button[id*="logout"],
#sidebar:not(.expanded) button[class*="logout"] {
    display: flex !important; width: 42px !important; height: 36px !important; min-height: 36px !important; padding: 0 !important;
}
.order-type-btn:not(.active) { background-color: #f1f5f9 !important; color: #475569 !important; box-shadow: none !important; }
.order-type-btn.active { background-color: #ffffff !important; color: #2563eb !important; box-shadow: 0 1px 3px rgba(15,23,42,0.12) !important; }
.order-schedule-compact { display: grid !important; grid-template-columns: minmax(240px, 0.48fr) minmax(420px, 1fr) !important; gap: 18px !important; align-items: start !important; }
.order-date-grid-stack { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; }
@media (max-width: 1024px) { .order-schedule-compact { grid-template-columns: 1fr !important; } .order-date-grid-stack { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 640px) { .order-date-grid-stack { grid-template-columns: 1fr !important; } }


/* =====================================================================
   V10.0 SIDEBAR HARD FIX - Fixed Header / Scroll Menu / Fixed Footer
   This block intentionally comes LAST and overrides all previous V9.x fixes.
   ===================================================================== */
html, body {
    min-height: 100%;
}

body #sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: auto !important;
    width: 64px !important;
    height: 100vh !important;
    max-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    background: linear-gradient(135deg, var(--brand-primary, #0d3b66) 0%, var(--brand-secondary, #1c5bb8) 100%) !important;
    color: #fff !important;
    z-index: 1000 !important;
}

body #sidebar.expanded {
    width: 256px !important;
}

/* 1) Header is always fixed at top inside sidebar */
body #sidebar > .sidebar-header {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 12px 10px 10px !important;
    border-bottom: 1px solid rgba(255,255,255,0.12) !important;
    background: rgba(0,0,0,0.04) !important;
    overflow: hidden !important;
}

body #sidebar .logo {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 7px !important;
    margin: 0 auto 7px !important;
    border-radius: 13px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
}

body #sidebar .logo i {
    font-size: 1.2rem !important;
    color: var(--brand-secondary, #1c5bb8) !important;
}

body #sidebar .sidebar-header h1 {
    font-size: 0.92rem !important;
    line-height: 1.12 !important;
    margin: 0 !important;
}

body #sidebar .sidebar-header p {
    font-size: 0.65rem !important;
    line-height: 1.1 !important;
    margin-top: 3px !important;
}

/* 2) Only the center menu scrolls */
body #sidebar > .sidebar-menu,
body #sidebar > nav.sidebar-menu,
body #sidebar > .sidebar-scroll-zone {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    width: 100% !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    padding: 8px 0 10px !important;
    margin: 0 !important;
    position: relative !important;
    scrollbar-width: auto !important;
    scrollbar-color: rgba(255,255,255,0.65) rgba(255,255,255,0.12) !important;
    scrollbar-gutter: stable !important;
}

body #sidebar > .sidebar-menu::-webkit-scrollbar,
body #sidebar > nav.sidebar-menu::-webkit-scrollbar,
body #sidebar > .sidebar-scroll-zone::-webkit-scrollbar {
    width: 8px !important;
}
body #sidebar > .sidebar-menu::-webkit-scrollbar-track,
body #sidebar > nav.sidebar-menu::-webkit-scrollbar-track,
body #sidebar > .sidebar-scroll-zone::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.10) !important;
    border-radius: 999px !important;
}
body #sidebar > .sidebar-menu::-webkit-scrollbar-thumb,
body #sidebar > nav.sidebar-menu::-webkit-scrollbar-thumb,
body #sidebar > .sidebar-scroll-zone::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.58) !important;
    border-radius: 999px !important;
    border: 2px solid rgba(13,59,102,0.35) !important;
}
body #sidebar > .sidebar-menu::-webkit-scrollbar-thumb:hover,
body #sidebar > nav.sidebar-menu::-webkit-scrollbar-thumb:hover,
body #sidebar > .sidebar-scroll-zone::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.82) !important;
}

/* 3) Footer is always fixed at bottom inside sidebar */
body #sidebar > .sidebar-footer,
body #sidebar > .sidebar-action-zone {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-height: none !important;
    overflow: hidden !important;
    padding: 10px 12px 11px !important;
    margin: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.14) !important;
    background: rgba(0,0,0,0.20) !important;
    box-shadow: 0 -10px 18px rgba(0,0,0,0.12) !important;
}

body #sidebar .menu-section-label {
    padding: 7px 18px 5px !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    letter-spacing: .08em !important;
    text-transform: uppercase !important;
    color: rgba(255,255,255,.56) !important;
}

body #sidebar .sidebar-divider {
    height: 1px !important;
    margin: 8px 16px !important;
    background: rgba(255,255,255,0.13) !important;
}

body #sidebar .menu-item {
    width: 100% !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    gap: 11px !important;
    padding: 9px 18px !important;
    color: #fff !important;
    border-left: 4px solid transparent !important;
    background: transparent !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    line-height: 1.15 !important;
    transition: background .18s ease, border-color .18s ease !important;
}

body #sidebar .menu-item:hover {
    background: rgba(255,255,255,0.14) !important;
}

body #sidebar .menu-item.active {
    border-left-color: var(--brand-accent, #f9a826) !important;
    background: rgba(255,255,255,0.20) !important;
}

body #sidebar .menu-item i {
    width: 24px !important;
    min-width: 24px !important;
    text-align: center !important;
    margin: 0 !important;
    font-size: 1.05rem !important;
}

body #sidebar .command-title {
    margin: 0 0 7px !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: rgba(255,255,255,0.50) !important;
}

body #sidebar .footer-text {
    font-size: 9px !important;
    line-height: 1.25 !important;
    color: rgba(255,255,255,0.50) !important;
}

body #sidebar > .sidebar-footer button,
body #sidebar > .sidebar-action-zone button {
    min-height: 32px !important;
}

/* Collapsed mode: header/footer stay fixed, menu is icon-only */
body #sidebar:not(.expanded) .sidebar-text,
body #sidebar:not(.expanded) .menu-section-label,
body #sidebar:not(.expanded) .sidebar-divider,
body #sidebar:not(.expanded) .command-title,
body #sidebar:not(.expanded) .footer-text {
    display: none !important;
}

body #sidebar:not(.expanded) > .sidebar-header {
    padding: 12px 0 10px !important;
}

body #sidebar:not(.expanded) .logo {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    margin: 0 auto !important;
    padding: 7px !important;
}

body #sidebar:not(.expanded) > .sidebar-menu,
body #sidebar:not(.expanded) > nav.sidebar-menu,
body #sidebar:not(.expanded) > .sidebar-scroll-zone {
    padding: 8px 0 !important;
}

body #sidebar:not(.expanded) .menu-item {
    justify-content: center !important;
    min-height: 42px !important;
    padding: 9px 0 !important;
    gap: 0 !important;
}

body #sidebar:not(.expanded) .menu-item i {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 1.15rem !important;
}

body #sidebar:not(.expanded) .menu-item span,
body #sidebar:not(.expanded) .menu-item .sidebar-text,
body #sidebar:not(.expanded) .menu-item [id$="badge"] {
    display: none !important;
}

body #sidebar:not(.expanded) > .sidebar-footer,
body #sidebar:not(.expanded) > .sidebar-action-zone {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 8px 6px 9px !important;
    overflow: hidden !important;
}

body #sidebar:not(.expanded) > .sidebar-footer .grid,
body #sidebar:not(.expanded) > .sidebar-action-zone .grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 7px !important;
    margin: 0 !important;
}

body #sidebar:not(.expanded) > .sidebar-footer button,
body #sidebar:not(.expanded) > .sidebar-action-zone button,
body #sidebar:not(.expanded) > .sidebar-footer .grid button,
body #sidebar:not(.expanded) > .sidebar-action-zone .grid button {
    display: flex !important;
    width: 42px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    border-radius: 12px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
}

body #sidebar:not(.expanded) > .sidebar-footer button i,
body #sidebar:not(.expanded) > .sidebar-action-zone button i {
    margin: 0 !important;
    font-size: 0.95rem !important;
}

body #sidebar:not(.expanded) > .sidebar-footer button .sidebar-text,
body #sidebar:not(.expanded) > .sidebar-action-zone button .sidebar-text {
    display: none !important;
}

body #main-content {
    margin-left: 64px !important;
    width: calc(100% - 64px) !important;
    transition: margin-left .3s ease, width .3s ease !important;
}

body #main-content.expanded {
    margin-left: 256px !important;
    width: calc(100% - 256px) !important;
}

/* Phase 1: explicit sidebar expand/collapse control */
body #sidebar .sidebar-header {
    position: relative;
}

body .sidebar-toggle-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    background: rgba(255,255,255,0.14);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease, right .18s ease;
    z-index: 5;
}

body .sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.24);
    transform: translateY(-1px);
}

body #sidebar:not(.expanded) .sidebar-toggle-btn {
    top: 64px;
    right: 14px;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.18);
}

body #sidebar:not(.expanded) .sidebar-header {
    min-height: 116px;
}

body .sidebar-trigger {
    width: 26px !important;
    z-index: 1200 !important;
}

/* Mobile: drawer behavior, but still header/menu/footer flex */
@media (max-width: 768px) {
    body #sidebar {
        width: 280px !important;
        transform: translateX(-100%) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3) !important;
        transition: transform .3s ease !important;
        z-index: 1000 !important;
    }

    body #sidebar.expanded {
        transform: translateX(0) !important;
    }

    body #sidebar .sidebar-text,
    body #sidebar .menu-section-label,
    body #sidebar .sidebar-divider,
    body #sidebar .command-title,
    body #sidebar .footer-text {
        display: initial !important;
    }

    body #sidebar .menu-section-label,
    body #sidebar .sidebar-divider,
    body #sidebar .command-title,
    body #sidebar .footer-text {
        display: block !important;
    }

    body #sidebar .menu-item span.sidebar-text {
        display: inline !important;
    }

    body #main-content,
    body #main-content.expanded {
        margin-left: 0 !important;
        width: 100% !important;
    }

    body .sidebar-trigger {
        display: none !important;
    }
}

@media (max-height: 760px) and (min-width: 769px) {
    body #sidebar.expanded > .sidebar-header {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
    body #sidebar.expanded .logo {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        margin-bottom: 5px !important;
    }
    body #sidebar.expanded .sidebar-header h1 { font-size: 0.84rem !important; }
    body #sidebar.expanded .sidebar-header p { font-size: 0.60rem !important; }
    body #sidebar.expanded .menu-item {
        min-height: 35px !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
        font-size: 0.84rem !important;
    }
    body #sidebar.expanded > .sidebar-footer,
    body #sidebar.expanded > .sidebar-action-zone {
        padding-top: 7px !important;
        padding-bottom: 8px !important;
    }
    body #sidebar.expanded > .sidebar-footer button,
    body #sidebar.expanded > .sidebar-action-zone button {
        min-height: 29px !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
    }
}

/* Order schedule compact layout: date stack left, weekdays right */
.order-quick-nav {
    position: sticky;
    top: 12px;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px;
    margin: -4px 0 2px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
}
.order-quick-nav button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.order-quick-nav button:hover {
    transform: translateY(-1px);
    border-color: #60a5fa;
    background: #dbeafe;
}
.global-workflow-nav {
    position: sticky;
    top: 12px;
    z-index: 22;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    margin: -4px 0 16px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
}
.global-workflow-nav__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1e40af;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.global-workflow-nav__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    min-width: 0;
}
.global-workflow-nav button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 900;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.global-workflow-nav button {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
}
.global-workflow-nav button:hover,
.global-workflow-nav button:focus-visible {
    transform: translateY(-1px);
    border-color: #60a5fa;
    background: #dbeafe;
    outline: 0;
}
.global-workflow-dock,
.order-floating-summary {
    display: none !important;
}
.order-schedule-compact {
    display: grid !important;
    grid-template-columns: minmax(230px, 0.42fr) minmax(460px, 1fr) !important;
    gap: 18px !important;
    align-items: start !important;
}
.order-date-grid-stack {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
}
.order-weekdays-full-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
}
@media (min-width: 1280px) {
    .order-weekdays-full-row { flex-wrap: nowrap !important; }
    .order-weekdays-full-row .weekday-btn {
        min-width: 78px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        font-size: 12px !important;
    }
}
@media (max-width: 1024px) {
    .order-schedule-compact { grid-template-columns: 1fr !important; }
    .order-date-grid-stack { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .global-workflow-nav {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .global-workflow-nav__actions {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }
    .global-workflow-nav button {
        flex: 0 0 auto;
    }
}
@media (max-width: 640px) {
    .global-workflow-nav {
        top: 78px;
        margin-left: -2px;
        margin-right: -2px;
        padding: 8px;
    }
    .global-workflow-nav__title {
        font-size: 11px;
    }
    .global-workflow-nav button {
        min-height: 36px;
        padding: 8px 11px;
    }
    .order-quick-nav {
        top: 80px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 8px;
        margin-left: -2px;
        margin-right: -2px;
    }
    .order-quick-nav button {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 8px 11px;
    }
    .order-date-grid-stack { grid-template-columns: 1fr !important; }
    .order-weekdays-full-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media print {
    .global-workflow-nav,
    .global-workflow-dock,
    .order-quick-nav,
    .order-floating-summary {
        display: none !important;
    }
}

/* Phase 1 sidebar toggle fallback: native checkbox keeps expand/collapse clickable. */
body .sidebar-expanded-state {
    position: fixed;
    left: 14px;
    top: 64px;
    width: 36px;
    height: 36px;
    opacity: 0.001;
    z-index: 1400;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    pointer-events: none;
}

body .sidebar-expanded-state:checked {
    left: 214px;
    top: 10px;
}

body .sidebar-toggle-btn::before {
    content: ">";
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

body:has(#sidebar-expanded-state:checked) .sidebar-toggle-btn::before {
    content: "<";
}

body:has(#sidebar-expanded-state:checked) #sidebar {
    width: 256px !important;
}

body:has(#sidebar-expanded-state:checked) #main-content {
    margin-left: 256px !important;
    width: calc(100% - 256px) !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .sidebar-text,
body:has(#sidebar-expanded-state:checked) #sidebar .menu-section-label,
body:has(#sidebar-expanded-state:checked) #sidebar .command-title,
body:has(#sidebar-expanded-state:checked) #sidebar .footer-text {
    display: inline !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .menu-section-label,
body:has(#sidebar-expanded-state:checked) #sidebar .command-title,
body:has(#sidebar-expanded-state:checked) #sidebar .footer-text {
    display: block !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .sidebar-divider {
    display: block !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .sidebar-header h1,
body:has(#sidebar-expanded-state:checked) #sidebar .sidebar-header p {
    display: block !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .sidebar-header {
    min-height: auto !important;
    padding: 12px 16px 10px !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .logo {
    width: 38px !important;
    height: 38px !important;
    margin-bottom: 5px !important;
}

/* Smart Sale app identity */
body #sidebar .logo,
body #sidebar:not(.expanded) .logo,
body:has(#sidebar-expanded-state:checked) #sidebar .logo {
    padding: 0 !important;
    overflow: hidden !important;
    background: transparent !important;
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.24) !important;
}

body #sidebar .logo .app-brand-icon {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.smart-sale-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.install-smart-sale-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .10);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.install-smart-sale-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    transform: translateY(-1px);
}

.install-smart-sale-btn:active { transform: scale(.98); }
.install-smart-sale-btn[hidden] { display: none !important; }

@media (max-width: 1023px) {
    .smart-sale-header-actions {
        width: 100%;
        align-items: flex-start;
    }

    .smart-sale-header-actions > div { text-align: left !important; }
}

body:has(#sidebar-expanded-state:checked) #sidebar .menu-item {
    justify-content: flex-start !important;
    padding: 9px 20px !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar .menu-item i {
    margin-right: 0 !important;
    font-size: 1.1rem !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-footer .grid,
body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-action-zone .grid {
    display: grid !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-footer button,
body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-action-zone button,
body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-footer .grid button,
body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-action-zone .grid button {
    width: 100% !important;
    min-height: 30px !important;
    padding: 6px 10px !important;
}

body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-footer button .sidebar-text,
body:has(#sidebar-expanded-state:checked) #sidebar > .sidebar-action-zone button .sidebar-text {
    display: inline !important;
}

/* Phase 1 collapsed footer: keep every command visible in a compact icon grid. */
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone {
    display: grid !important;
    grid-template-columns: repeat(2, 28px) !important;
    justify-content: center !important;
    align-content: center !important;
    gap: 6px !important;
    padding: 8px 4px !important;
    overflow: visible !important;
    max-height: none !important;
}

body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer .grid,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone .grid {
    display: contents !important;
}

body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer button,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone button,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer .grid button,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone .grid button {
    display: inline-flex !important;
    width: 28px !important;
    height: 32px !important;
    min-width: 28px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 10px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
}

body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer button i,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone button i {
    margin: 0 !important;
    font-size: 0.92rem !important;
}

body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer button .sidebar-text,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone button .sidebar-text,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer .command-title,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone .command-title,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-footer .footer-text,
body:not(:has(#sidebar-expanded-state:checked)) #sidebar > .sidebar-action-zone .footer-text {
    display: none !important;
}

/* Phase 1 mobile UX pass: desktop checkbox fallback must not collapse the drawer. */
@media (max-width: 768px) {
    body .sidebar-expanded-state {
        display: none !important;
        pointer-events: none !important;
    }

    body #mobile-menu-btn {
        display: inline-flex !important;
        width: 60px !important;
        height: 60px !important;
        padding: 0 !important;
        align-items: center !important;
        justify-content: center !important;
    }

    body:has(#sidebar.expanded) #mobile-menu-btn {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(0.92) !important;
    }

    body #sidebar,
    body:has(#sidebar-expanded-state:checked) #sidebar {
        width: min(86vw, 320px) !important;
        max-width: 320px !important;
    }

    body #sidebar.expanded {
        width: min(86vw, 320px) !important;
        max-width: 320px !important;
        transform: translateX(0) !important;
    }

    body #sidebar.expanded .sidebar-text,
    body #sidebar.expanded .menu-section-label,
    body #sidebar.expanded .command-title,
    body #sidebar.expanded .footer-text {
        display: inline !important;
    }

    body #sidebar.expanded .menu-section-label,
    body #sidebar.expanded .command-title,
    body #sidebar.expanded .footer-text,
    body #sidebar.expanded .sidebar-divider,
    body #sidebar.expanded .sidebar-header h1,
    body #sidebar.expanded .sidebar-header p {
        display: block !important;
    }

    body #sidebar.expanded > .sidebar-footer,
    body #sidebar.expanded > .sidebar-action-zone,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone {
        display: block !important;
        padding: 10px 12px 12px !important;
        overflow: hidden !important;
    }

    body #sidebar.expanded > .sidebar-footer .grid,
    body #sidebar.expanded > .sidebar-action-zone .grid,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer .grid,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone .grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
    }

    body #sidebar.expanded > .sidebar-footer button,
    body #sidebar.expanded > .sidebar-action-zone button,
    body #sidebar.expanded > .sidebar-footer .grid button,
    body #sidebar.expanded > .sidebar-action-zone .grid button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer .grid button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone .grid button {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 36px !important;
        padding: 7px 10px !important;
        border-radius: 10px !important;
        gap: 8px !important;
    }

    body #sidebar.expanded > .sidebar-footer button .sidebar-text,
    body #sidebar.expanded > .sidebar-action-zone button .sidebar-text,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer button .sidebar-text,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone button .sidebar-text {
        display: inline !important;
    }

    body #sidebar.expanded .sidebar-toggle-btn {
        top: 10px !important;
        right: 10px !important;
    }
}

@media (max-width: 768px) {
    body #sidebar.expanded > .sidebar-footer,
    body #sidebar.expanded > .sidebar-action-zone,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
        padding: 9px 12px 10px !important;
    }

    body #sidebar.expanded > .sidebar-footer .grid,
    body #sidebar.expanded > .sidebar-action-zone .grid,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer .grid,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone .grid {
        display: contents !important;
    }

    body #sidebar.expanded > .sidebar-footer .command-title,
    body #sidebar.expanded > .sidebar-action-zone .command-title,
    body #sidebar.expanded > .sidebar-footer .footer-text,
    body #sidebar.expanded > .sidebar-action-zone .footer-text {
        display: none !important;
    }

    body #sidebar.expanded > .sidebar-footer button,
    body #sidebar.expanded > .sidebar-action-zone button,
    body #sidebar.expanded > .sidebar-footer .grid button,
    body #sidebar.expanded > .sidebar-action-zone .grid button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-footer .grid button,
    body:not(:has(#sidebar-expanded-state:checked)) #sidebar.expanded > .sidebar-action-zone .grid button {
        width: 100% !important;
        min-height: 34px !important;
        height: 34px !important;
        padding: 0 8px !important;
        margin: 0 !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }

    body #sidebar.expanded > .sidebar-footer > button:first-of-type {
        grid-column: 1 / -1 !important;
    }
}

/* 2026-10-16: tablet portrait 641-768px - keep content below the fixed menu button */
@media (min-width: 641px) and (max-width: 768px) {
    body #main-content { padding-top: 96px !important; }
}

/* 2026-10-16: Smart Recommendation Engine v2 panel */
.smart-rec-ring { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 46px; }
.smart-rec-ring span { width: 36px; height: 36px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #1e293b; }
.smart-rec-plan--featured { box-shadow: 0 0 0 2px #8b5cf6 inset, 0 8px 20px rgba(139, 92, 246, .15); }
.smart-rec-bars { display: grid; gap: 3px; }
.smart-rec-bar { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 40px; align-items: center; gap: 6px; font-size: 11px; color: #475569; }
.smart-rec-bar__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smart-rec-bar__track { height: 6px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.smart-rec-bar__track > span { display: block; height: 100%; background: linear-gradient(90deg, #8b5cf6, #ec4899); border-radius: 4px; }
.smart-rec-bar__val { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .smart-rec-bar { grid-template-columns: minmax(0, 1fr) 70px 38px; } }
.smart-rec-plans { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.smart-rec-info { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* 27 ต.ค. 2569: แท็บเล็ตแนวตั้ง (641-768px) แถบทางลัดต้องอยู่ใต้ปุ่มเมนู (ปุ่มอยู่ที่ 16-76px) ไม่ทับกัน */
@media (min-width: 641px) and (max-width: 768px) {
    .global-workflow-nav,
    .order-quick-nav {
        top: 84px;
    }
}

/* 28 ต.ค. 2569: มือถือ/แท็บเล็ต (<=768px) แถบพื้นหลังคงที่ด้านบน หลังปุ่มเมนู
   เนื้อหาที่เลื่อนผ่านจะซ่อนใต้แถบนี้ ไม่โผล่ข้างปุ่มเมนู / แถบทางลัดอยู่ใต้แถบพอดี */
@media (max-width: 768px) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 84px;
        background: #f1f5f9;
        box-shadow: 0 6px 10px -8px rgba(15, 23, 42, 0.25);
        z-index: 21;
        pointer-events: none;
    }
    .global-workflow-nav,
    .order-quick-nav {
        top: 84px;
    }
}
@media print {
    body::before { display: none !important; }
}
