:root {

             --danger-hover: #dc2626; 
             
        }

        body { font-family: 'Inter', 'Sarabun', sans-serif; background-color: var(--bg-body); padding: 0; margin: 0; box-sizing: border-box; color: var(--text-primary); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

        .top-header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-height); background: var(--bg-surface); border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; padding: 0 24px; z-index: 1000; box-shadow: 0 1px 2px rgba(0,0,0,0.02); box-sizing: border-box; }
        .header-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; color: var(--text-primary); width: var(--sidebar-width); }
        .header-brand img { height: 44px; margin-left: 12px; object-fit: contain; }
        .header-actions { display: flex; align-items: center; gap: 16px; }
        
        .profile-btn { display: flex; align-items: center; gap: 10px; background: #f8fafc; padding: 6px 16px 6px 6px; border-radius: 30px; border: 1px solid var(--border-light); cursor: pointer; transition: 0.2s; }
        .profile-btn:hover { background: #edf7ff; border-color: #badef7; }
        .profile-btn img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
        .profile-info-text { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
        .profile-info-text .user-name { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.2;}
        .profile-info-text .manage-text { font-size: 11px; font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 4px; margin-top: 2px;}
        
        .btn-outline { background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; font-family: inherit; }
        .btn-outline:hover { background: #f8fafc; color: var(--text-primary); border-color: #cbd5e1; }
        .mobile-toggle { display: none; background: transparent; border: none; font-size: 28px; color: var(--text-primary); cursor: pointer; }

        .layout-wrapper { display: flex; flex: 1; margin-top: var(--header-height); height: calc(100vh - var(--header-height)); overflow: hidden; }
        .left-sidebar { width: var(--sidebar-width); background: var(--bg-surface); border-right: 1px solid var(--border-light); display: flex; flex-direction: column; overflow-y: auto; padding: 24px 0; transition: left 0.3s ease; z-index: 900; flex-shrink: 0;}
        .menu-title { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin: 0 24px 12px 24px; }
        .menu-list { list-style: none; padding: 0; margin: 0 0 24px 0; }
        .menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 24px; color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 600; transition: 0.2s; position: relative; cursor: pointer; }
        .menu-item:hover, .menu-item.active { background: #edf7ff; color: var(--primary); }
        .menu-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); border-radius: 0 4px 4px 0; }
        .menu-item i { font-size: 20px; }

        .main-content-split { flex: 1; display: flex; flex-direction: row; overflow: hidden; background: var(--bg-body); padding: 32px; gap: 32px; box-sizing: border-box;}
        .controls-panel { width: 480px; background: var(--bg-surface); border-radius: 12px; border: 1px solid var(--border-light); box-shadow: 0 4px 10px rgba(0,0,0,0.03); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
        .iframe-container { flex: 1; position: relative; background: #525659; border-radius: 12px; overflow-y: auto; overflow-x: hidden; box-shadow: inset 0 0 10px rgba(0,0,0,0.3); display: flex; flex-direction: column; align-items: center; padding: 20px 0; box-sizing: border-box;}

        .panel-header { padding: 20px; border-bottom: 1px solid var(--border-light); background: var(--bg-surface); z-index: 10; display: flex; flex-direction: column; gap: 12px; }
        .panel-header-top { display: flex; justify-content: space-between; align-items: center; }
        
        .tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border-light); width: 100%; margin-top: 10px;}
        .tab-btn { flex: 1; padding: 12px 10px; font-size: 13px; background: transparent; color: var(--text-secondary); border: none; border-bottom: 3px solid transparent; font-weight: 600; cursor: pointer; transition: all 0.2s ease; display: flex; justify-content: center; align-items: center; gap: 6px; font-family: inherit;}
        .tab-btn:hover { background: rgba(79, 70, 229, 0.04); color: var(--primary); }
        .tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

        .btn-company-edit { background: #edf7ff; color: var(--primary); border: 1px solid #badef7; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; gap: 8px; font-family: inherit; box-shadow: 0 2px 4px rgba(79, 70, 229,0.05); }
        .btn-company-edit:hover { background: #dcefff; border-color: #78bff2; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(79, 70, 229,0.1); }
        
        .panel-body { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg-body); display: flex; flex-direction: column;}
        .form-panel { background: var(--bg-surface); padding: 24px; border-radius: 12px; border: 1px solid var(--border-light); box-shadow: 0 1px 3px rgba(0,0,0,0.02); margin-bottom: 20px; }
        .form-panel h4 { margin: 0 0 16px 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text-primary);}
        .form-panel h4 i { color: var(--primary); font-size: 20px; }
        
        label { font-weight: 600; display: block; margin-top: 16px; color: var(--text-primary); font-size: 13px; margin-bottom: 8px;}
        .app-input { width: 100%; padding: 12px; border: 1px solid var(--border-light); border-radius: 8px; box-sizing: border-box; font-family: inherit; font-size: 14px; background: var(--input-bg); transition: 0.2s; color: var(--text-primary); }
        .app-input:focus { outline: none; border-color: var(--primary); background: var(--bg-surface); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
        select.app-input { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; padding-right: 2.5rem; cursor: pointer; }
        
        .quick-time-group { display: flex; gap: 10px; margin-top: 16px; }
        .quick-time-btn { background: #e2e8f0; color: var(--text-primary); border: none; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; flex: 1; transition: 0.2s; font-family: inherit;}
        .quick-time-btn:hover { background: #cbd5e1; }
        .quick-clear-btn { background: #fee2e2; color: var(--danger); border: none; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; flex: 1; transition: 0.2s; font-family: inherit;}
        .quick-clear-btn:hover { background: #fca5a5; }

        .btn-add { background: var(--primary); color: white; margin-top: 24px; width: 100%; padding: 16px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2); font-family: inherit; }
        .btn-add:hover { background: var(--primary-hover); transform: translateY(-1px); }

        .bottom-actions { display: flex; gap: 12px; margin-top: auto; padding-top: 20px;}
        .bottom-btn { flex: 1; padding: 14px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; border: none; display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; font-family: inherit; }
        .btn-history { background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border-light); }
        .btn-history:hover { background: #e2e8f0; }
        .btn-export { background: var(--danger); color: white; box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2); }
        .btn-export:hover { background: var(--danger-hover); }

        .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 2000; display: none; justify-content: center; align-items: center; padding: 24px; }
        .modal-box { background: var(--bg-surface); width: 100%; max-width: 650px; max-height: 85vh; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); border: 1px solid var(--border-light); }
        .modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
        .modal-header h2 { margin: 0; color: var(--text-primary); font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px;}
        .btn-close { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 13px; transition: 0.2s; font-family: inherit;}
        .btn-close:hover { background: var(--input-bg); color: var(--text-primary); }
        .modal-body { padding: 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column;}
        
        .history-table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; border: 1px solid var(--border-light); }
        .history-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
        .history-table th { background: #f8fafc; color: var(--text-secondary); padding: 12px 16px; position: sticky; top: 0; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; white-space: nowrap; z-index: 1;}
        .history-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); white-space: nowrap; }
        
        .btn-action-small { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; transition: 0.2s; font-family: inherit;}
        .btn-action-small:hover { background: var(--input-bg); color: var(--text-primary); }
        .btn-del { background: #fee2e2; color: var(--danger); border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; transition: 0.2s; font-family: inherit;}
        .btn-del:hover { background: #fca5a5; }

        .enterprise-swal-popup { border-radius: 16px !important; padding: 24px !important; border: 1px solid var(--border-light) !important; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25) !important; }
        .enterprise-swal-confirm { background: var(--primary) !important; color: #ffffff !important; border: none !important; border-radius: 8px !important; padding: 12px 24px !important; font-weight: 700 !important; font-family: 'Inter', 'Sarabun', sans-serif !important; }
        .enterprise-swal-cancel { background: var(--danger) !important; color: #ffffff !important; border: none !important; border-radius: 8px !important; padding: 12px 24px !important; font-weight: 700 !important; font-family: 'Inter', 'Sarabun', sans-serif !important; }

        .loading-screen { position: fixed; inset: 0; background: rgba(248, 250, 252, 0.95); backdrop-filter: blur(8px); display: flex; justify-content: center; align-items: center; flex-direction: column; z-index: 9999; }
        .spinner { border: 4px solid var(--border-light); border-top: 4px solid var(--primary); border-radius: 50%; width: 48px; height: 48px; animation: spin 1s linear infinite; margin-bottom: 20px; }
        @keyframes spin { 100% { transform: rotate(360deg); } }

        .sig-canvas-container { border: 1px dashed var(--border-light); border-radius: 8px; width: 100%; height: 160px; background: #f8f9fa; touch-action: none; position: relative; margin-bottom: 12px; overflow: hidden;}
        .sig-canvas-container canvas { width: 100%; height: 100%; cursor: crosshair; }
        .btn-clear-canvas { position: absolute; top: 8px; right: 8px; background: rgba(217, 48, 37, 0.1); color: var(--danger); border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
        .btn-clear-canvas:hover { background: rgba(217, 48, 37, 0.2); }

        .checkbox-custom { width: 18px; height: 18px; margin-top: 2px; cursor: pointer; accent-color: var(--primary); border-radius: 4px; border: 2px solid var(--text-secondary);}

        #pdfArea { display: flex; flex-direction: column; gap: 0; width: 100%; align-items: center; background: white; }
        .pdf-page { background: #fff; width: 210mm; height: 297mm; padding: 12mm 15mm; box-shadow: 0 5px 20px rgba(0,0,0,0.5); color: #000; font-size: 12pt; line-height: 1.5; box-sizing: border-box; position: relative; overflow: hidden; font-family: 'Sarabun', sans-serif; margin-bottom: 20px; }
        .doc-header { text-align: center; margin-bottom: 12px; }
        .doc-header h2 { margin: 0; font-size: 18pt; font-weight: bold; }
        .doc-header h3 { margin: 5px 0 0 0; font-size: 14pt; font-weight: normal; }
        .info-section { margin-bottom: 10px; font-size: 12pt; line-height: 1.8; }
        .info-row { display: flex; align-items: baseline; margin-bottom: 3px; white-space: nowrap; }
        .dotted-text { border-bottom: 1px dotted #000; text-align: center; color: #333; display: inline-block; padding: 0 5px; margin: 0 5px; white-space: nowrap; min-height: 18px; }
        table.time-table { width: 100%; border-collapse: collapse; margin-top: 5px; margin-bottom: 10px; font-size: 11pt; text-align: center; table-layout: fixed; }
        table.time-table th, table.time-table td { border: 1px solid #000; padding: 4px 2px; vertical-align: middle; word-wrap: break-word; }
        table.time-table th { background-color: #f8fafc; font-weight: bold; font-size: 10pt; line-height: 1.2; }
        table.time-table td.empty-row { height: 26px; } 
        table.time-table td { height: 26px; } 
        .summary-section { font-size: 12pt; line-height: 1.6; }
        .summary-note { margin-top: 5px; font-size: 11pt; line-height: 1.4; }

        @media print {
            @page { size: A4 portrait; margin: 12mm 15mm; } 
            body * { visibility: hidden; } 
            body, html { background: white !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; height: auto !important; }
            #pdfArea, #pdfArea * { visibility: visible; }
            .layout-wrapper, .main-content-split, .iframe-container, #scale-container { display: block !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; height: auto !important; transform: none !important; background: transparent !important; border: none !important; box-shadow: none !important; }
            #pdfArea { position: absolute; left: 0; top: 0; width: 100%; display: block; }
            .pdf-page { width: 100% !important; height: auto !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; page-break-after: always; background: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
            .top-header, .left-sidebar, .controls-panel, .modal-overlay, #loading, .swal2-container { display: none !important; }
        }

        @media (max-width: 1024px) {
            .main-content-split { flex-direction: column; overflow-y: auto; padding: 20px; gap: 20px; }
            .controls-panel { width: 100%; flex: none; height: auto; min-height: 500px; }
            .iframe-container { width: 100%; flex: none; min-height: 500px; padding: 20px 0; box-sizing: border-box; }
        }
        
        @media (max-width: 768px) {
            .left-sidebar { position: fixed; left: -100%; top: var(--header-height); bottom: 0; box-shadow: 4px 0 10px rgba(0,0,0,0.1); width: 260px; z-index: 1000; }
            .left-sidebar.show { left: 0; }
            .mobile-toggle { display: block; }
            .header-brand { width: auto; gap: 8px; font-size: 18px; }
            .header-brand span { display: none; }
            .header-actions { gap: 10px; }
            .profile-btn { padding: 4px; border-radius: 50%; }
            .profile-info-text { display: none; }
            .btn-outline .hide-mobile { display: none; }
            .btn-outline { padding: 8px; width: 36px; height: 36px; display: flex; justify-content: center; align-items: center; border-radius: 50%; }
            .main-content-split { padding: 16px; gap: 16px; }
            .controls-panel { min-height: auto; }
            .iframe-container { min-height: 400px; padding: 16px 0; }
            .quick-time-group { flex-direction: column; gap: 8px; }
            .modal-overlay { padding: 12px; }
            .modal-box { max-height: 90vh; border-radius: 12px; }
            .modal-header { padding: 16px; }
            .modal-body { padding: 16px; }
        }
