@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Noto+Sans+Thai:wght@100..900&display=swap');
        
        /* --- Base Styles --- */
        html { scroll-behavior: smooth; }
        body {
            font-family: 'Noto Sans Thai', 'Inter', sans-serif;
            background-color: #0d111c;
            color: #e5e7eb;
            overflow-x: hidden;
        }
        .text-accent { color: #00e0a5; }
        .bg-accent { background-color: #00e0a5; }
        .border-accent { border-color: #00e0a5; }

        /* --- Custom Component Styles (from index.php inspiration) --- */
        .card {
            background-color: #182033;
            border: 1px solid #2d3748;
            border-radius: 0.75rem; /* 12px */
            transition: all 0.3s ease-in-out;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 224, 165, 0.1);
        }
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem; /* 8px */
            padding: 0.75rem 1.5rem; /* 12px 24px */
            border-radius: 0.5rem; /* 8px */
            font-weight: 700;
            transition: all 0.2s ease-in-out;
            cursor: pointer;
            border: 1px solid transparent;
            font-size: 1rem; /* 16px */
            line-height: 1.5rem; /* 24px */
        }
        .btn-lg {
            padding: 1rem 2rem; /* 16px 32px */
            font-size: 1.125rem; /* 18px */
            line-height: 1.75rem; /* 28px */
        }
        .btn-sm {
            padding: 0.5rem 1rem; /* 8px 16px */
            font-size: 0.875rem; /* 14px */
            line-height: 1.25rem; /* 20px */
        }
        .btn-primary {
            background-color: #00e0a5;
            color: #0d111c;
            box-shadow: 0 4px 14px 0 rgba(0, 224, 165, 0.39);
        }
        .btn-primary:hover {
            background-color: #00c791;
            transform: translateY(-2px);
            box-shadow: 0 6px 18px 0 rgba(0, 224, 165, 0.45);
        }
        .btn-outline {
            background-color: transparent;
            color: #a0aec0;
            border-color: #4a5568;
        }
        .btn-outline:hover {
            background-color: #2d3748;
            color: white;
            border-color: #00e0a5;
        }
        .btn-danger {
            background-color: #e53e3e;
            color: white;
        }
        .btn-danger:hover {
            background-color: #c53030;
        }
        
        .form-input, .form-select, .form-textarea { /* Added form-textarea */
            background-color: #2d3748;
            border: 1px solid #4a5568;
            color: white;
            border-radius: 0.5rem; /* 8px */
            padding: 0.75rem 1rem; /* 12px 16px */
            width: 100%;
            transition: border-color 0.2s, box-shadow 0.2s;
            font-size: 1rem; /* 16px */
        }
        .form-textarea {
             min-height: 80px; /* Give textarea some default height */
        }
        .form-input:focus, .form-select:focus, .form-textarea:focus { /* Added form-textarea */
            outline: none;
            border-color: #00e0a5;
            box-shadow: 0 0 0 3px rgba(0, 224, 165, 0.3);
        }
        .form-input[type="month"]::-webkit-calendar-picker-indicator {
            filter: invert(1);
        }
        .form-input.invalid {
            border-color: #e53e3e;
            box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.3);
        }

        /* --- Input Tabs --- */
        .input-tab {
            cursor: pointer;
            padding: 0.75rem 1.5rem; /* 12px 24px */
            border-bottom: 3px solid transparent;
            color: #a0aec0;
            font-size: 1.125rem; /* 18px */
            font-weight: 500;
        }
        .input-tab.active {
            color: #00e0a5;
            border-bottom-color: #00e0a5;
            font-weight: 700;
        }
        
        /* --- File Upload Area --- */
        #csv-upload-area {
            border: 3px dashed #4a5568;
            border-radius: 0.75rem; /* 12px */
            padding: 3rem; /* 48px */
            text-align: center;
            cursor: pointer;
            transition: background-color 0.2s, border-color 0.2s;
        }
         #csv-upload-area:hover, #csv-upload-area.dragover {
            background-color: #2d3748;
            border-color: #00e0a5;
        }

        /* --- Guide Section (from index.php) --- */
        #guide-section summary::-webkit-details-marker { display: none; }
        #guide-section summary { list-style: none; cursor: pointer; }
        #guide-section summary .ph-caret-down { transition: transform 0.3s; }
        #guide-section details[open] summary .ph-caret-down { transform: rotate(180deg); }

        /* --- Animations --- */
        .fade-in {
            animation: fadeIn 0.8s ease-in-out forwards;
            opacity: 0;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* --- Mobile Menu --- */
        #mobile-menu {
            transition: max-height 0.3s ease-in-out;
            max-height: 0;
            overflow: hidden;
        }

        /* --- Custom Chart Styles --- */
        .chart-svg {
            width: 100%;
            height: 400px;
            font-family: 'Inter', sans-serif;
        }
        .chart-svg .axis-line {
            stroke: #4a5568;
            stroke-width: 1;
        }
        .chart-svg .grid-line {
            stroke: #2d3748;
            stroke-width: 1;
            stroke-dasharray: 4 4;
        }
        .chart-svg .axis-label {
            fill: #a0aec0;
            font-size: 12px;
        }
        .chart-svg .bar-revenue { fill: #00e0a5; opacity: 0.8; }
        .chart-svg .bar-spend { fill: #3b82f6; opacity: 0.8; }
        .chart-svg .bar-net-positive { fill: #22c55e; }
        .chart-svg .bar-net-negative { fill: #ef4444; }
        .chart-svg .bar-forecast { opacity: 0.5; }
        .chart-svg .zero-line {
            stroke: #e5e7eb;
            stroke-width: 2;
            stroke-dasharray: 5 5;
        }
        .chart-svg .breakeven-pin {
            fill: #f59e0b;
            stroke: #fff;
            stroke-width: 2;
        }
        .chart-svg .breakeven-text {
            fill: #f59e0b;
            font-size: 14px;
            font-weight: bold;
            text-anchor: middle;
        }
        .chart-svg .tooltip {
            position: absolute;
            background-color: #0d111c;
            border: 1px solid #4a5568;
            border-radius: 0.5rem;
            padding: 0.75rem;
            color: white;
            font-size: 0.875rem;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s;
            box-shadow: 0 4px 10px rgba(0,0,0,0.5);
            min-width: 200px;
            /* Position off-screen initially */
            left: -9999px; 
            top: -9999px;
            transform: translate(0, 0); /* Reset transform */
        }
        
        /* --- Print Styles --- */
        .no-print { display: block; } /* Default state */
        .print-only { display: none; }
        
        @media print {
            body { 
                background-color: white !important; 
                color: #1f2937 !important; 
                font-family: 'Noto Sans Thai', sans-serif;
                font-size: 10pt;
                margin: 0; /* Reset body margin */
                padding: 0; /* Reset body padding */
            }
            header, footer, #guide-section, #input-section, #config-section, #action-section, #scenario-section, #export-buttons, #ai-section { 
                display: none !important; 
            }
            /* FIX: Hide transparency section in print */
            /* #calculation-transparency-section {
                display: none !important;
            } */ /* REMOVED: ลบออกเพื่อให้แสดงในหน้าพิมพ์ */
            .no-print { display: none !important; }
            .print-only { display: block !important; }
 
            /* --- Layout and Spacing --- */
            main {
                padding: 0 !important;
                margin: 0 !important;
            }
            main > div {
                max-width: none !important; /* Allow full width */
                padding: 0 !important; /* Reset padding */
                margin: 0 !important; /* Reset margin */
            }
            #results-section { 
                display: block !important; 
                box-shadow: none !important; 
                border: none !important; 
                padding: 1cm !important; 
                margin: 0 !important; 
                width: 100%;
            }
            .card, .printable-card { 
                background-color: white !important; 
                color: #1f2937 !important; 
                border: 1px solid #e5e7eb !important; 
                box-shadow: none !important; 
                padding: 1rem !important;
                margin-bottom: 1.5rem;
                -webkit-print-color-adjust: exact; 
                print-color-adjust: exact; 
                page-break-inside: avoid;
            }
            
            .print-only.mb-8 {
                margin-bottom: 1rem !important; /* Reduce margin for print */
            }
            
            /* --- Typography --- */
            h1, h2, h3, h4, p, th, td, li, strong { 
                color: #1f2937 !important; 
            }
            .text-accent { color: #00755e !important; }
            #results-title {
                font-size: 20pt; font-weight: 900;
                margin-bottom: 1rem;
                text-align: left;
                border-bottom: 2px solid #1f2937;
                padding-bottom: 0.5rem;
            }
            
            /* --- KPI Summary --- */
            #kpi-summary {
                display: grid !important;
                grid-template-columns: 1fr 1fr 1fr !important;
                gap: 1.5rem !important;
                background-color: white !important;
                border: 1px solid #e5e7eb;
                border-radius: 8px;
                padding: 1rem;
            }
            #kpi-summary > div {
                padding: 0; border: none;
                text-align: left;
                background-color: transparent !important;
            }
            #kpi-summary h4 { color: #6b7280 !important; font-size: 10pt; margin: 0; }
            #kpi-summary p { margin: 0; }
            #kpi-summary .kpi-value { font-size: 18pt; font-weight: 700; margin-bottom: 2px;}
            #kpi-summary .kpi-detail { font-size: 9pt; color: #6b7280 !important; }

            /* --- Charts --- */
            .chart-container-card {
                /* page-break-before: always; */ /* REMOVED: ลบการบังคับขึ้นหน้าใหม่ เพื่อลดช่องว่าง */
                border: none !important;
            }
            .chart-svg {
                height: 500px; /* Taller for print */
            }
            .chart-svg .axis-line { stroke: #d1d5db; }
            .chart-svg .grid-line { stroke: #e5e7eb; }
            .chart-svg .axis-label { fill: #4b5563; font-size: 10px; }
            .chart-svg .bar-revenue { fill: #a7f3d0; opacity: 1; }
            .chart-svg .bar-spend { fill: #bfdbfe; opacity: 1; }
            .chart-svg .bar-net-positive { fill: #bbf7d0; }
            .chart-svg .bar-net-negative { fill: #fecaca; }
            .chart-svg .zero-line { stroke: #ef4444; }
            .chart-svg .breakeven-pin { fill: #f59e0b; }
            .chart-svg .breakeven-text { fill: #d97706; font-size: 12px; }
            .chart-svg .bar-forecast { opacity: 0.6; }
            .chart-svg {
                background-color: white !important;
            }
            
            /* --- Results Table --- */
            #results-table-container {
                /* page-break-before: always; */ /* REMOVED: ลบการบังคับขึ้นหน้าใหม่ เพื่อลดช่องว่าง */
                border: none !important;
            }
            #results-table th, #results-table td { 
                border: 1px solid #e5e7eb; 
                padding: 8px; 
                text-align: left;
                font-size: 9pt;
            }
            #results-table th { 
                background-color: white !important; 
                font-weight: 700;
                border-bottom: 2px solid #1f2937 !important;
            }
            #results-table tbody tr:nth-child(even) {
                background-color: white !important;
            }
            #results-table .text-green-400 { color: #16a34a !important; }
            #results-table .text-red-400 { color: #dc2626 !important; }
            #results-table .text-gray-400 { color: #6b7280 !important; }
            #results-table .status-badge {
                background-color: transparent !important;
                color: inherit !important;
                padding: 0 !important; border: none;
                font-weight: 600;
            }
             /* Add signature for print */
            .signature {
                display: block !important;
                position: fixed;
                bottom: 1cm;
                right: 1.5cm;
                font-size: 9pt;
                color: #9ca3af;
            }
        }