.tlb-app {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.tlb-top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tlb-input-group {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #f59e0b;
    border-radius: 6px;
    padding: 4px 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tlb-input-group input {
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: bold;
    width: 70px;
    text-align: center;
    color: #d97706;
}

.tlb-input-group select {
    border: none;
    outline: none;
    background: transparent;
    font-weight: 600;
    cursor: pointer;
}

.tlb-input-label {
    font-size: 0.9rem;
    color: #64748b;
    margin-left: 5px;
}

.tlb-tip {
    font-size: 0.9rem;
    color: #64748b;
}

/* Khung chứa thước 5m, hỗ trợ cuộn mượt bằng phần cứng */
.tlb-rulers-container {
    position: relative;
    background: #fafaf9;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 0;
    margin-bottom: 30px;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;

    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tlb-rulers-container::-webkit-scrollbar {
    display: none;
}

.tlb-rulers-container:active {
    cursor: grabbing;
}

.tlb-global-pointer {
    position: sticky;
    top: 0;
    left: 50%;
    width: 2px;
    height: 160px;
    background: #f59e0b;
    z-index: 20;
    pointer-events: none;
    transform: translateX(-50%);
    margin-top: -10px;
}

.tlb-global-pointer span {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid #f59e0b;
}

.tlb-ruler-row {
    margin-bottom: 15px;
    padding: 0 10px;
}
.tlb-ruler-row:last-child {
    margin-bottom: 0;
}

.tlb-ruler-title {
    font-weight: bold;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 4px;
}

.tlb-ruler-track {
    position: relative;
    height: 60px;
    background: #fff;
    border: 1px solid #94a3b8;
    transform: translateZ(0);
}

/* Vạch chia đơn vị mm chi tiết */
.tlb-ruler-scale {
    position: absolute;
    top: 0;
    left: 0;
    height: 12px;
}

.tlb-mm-tick {
    position: absolute;
    top: 0;
    width: 1px;
    background-color: #94a3b8;
}

.tlb-mm-tick.medium {
    height: 6px;
    background-color: #64748b;
}

.tlb-mm-tick.large {
    height: 10px;
    background-color: #1e293b;
    width: 1.5px;
}

/* Nhãn số mm trên thước */
.tlb-ruler-mm-labels {
    position: absolute;
    top: 12px;
    left: 0;
    height: 18px;
    width: 100%;
}

.tlb-mm-label {
    position: absolute;
    top: 0;
    font-size: 9px;
    font-weight: 600;
    color: #1e293b;
    transform: translateX(-50%);
    text-align: center;
    line-height: 18px;
}

/* Tầng các cung Lỗ Ban */
.tlb-segments-level-1, .tlb-segments-level-2 {
    position: absolute;
    left: 0;
    height: 15px;
    display: flex;
}

.tlb-segments-level-1 { top: 30px; }
.tlb-segments-level-2 { top: 45px; }

.tlb-seg-box {
    position: absolute;
    height: 15px;
    border-right: 1px solid #94a3b8;
    border-bottom: 1px solid #94a3b8;
    font-size: 11px;
    text-align: center;
    line-height: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
}

.tlb-seg-box.good { color: #000; background: #fff; }
.tlb-seg-box.bad { color: #fff; background: #dc2626; border-color: #b91c1c; }

/* Khu vực hiển thị kết quả */
.tlb-results-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.tlb-result-item {
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 6px;
    padding: 12px 15px;
    box-sizing: border-box;
}

.tlb-result-item .tlb-result-title {
    color: #b45309;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.tlb-result-content {
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.5;
}

/* Bảng tra cứu ma trận giống hình mẫu */
.tlb-lookup-table-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
    margin-top: 10px;
    overflow-x: auto;
    display: block;
}

.tlb-lookup-table-matrix th, .tlb-lookup-table-matrix td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: center;
    white-space: nowrap;
}

.tlb-lookup-table-matrix th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: bold;
}

.tlb-lookup-table-matrix td.cung-name {
    font-weight: bold;
    text-align: center;
    background: #f8fafc;
    vertical-align: middle;
}

.tlb-lookup-table-matrix td.sub-cung {
    text-align: left;
    font-weight: 600;
    background: #fff;
}

.tlb-lookup-table-matrix td.val-cell {
    font-family: monospace;
    color: #0f172a;
}

/* Tô màu trạng thái Cát/Hung cho tên cung */
.tlb-lookup-table-matrix tr.cung-good td.cung-name {
    color: #047857; /* Xanh lá cho Cát */
}
.tlb-lookup-table-matrix tr.cung-bad td.cung-name {
    color: #dc2626; /* Đỏ cho Hung */
}