/* --- CSS VARIABLES (Bảng màu) --- */
.sago-tlb {
    --bg-body: #f9fafb;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --white: #ffffff;
    
    /* Orange */
    --orange-50: #fff7ed;
    --orange-100: #ffedd5;
    --orange-300: #fdba74;
    --orange-600: #ea580c;
    --orange-800: #9a3412;
    /* Red */
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    /* Yellow */
    --yellow-50: #fefce8;
    --yellow-100: #fef9c3;
    --yellow-200: #fde047;
    /* Blue */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-800: #1e40af;
    /* Gray */
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-800: #1f2937;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 0.75rem; /* 12px */
}

/* --- RESET & BASE --- */


.sago-tlb {
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- UTILITIES --- */
.sago-tlb .sago-tlb-container { max-width: 100%; margin: 0 auto; padding: 1rem; }
.sago-tlb .sago-tlb-text-center { text-align: center; }
.sago-tlb .sago-tlb-font-bold { font-weight: 700; }
.sago-tlb .sago-tlb-uppercase { text-transform: uppercase; }
.sago-tlb .sago-tlb-flex { display: flex; }
.sago-tlb .sago-tlb-flex-col { flex-direction: column; }
.sago-tlb .sago-tlb-items-center { align-items: center; }
.sago-tlb .sago-tlb-justify-center { justify-content: center; }
.sago-tlb .sago-tlb-hidden { display: none; }

/* --- COMPONENTS --- */

/* 1. Header & Input */
.sago-tlb .sago-tlb-header-box {
    background: var(--white);
    border: 1px solid var(--orange-100);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 40;
}
.sago-tlb .sago-tlb-app-title {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}
.sago-tlb .sago-tlb-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sago-tlb .sago-tlb-main-input {
    width: 200px;
    font-size: 2.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--orange-600);
    border: 2px solid var(--orange-300);
    border-radius: 0.5rem;
    padding: 0.5rem;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 15px;
}
.sago-tlb .sago-tlb-main-input:focus {
    border-color: var(--orange-600);
    box-shadow: 0 0 0 4px var(--orange-100);
}
.sago-tlb .sago-tlb-unit-label { font-size: 1.5rem; font-weight: 700; color: #6b7280; margin-top: 5px;}
.sago-tlb .sago-tlb-instruction-text {
    font-size: 0.875rem; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}

/* 2. Canvas Ruler Container */
.sago-tlb .sago-tlb-ruler-container {
    background: var(--white);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    user-select: none;
}
.sago-tlb .sago-tlb-ruler-label {
    position: absolute;
    left: 0.5rem;
    z-index: 30;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    border: 1px solid;
}
@media (min-width: 768px) { .sago-tlb .sago-tlb-ruler-label { font-size: 0.875rem; } }
.sago-tlb .sago-tlb-label-blue { color: var(--blue-800); border-color: var(--blue-100); top: 55px; }
.sago-tlb .sago-tlb-label-orange { color: var(--orange-800); border-color: var(--orange-100); top: 150px; }
.sago-tlb .sago-tlb-label-gray { color: var(--text-main); border-color: var(--gray-200); top: 245px; }
.sago-tlb .sago-tlb-cursor-line {
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    width: 2px;
    background-color: var(--red-600);
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: none;
    opacity: 0.8;
}
.sago-tlb canvas {
    display: block;
    width: 100%;
    cursor: grab;
    position: relative;
    z-index: 10;
    touch-action: none;
}
.sago-tlb canvas:active { cursor: grabbing; }

/* 3. Results Section */
.sago-tlb .sago-tlb-results-box {
    background-color: var(--yellow-50);
    border: 1px solid var(--yellow-100);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}
.sago-tlb .sago-tlb-result-item { margin-bottom: 1.5rem; }
.sago-tlb .sago-tlb-result-item:last-child { margin-bottom: 0; }
.sago-tlb .sago-tlb-result-header {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}
.sago-tlb .sago-tlb-result-type-label { font-weight: 500; font-size: 1rem; color: var(--text-muted); }
.sago-tlb .sago-tlb-result-detail { font-size: 1rem; line-height: 1.6; margin-bottom: 0.5rem; }
.sago-tlb .sago-tlb-highlight-val { font-weight: 700; font-size: 1.25rem; }
.sago-tlb .sago-tlb-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.875rem;
    border: 1px solid transparent;
}
.sago-tlb .sago-tlb-badge-good { background-color: var(--red-50); color: var(--red-700); border-color: var(--red-100); }
.sago-tlb .sago-tlb-badge-bad { background-color: var(--gray-100); color: var(--gray-800); border-color: var(--gray-200); }

.sago-tlb .sago-tlb-text-good { color: var(--red-700); }
.sago-tlb .sago-tlb-text-bad { color: var(--gray-800); }

.sago-tlb .sago-tlb-desc-box {
    background: var(--white);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--gray-100);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}
.sago-tlb .sago-tlb-divider { height: 1px; background-color: var(--yellow-200); opacity: 0.5; margin: 1rem 0; }

/* 4. Guide Section */
.sago-tlb .sago-tlb-guide-box {
    background: var(--orange-50);
    border: 1px solid var(--orange-100);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-main);
}
.sago-tlb .sago-tlb-guide-title {
    color: var(--orange-800);
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(251, 146, 60, 0.3);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.sago-tlb .sago-tlb-guide-list {
    background: var(--white);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--orange-100);
    margin-top: 1rem;
    list-style: none;
}
.sago-tlb .sago-tlb-guide-list li { margin-bottom: 0.5rem; display: flex; align-items: start; gap: 0.5rem; }
.sago-tlb .sago-tlb-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; flex-shrink: 0; }
.sago-tlb .sago-tlb-dot-blue { background: #3b82f6; }
.sago-tlb .sago-tlb-dot-orange { background: #f97316; }
.sago-tlb .sago-tlb-dot-gray { background: #6b7280; }

/* 5. Full Table */
.sago-tlb .sago-tlb-table-container {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    margin-bottom: 2rem;
    transition: box-shadow 0.3s ease;
}
.sago-tlb .sago-tlb-table-container:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.sago-tlb .sago-tlb-table-head-section {
    padding: 1.5rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
    border-bottom: 2px solid var(--red-200);
}
.sago-tlb .sago-tlb-table-title {
    font-weight: 700; 
    color: var(--red-700); 
    font-size: 1.25rem; 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}
.sago-tlb .sago-tlb-table-title svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.sago-tlb .sago-tlb-table-head-section p {
    font-size: 0.875rem; 
    color: #6b7280; 
    margin-top: 0.5rem;
    margin-bottom: 0;
    line-height: 1.5;
}
.sago-tlb .sago-tlb-table-scroll { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for table */
.sago-tlb .sago-tlb-table-scroll::-webkit-scrollbar { 
    height: 10px; 
}
.sago-tlb .sago-tlb-table-scroll::-webkit-scrollbar-track { 
    background: #f8f9fa; 
    border-radius: 5px;
}
.sago-tlb .sago-tlb-table-scroll::-webkit-scrollbar-thumb { 
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
    border-radius: 5px;
    transition: background 0.3s ease;
}
.sago-tlb .sago-tlb-table-scroll::-webkit-scrollbar-thumb:hover { 
    background: linear-gradient(135deg, #b91c1c 0%, #c2410c 100%);
}

.sago-tlb table { 
    width: 100%; 
    min-width: 1000px; 
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem; 
}

.sago-tlb th {
    padding: 1rem 0.875rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: var(--red-700);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8125rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--red-300);
    border-right: 1px solid rgba(220, 38, 38, 0.1);
    position: sticky; 
    top: 0; 
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
}

.sago-tlb th:first-child {
    border-top-left-radius: 0;
}

.sago-tlb th:last-child {
    border-top-right-radius: 0;
    border-right: none;
}

.sago-tlb td {
    padding: 0.875rem;
    border-bottom: 1px solid #f3f4f6;
    border-right: 1px solid #f9fafb;
    transition: all 0.2s ease;
    background: var(--white);
}

.sago-tlb td:last-child {
    border-right: none;
}

.sago-tlb tr {
    transition: all 0.2s ease;
}

.sago-tlb tr:hover {
    background-color: #fef2f2;
    transform: scale(1.001);
}

.sago-tlb tr:hover td {
    background-color: #fef2f2;
    border-bottom-color: #fee2e2;
}

.sago-tlb tr:last-child td {
    border-bottom: none;
}

.sago-tlb .sago-tlb-col-main { 
    font-weight: 700; 
    color: var(--red-600); 
    text-transform: uppercase; 
    text-align: center; 
    background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
    vertical-align: middle; 
    border-right: 2px solid var(--red-200);
    font-size: 0.8125rem;
    letter-spacing: 0.5px;
    position: sticky;
    left: 0;
    z-index: 5;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    min-width: 120px;
}

.sago-tlb .sago-tlb-col-main.sago-tlb-neutral { 
    color: var(--gray-700);
    background: linear-gradient(135deg, #fff 0%, #f9fafb 100%);
}

.sago-tlb tr:hover .sago-tlb-col-main {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.sago-tlb .sago-tlb-col-sub { 
    font-weight: 500;
    font-size: 0.875rem;
    padding-left: 1.25rem;
}

.sago-tlb .sago-tlb-col-sub.sago-tlb-good { 
    color: var(--red-600);
    font-weight: 600;
}

.sago-tlb .sago-tlb-col-sub.sago-tlb-bad { 
    color: var(--gray-600);
}

.sago-tlb .sago-tlb-cell-value {
    text-align: right;
    color: var(--gray-800);
    letter-spacing: -0.3px;
    font-size: 0.875rem;
    font-weight: 500;
    padding-right: 1.25rem;
}

.sago-tlb tr:hover .sago-tlb-cell-value {
    color: var(--gray-900);
    font-weight: 600;
}

