/* ==================== Index Page Styles ==================== */

.index {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (max-width: 1100px) {
    .index {
        gap: 1.75rem;
    }
}

@media (max-width: 560px) {
    .index {
        gap: 1.25rem;
    }
}

/* Statistics Summary */
.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    background: var(--surface-bg);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--surface-shadow-soft);
}

/* Statistics Summary Inline */
.results-summary-inline {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--config-inline-gap);
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    box-sizing: border-box;
    min-width: 0;
    height: 90px;
    min-height: 90px;
}

.results-summary-inline .summary-item {
    padding: 0.6rem 0.5rem;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 90px;
    height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: visible;
    word-wrap: break-word;
    word-break: break-word;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
    padding: 0.875rem 0.75rem;
    background: var(--surface-muted-bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    position: relative;
    overflow: hidden;
}

.summary-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb), 0.3), transparent);
    opacity: 0;
}

.summary-item.clickable-stat {
    cursor: pointer;
}

.summary-item.clickable-stat:hover {
    background: var(--surface-hover-bg);
    box-shadow: var(--surface-shadow-hover);
    border-left-color: var(--primary);
}

.summary-item.clickable-stat:hover::before {
    opacity: 1;
}

.summary-item[data-filter="success"] {
    border-left-color: #28a745;
}

.summary-item[data-filter="success"]:hover {
    border-left-color: #28a745;
}

.summary-item[data-filter="failed"] {
    border-left-color: #dc3545;
}

.summary-item[data-filter="failed"]:hover {
    border-left-color: #dc3545;
}

.summary-label {
    font-size: clamp(0.5rem, 1.2vw + 0.5rem, 0.8rem);
    color: #666;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: visible;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.summary-value {
    font-size: clamp(0.9rem, 2.5vw + 0.5rem, 1.75rem);
    font-weight: 400;
    color: var(--primary);
    white-space: nowrap;
    overflow: visible;
    text-overflow: ellipsis;
    line-height: 1.2;
    flex-shrink: 0;
}

.summary-item.clickable-stat:hover .summary-value {
    transform: scale(1.05);
}

.summary-value.success {
    color: #28a745 !important;
}

.summary-value.failed {
    color: #dc3545 !important;
}

.summary-value.rate-medium {
    color: #ffc107 !important;
}

/* Control Card */
.control-card {
    --control-section-divider-gap: 1.5rem;
    background: var(--surface-bg);
    box-shadow: var(--surface-shadow-soft);
    overflow: visible;
    margin-bottom: 0;
}

.control-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: visible;
}

/* Basic Configuration */
.basic-config {
    margin-bottom: 0;
    padding-bottom: 0;
}

.config-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: nowrap;
}

.config-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    white-space: nowrap;
}

.basic-config .config-group,
.file-config-content .config-group {
    flex: 0 1 auto;
    min-width: 0;
}


/* Nhóm bên phải: Số lượng, Số luồng, Delay và nút Bắt đầu */
.basic-config .config-group-right,
.file-config-content .config-group-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(118px, auto);
    grid-auto-rows: auto;
    gap: var(--config-inline-gap);
    align-items: center;
    flex: 0 1 auto;
    min-width: 300px;
    max-width: 100%;
    box-sizing: border-box;
    justify-self: end;
    align-self: start;
    height: 90px;
    min-height: 90px;
}

/* Mỗi hàng: input bên trái, nút bên phải */
.config-row-item {
    display: contents;
}

/* Đảm bảo các phần tử trong grid thẳng hàng */
.config-row-item .config-group {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
    align-self: center;
}

/* Tất cả input tự động điều chỉnh kích thước */
.config-row-item .config-group .config-input {
    width: 100%;
    min-width: 60px;
    max-width: var(--header-input-width);
    flex: 1 1 auto;
}

/* Hàng 1: Số luồng ở cột 1 */
.config-row-item:first-child .config-group:not(#configQuantityGroup):not(#configDelayGroup) {
    grid-column: 1;
    grid-row: 1;
}

/* Số lượng và Delay cùng vị trí - cột 1, hàng 2 (thẳng dưới Số luồng) */
.config-row-item:first-child .config-group#configQuantityGroup,
.config-row-item:last-child .config-group#configQuantityGroup,
.config-row-item:last-child .config-group#configDelayGroup {
    grid-column: 1;
    grid-row: 2;
}

/* Hàng 1: Nút Bắt đầu ở cột 2, hàng 1 - bám sát Số luồng */
.config-row-item:first-child .btn {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    margin: 0;
}

/* Hàng 2: Nút Cấu hình ở cột 2 - bám sát Delay/Số lượng, hàng 2 */
.config-row-item:last-child .btn-toggle-file-config {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    margin: 0;
}

.config-group label {
    font-size: var(--form-label-font-size);
    color: rgba(var(--control-text-rgb), 0.72);
    font-weight: 400;
    white-space: nowrap;
    min-width: var(--config-label-width);
    text-align: left;
    display: inline-block;
    flex-shrink: 0;
}

.config-input {
    padding: 0.5rem 0.6rem;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--form-control-radius);
    font-size: var(--form-control-font-size);
    width: 100%;
    min-width: 60px;
    max-width: var(--header-input-width);
    text-align: center;
    flex: 1 1 auto;
    box-sizing: border-box;
    height: calc(0.5rem * 2 + 1em * 1.2 + 2px);
    line-height: 1.2;
}


/* Buttons trong config-row-item */
.config-row-item .btn {
    min-width: var(--header-action-width);
    max-width: 100%;
    padding: 0.6rem 1.2rem;
    font-size: var(--form-control-font-size);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-shrink: 0;
    box-sizing: border-box;
    height: calc(0.6rem * 2 + 1em * 1.2 + 2px);
    line-height: 1.2;
    text-shadow: none !important;
}

.config-row-item .btn .btn-icon {
    width: clamp(14px, 1.2vw + 0.5rem, 18px);
    height: clamp(14px, 1.2vw + 0.5rem, 18px);
    flex-shrink: 0;
    color: currentColor;
    fill: currentColor;
    stroke: currentColor;
    filter: none;
}

.config-row-item .btn .btn-icon.btn-icon-loading {
    animation: btn-icon-spin 0.8s linear infinite;
    fill: none !important;
    stroke: currentColor !important;
    transform-box: fill-box;
    transform-origin: center center;
}

.config-row-item .btn .btn-icon.btn-icon-loading * {
    fill: none !important;
    stroke: currentColor !important;
}

@keyframes btn-icon-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .config-row-item .btn .btn-icon.btn-icon-loading {
        animation: none;
    }
}

.config-row-item .btn-toggle-file-config {
    min-width: var(--header-action-width);
    max-width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: var(--form-control-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: var(--form-control-font-size);
    flex-shrink: 0;
    box-sizing: border-box;
    height: calc(0.6rem * 2 + 1em * 1.2 + 2px);
    line-height: 1.2;
}

.config-row-item .btn-toggle-file-config .settings-icon {
    width: clamp(12px, 1.2vw + 0.4rem, 16px);
    height: clamp(12px, 1.2vw + 0.4rem, 16px);
    color: currentColor;
    fill: none;
    stroke: currentColor;
    filter: none;
    pointer-events: none;
}

.config-row-item .btn-toggle-file-config.collapsed .settings-icon {
    transform: rotate(0deg);
}

.config-row-item .btn-toggle-file-config:not(.collapsed) .settings-icon {
    transform: rotate(90deg);
}

.config-row-item .btn-toggle-file-config span {
    font-weight: 400;
    font-size: inherit;
}

/* File Configuration */
.file-config {
    margin-top: 1.5rem;
    padding-top: 0;
    border-top: none; /* Không có border mặc định */
}

/* File Config Wrapper */
.file-config-wrapper {
    position: relative;
    border-top: 0;
    margin-top: var(--control-section-divider-gap);
    padding-top: var(--control-section-divider-gap);
    overflow: visible;
}

.file-config-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--surface-border);
    pointer-events: none;
}

/* Khi collapsed, ẩn hoàn toàn không có gap hay border */
.file-config-wrapper.collapsed {
    display: none;
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
    overflow: hidden;
}

.file-config-wrapper.collapsed::before {
    display: none;
}

.file-config-input[readonly] {
    cursor: not-allowed;
}

.file-content-textarea {
    width: 100%;
    height: var(--form-control-height);
    min-height: var(--form-control-height);
    max-height: none;
    padding: 0.45rem 0.75rem;
    line-height: 1.25;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--form-control-radius);
    font-size: 0.95rem;
    font-family: var(--font-mono);
    resize: vertical;

    box-sizing: border-box;
}



.file-content-textarea[readonly] {
    cursor: default;
}

.file-content-textarea:not([readonly]) {
    cursor: text;
}

/* Placeholder cho file-content-textarea */
.file-content-textarea::placeholder {
    color: #999;
    font-style: italic;
}

.file-content-textarea::-webkit-input-placeholder {
    color: #999;
    font-style: italic;
}

.file-content-textarea::-moz-placeholder {
    color: #999;
    font-style: italic;
}

.file-content-textarea:-ms-input-placeholder {
    color: #999;
    font-style: italic;
}

/* Status upload trong label */
.up-web-upload-status {
    font-size: 0.85rem;
    font-weight: 400;
    margin-left: 0.5rem;
}

/* Custom Select Dropdown với Search */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--form-control-radius);

    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.2;
    min-height: calc(0.5rem * 2 + 1.2em);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.custom-select-trigger span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border);
    border-radius: 13px;
    box-shadow: var(--dropdown-shadow);
    z-index: 99999; /* Tăng z-index lên rất cao để không bị table che */
    display: none;
    margin-top: 0;
    max-height: 300px;
    overflow: hidden;
    flex-direction: column;
}

.custom-select-options.show {
    display: flex;
}

.custom-select-search {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--dropdown-search-border);
    background: var(--dropdown-search-bg);
}

.custom-select-search input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--form-control-radius);

    font-size: 0.9rem;

    line-height: 1.2;
    box-sizing: border-box;
}


.custom-select-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.custom-select-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: var(--dropdown-option-text);
    font-size: 0.9rem;
}

.custom-select-option.hidden {
    display: none;
}

/* Native select replacement for config dropdowns: keeps real select value, avoids OS blue popup. */
.config-native-select-hidden {
    display: none !important;
}

.config-native-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.config-native-select.open {
    z-index: 10002;
}

.config-native-select-trigger {
    width: 100%;
    height: var(--form-control-height);
    min-height: var(--form-control-height);
    padding: 0 2rem 0 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--form-control-radius);

    font: inherit;
    font-size: var(--form-control-font-size);
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    position: relative;
}



.config-native-select-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.config-native-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.25rem 0;
    border: 1px solid var(--dropdown-border);
    border-radius: var(--form-control-radius);
    background: var(--dropdown-bg);
    box-shadow: var(--dropdown-shadow);
    box-sizing: border-box;
    z-index: 10003;
}

.config-native-select-option {
    min-height: var(--dropdown-option-height);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    color: var(--dropdown-option-text);
    font-size: var(--form-control-font-size);
    line-height: 1.25;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
}

.config-native-select-option.disabled,
.config-native-select.disabled .config-native-select-trigger {
    opacity: 0.6;
    cursor: not-allowed;
}

.file-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    align-items: stretch;
    background: transparent;
    background-color: transparent;
    border: 0;
    box-shadow: none;
}

/* Dashboard trong basic-config - rộng hơn */
.basic-config > .file-config-grid {
    grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr);
    align-items: stretch;
    min-width: 0;
    gap: 0.75rem;
}

/* Đảm bảo các phần tử không bị đè lên nhau */
.basic-config > .file-config-grid > * {
    min-width: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

/* Đặc biệt cho file-config-group chứa custom-select */
.basic-config > .file-config-grid > .file-config-group {
    overflow: visible;
}

.results-summary-inline {
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.config-group-right {
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.basic-config > .file-config-grid > .results-summary-inline {
    overflow: visible;
}

@media (max-width: 1100px) {
    .basic-config > .file-config-grid {
        grid-template-columns: minmax(0, 1fr) minmax(280px, auto);
        gap: 0.75rem;
    }

    .basic-config .config-group-right {
        display: grid;
        grid-template-columns: minmax(0, 1fr) var(--header-action-width);
        align-items: center;
        justify-self: end;
        width: auto;
        min-width: 280px;
        height: 90px;
        min-height: 90px;
        overflow: visible;
    }

    .basic-config .config-group-right .config-row-item {
        display: contents;
    }

    .basic-config .config-group-right .config-row-item .config-group {
        justify-content: flex-end;
        width: 100%;
    }

    .basic-config .config-group-right .config-row-item > .config-group,
    .basic-config .config-group-right .config-row-item > .btn,
    .basic-config .config-group-right .config-row-item > .btn-toggle-file-config {
        align-self: center;
    }

    .basic-config .config-group-right .config-row-item:first-child > .config-group:not(#configQuantityGroup):not(#configDelayGroup) {
        grid-column: 1;
        grid-row: 1;
    }

    .basic-config .config-group-right .config-row-item:first-child > .btn {
        grid-column: 2;
        grid-row: 1;
    }

    .basic-config .config-group-right .config-row-item:last-child > #configDelayGroup,
    .basic-config .config-group-right .config-row-item:last-child > #configQuantityGroup {
        grid-column: 1;
        grid-row: 2;
    }

    .basic-config .config-group-right .config-row-item:last-child > .btn-toggle-file-config {
        grid-column: 2;
        grid-row: 2;
    }

    .basic-config .config-group-right .config-row-item .btn,
    .basic-config .config-group-right .config-row-item .btn-toggle-file-config {
        width: var(--header-action-width);
        min-width: var(--header-action-width);
        max-width: var(--header-action-width);
    }
}

@media (max-width: 640px) {
    .basic-config > .file-config-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .basic-config .config-group-right {
        justify-self: stretch;
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 0;
    }
}

@media (max-width: 560px) {
    .basic-config .config-group-right {
        grid-template-columns: minmax(0, 1fr) var(--header-action-width);
        gap: var(--config-inline-gap);
        height: auto !important;
        min-height: 0 !important;
    }

    .basic-config .config-group-right .config-row-item:first-child > .config-group:not(#configQuantityGroup):not(#configDelayGroup) {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .basic-config .config-group-right .config-row-item:first-child > .btn {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    .basic-config .config-group-right .config-row-item:first-child > #configQuantityGroup,
    .basic-config .config-group-right .config-row-item:last-child > #configQuantityGroup,
    .basic-config .config-group-right .config-row-item:last-child > #configDelayGroup {
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    .basic-config .config-group-right .config-row-item:last-child > .btn-toggle-file-config {
        grid-column: 2 !important;
        grid-row: 2 !important;
    }

    .basic-config .config-group-right .config-row-item .btn,
    .basic-config .config-group-right .config-row-item .btn-toggle-file-config {
        width: var(--header-action-width);
        min-width: var(--header-action-width);
        max-width: var(--header-action-width);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .basic-config .config-group-right .config-row-item .config-group {
        flex-wrap: nowrap;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    .basic-config .config-group-right .config-row-item .config-group label {
        min-width: var(--config-label-width);
        width: auto;
    }

    .basic-config .config-group-right .config-row-item .config-group .config-input {
        min-width: 52px;
        max-width: var(--header-input-width);
    }
}

/* Ẩn các item có display: none khỏi grid layout */
.file-config-grid > [style*="display: none"] {
    display: none !important;
}

/* Đảm bảo file-config-group không bị co giãn không đều */
.file-config-grid > .file-config-group {
    min-width: 0;
}

.file-config-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    overflow: visible;
    position: relative;
}

.file-config-group label {
    font-size: 0.9rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    flex-wrap: nowrap;
}

.file-config-group label span {
    display: inline;
    white-space: nowrap;
    margin: 0;
    padding: 0;
}

/* Giảm khoảng cách cho label chứa proxy count */
label[for="proxyListFree"] {
    gap: 0;
    display: inline-block;
}

.file-config-group label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.file-config-input {
    padding: 0.5rem 0.75rem;
    border-width: 1px;
    border-style: solid;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.2;
    min-height: calc(0.5rem * 2 + 1.2em);
    width: 100%;

    box-sizing: border-box;
}

/* Password Input Wrapper với Eye Toggle */
.password-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.password-input-wrapper .file-config-input {
    padding-right: 2.5rem;
}

.password-input-wrapper .config-secret-input.is-masked {
    -webkit-text-security: disc;
}

.password-toggle-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.eye-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

/* Mặc định: ẩn cả 2 icon, sẽ được điều khiển bởi các rule cụ thể bên dưới */
.password-input-wrapper .eye-icon {
    display: none;
}

/* Khi nội dung đang ẩn, hiển thị mắt có gạch chéo. */
.password-input-wrapper .config-secret-input.is-masked ~ .password-toggle-btn .eye-icon.eye-closed {
    display: block !important;
}

.password-input-wrapper .config-secret-input.is-masked ~ .password-toggle-btn .eye-icon.eye-open {
    display: none !important;
}

/* Khi nội dung đang hiện, hiển thị mắt không có gạch chéo. */
.password-input-wrapper .config-secret-input:not(.is-masked) ~ .password-toggle-btn .eye-icon.eye-open {
    display: block !important;
}

.password-input-wrapper .config-secret-input:not(.is-masked) ~ .password-toggle-btn .eye-icon.eye-closed {
    display: none !important;
}

/* Mobile: chỉ về 1 cột khi không còn đủ không gian thao tác */
@media (max-width: 560px) {
    .file-config-grid {
        grid-template-columns: 1fr;
    }
}

/* Threads Table */
.table-container {
    margin-top: 2rem;
    position: relative;
    z-index: 0; /* Đảm bảo table container có z-index thấp hơn dropdown */
}

body.embedded-shell .index .threads-table-panel {
    will-change: auto;
}

.threads-table-panel.threads-table-hidden {
    display: none !important;
}

/* Threads Table Container (chỉ chứa table) */
.threads-table-container {
    z-index: 0; /* Đảm bảo table container có z-index thấp hơn dropdown */
}

.threads-table {
    min-width: 800px; /* Đảm bảo bảng không bị co nhỏ hơn tổng độ rộng các cột */
}

.threads-table th .resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    background: transparent;
    z-index: 1;
    border-right: 1px solid var(--threads-table-border-color);
}

.threads-table th .resizer:hover {
    background: rgba(var(--primary-rgb), 0.2);
    border-right: 1px solid var(--primary);
}

.threads-table th.resizing .resizer {
    background: rgba(var(--primary-rgb), 0.3);
    border-right: 1px solid var(--primary);
}

.threads-table th.resizing {
    user-select: none;
}

.threads-table th:nth-child(1) { 
    width: 50px !important; 
    min-width: 50px;
    max-width: 50px;
    text-align: center;
    position: sticky;
    left: 0;
    background: var(--table-header-bg);
    border-right: none;
    z-index: 10;
    box-shadow: none;
} /* STT - ghim bên trái */

.threads-table th:nth-child(2) { 
    width: 90px !important; 
    min-width: 90px;
    max-width: 90px;
    text-align: center;
} /* Tên luồng - cố định */

.threads-table th:nth-child(3) { width: 15%; } /* Proxy */
.threads-table th:nth-child(4) { width: 25%; } /* UserAgent */
.threads-table th:nth-child(5) { 
    width: auto; 
    border-right: none;
} /* Trạng thái - phần còn lại */

.threads-table th:nth-child(5) .resizer {
    display: none !important;
} /* Ẩn resizer của cột Trạng thái (bên trái cột Tổng) */
.threads-table th:nth-child(6) { 
    width: 15% !important; 
    min-width: 15%;
    max-width: 15%;
    text-align: center;
    position: sticky;
    right: 0;
    background: var(--table-header-bg);
    background-clip: padding-box;
    border-left: none;
    border-right: 1px solid var(--threads-table-border-color);
    z-index: 10;
    box-shadow: none;
} /* Tổng - cố định bên phải */

.threads-table td:nth-child(1) {
    width: 50px !important; 
    min-width: 50px;
    max-width: 50px;
    text-align: center;
    position: sticky;
    left: 0;
    background: var(--table-row-bg);
    border-right: none;
    z-index: 5;
    box-shadow: none;
} /* STT - ghim bên trái */

.threads-table td:nth-child(2) { 
    width: 90px !important; 
    min-width: 90px;
    max-width: 90px;
    text-align: center;
} /* Tên luồng - cố định */

.threads-table td:nth-child(5) {
    border-right: none;
}

.threads-table td:nth-child(6) {
    text-align: left;
    position: sticky;
    right: 0;
    background: var(--table-row-bg);
    border-left: none;
    border-right: 1px solid var(--threads-table-border-color);
    z-index: 5;
    box-shadow: none;
} /* Tổng - ghim bên phải */

/* Stats cell styling */
.threads-table .stats-cell {
    font-size: clamp(0.7rem, 1vw + 0.4rem, 0.85rem);
    text-align: left;
    white-space: nowrap;
}

.threads-table .stat-live {
    color: #28a745;
    font-weight: normal;
}

.threads-table .stat-die {
    color: #dc3545;
    font-weight: normal;
}

.threads-table .stat-error {
    color: #ffc107;
    font-weight: normal;
}

.status-cell {
    font-weight: normal;
}

.status-live .status-cell {
    color: #2e7d32;
}

.status-success .status-cell {
    color: #2e7d32; /* Màu xanh cho thành công */
}

.status-die .status-cell {
    color: #c62828;
}

/* Màu sắc cho các phần trong status */
.status-success-text {
    color: #2e7d32; /* Màu xanh cho "thành công" */
    font-weight: normal;
}

.status-error-text {
    color: #dc3545; /* Màu đỏ cho "lỗi" */
    font-weight: normal;
}

.status-stopped .status-cell {
    color: #dc3545;
    font-weight: normal;
}

.status-stopping .status-cell {
    color: #ff9800;
    font-weight: normal;
}

/* Status: Proxy Die */
.status-proxy-die .status-cell {
    color: #dc3545;
    font-weight: normal;
}

/* Status: Lỗi đăng ký */
.status-error .status-cell {
    color: #dc3545;
    font-weight: normal;
}

/* Status: Facebook chặn */
.status-blocked .status-cell {
    color: #dc3545;
    font-weight: normal;
}

.useragent-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem !important;
    width: 100%;
    display: table-cell;
    position: relative;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--surface-muted-bg);
    border-bottom: 1px solid var(--threads-table-border-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    flex-wrap: nowrap;
}

.pagination-left,
.pagination-center,
.pagination-right {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.pagination-left {
    flex: 0 0 auto;
    justify-content: flex-start;
    display: flex;
    align-items: center;
    min-width: 0;
}

.pagination-center {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
}

.pagination-right {
    flex: 0 0 auto;
    justify-content: flex-end;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: visible;
}

.system-info-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(0.8rem, 1.2vw + 0.5rem, 0.95rem);
    line-height: 1.5;
    height: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.system-info-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #495057;
    background: transparent;
}


.system-info-label {
    font-weight: 400;
    text-align: left;
}

.system-info-value {
    font-weight: 400;
    text-align: left;
    min-width: 45px;
    display: inline-block;
}

.system-info-item.stat-cpu-item .system-info-label,
.system-info-item.stat-cpu-item .system-info-value {
    color: #0d6efd;
}

.system-info-item.stat-ram-item .system-info-label,
.system-info-item.stat-ram-item .system-info-value {
    color: #6f42c1;
}

/* Threads Stats Top */
.threads-stats-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: clamp(0.8rem, 1.2vw + 0.5rem, 0.95rem);
    line-height: 1.5;
    height: 100%;
    white-space: nowrap;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow: hidden;
}

/* Khi pagination-info bị ẩn, căn lề phải cho threads-stats-top */
.pagination-controls.pagination-info-hidden .pagination-center .threads-stats-top {
    justify-content: flex-end;
}

.threads-stats-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #495057;
    white-space: nowrap;
    flex-shrink: 0;
    background: transparent;
}


.threads-stats-label {
    font-weight: 400;
    color: #6c757d;
    text-align: center;
}

.threads-stats-value {
    font-weight: 400;
    text-align: left;
    min-width: 50px;
    display: inline-block;
}

.threads-stats-item:first-child .threads-stats-label,
.threads-stats-item:first-child .threads-stats-value {
    color: #0d6efd;
}

.threads-stats-item .threads-stats-label.stat-live-label,
.threads-stats-value.stat-live {
    color: #28a745;
}

.threads-stats-item .threads-stats-label.stat-die-label,
.threads-stats-value.stat-die {
    color: #c62828;
}

.threads-stats-item .threads-stats-label.stat-error-label,
.threads-stats-value.stat-error {
    color: #ff9800;
}


.threads-stats-item .threads-stats-label.stat-rate-label {
    color: #28a745; /* Cố định cùng màu Live ở cột Tổng, không đổi theo theme/tỷ lệ */
}

.threads-stats-value.stat-rate {
    color: var(--primary); /* Màu mặc định */
}

/* Màu cho value khi tỷ lệ cao (>= 70%) */
.threads-stats-value.stat-rate.rate-high {
    color: #28a745; /* Xanh lá - tốt */
}

/* Màu cho value khi tỷ lệ trung bình (30-69%) */
.threads-stats-value.stat-rate.rate-medium {
    color: #ff9800; /* Vàng/cam - trung bình */
}

/* Màu cho value khi tỷ lệ thấp (< 30%) */
.threads-stats-value.stat-rate.rate-low {
    color: #dc3545; /* Đỏ - thấp */
}

.pagination-right {
    display: flex;
    align-items: center;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination-nav-bottom,
.pagination-nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--surface-muted-bg);
    box-sizing: border-box;
}

.pagination-nav-bottom {
    border-top: 1px solid var(--threads-table-border-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.pagination-nav-top {
    border-bottom: 1px solid var(--threads-table-border-color);
}

.page-display-info {
    font-size: 0.9rem;
    color: var(--control-text);
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    white-space: nowrap;
    vertical-align: middle;
    line-height: var(--form-control-height);
    height: var(--form-control-height);
    min-height: var(--form-control-height);
    box-sizing: border-box;
}

.pagination-nav-bottom .pagination-nav,
.pagination-nav-top .pagination-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.5;
    overflow: visible;
}

.pagination-info label {
    font-size: var(--form-label-font-size);
    color: var(--control-text);
    font-weight: 400;
}

.pagination-text {
    font-size: var(--form-label-font-size);
    color: var(--control-text);
    font-weight: 400;
}

/* Responsive */
@media (max-width: 768px) {
    .pagination-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .pagination-left {
        flex: 0 0 auto;
        width: 100%;
        justify-content: center;
    }
    
    .pagination-center {
        flex: 0 0 auto;
        width: 100%;
        justify-content: center;
    }
    
    .pagination-right {
        flex: 0 0 auto;
        width: 100%;
        justify-content: center;
    }
    
    .system-info-top {
        justify-content: center;
        flex-wrap: nowrap;
        gap: 1.5rem;
    }
    
    .threads-stats-top {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        align-items: center;
    }
    
    /* Khi pagination-info bị ẩn ở mobile, hiển thị 1 dòng và căn lề phải */
    .pagination-controls.pagination-info-hidden .pagination-center .threads-stats-top {
        flex-wrap: nowrap;
        justify-content: flex-end;
    }
    
    /* Dòng 1: Số luồng (order: 1) và Tỷ lệ (order: 2) */
    .threads-stats-top .threads-stats-item:first-child {
        order: 1;
    }
    
    .threads-stats-top .threads-stats-item:last-child {
        order: 2;
    }
    
    /* Tạo line break sau Tỷ lệ bằng cách đặt flex-basis: 100% cho phần tử ẩn */
    .threads-stats-top::after {
        content: '';
        flex-basis: 100%;
        width: 100%;
        order: 2;
        height: 0;
    }
    
    /* Dòng 2: Live (order: 3), Die (order: 4), Lỗi (order: 5) - cùng 1 dòng */
    .threads-stats-top .threads-stats-item:nth-child(2) {
        order: 3;
    }
    
    .threads-stats-top .threads-stats-item:nth-child(3) {
        order: 4;
    }
    
    .threads-stats-top .threads-stats-item:nth-child(4) {
        order: 5;
    }
    
    .pagination-info {
        width: auto;
        justify-content: flex-start !important;
    }
    
    .pagination-info label {
        font-size: var(--form-label-font-size);
    }
    
    .pagination-nav {
        width: auto;
        justify-content: flex-end;
        gap: 0.5rem;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }

    .config-row {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .config-group {
        flex: 1 1 auto;
        min-width: calc(50% - 0.5rem);
    }

    .config-input {
        width: 100%;
        min-width: 60px;
        max-width: 100%;
    }
    
    .results-summary-inline {
        grid-template-columns: repeat(4, 1fr);
        width: 100%;
        min-width: 0;
        margin-bottom: 1rem;
        height: 90px;
        min-height: 90px;
    }
    
    .results-summary-inline .summary-item {
        min-height: 90px;
        height: 90px;
        padding: 0.5rem 0.3rem;
    }
    
    .summary-label {
        font-size: clamp(0.6rem, 2vw, 0.7rem);
    }
    
    .summary-value {
        font-size: clamp(1rem, 2.5vw, 1.5rem);
    }
    
    .config-row-item {
        width: 100%;
        justify-content: space-between;
    }

    /* Responsive font-size cho config controls */
    .config-group label {
        font-size: var(--form-label-font-size);
    }
    
    .config-input {
        font-size: var(--form-control-font-size);
        padding-top: 0;
        padding-bottom: 0;
        height: var(--form-control-height);
        min-height: var(--form-control-height);
        border-radius: var(--form-control-radius);
    }
    
    .config-row-item .btn {
        font-size: var(--form-control-font-size);
        padding-top: 0;
        padding-bottom: 0;
        height: var(--form-control-height);
        min-height: var(--form-control-height);
        border-radius: var(--form-control-radius);
        min-width: 90px;
    }
    
    .config-row-item .btn-toggle-file-config {
        height: var(--form-control-height);
        min-height: var(--form-control-height);
        font-size: var(--form-control-font-size);
        padding-top: 0;
        padding-bottom: 0;
        border-radius: var(--form-control-radius);
        min-width: 90px;
    }
    
    .config-row-item .btn .btn-icon {
        width: 14px;
        height: 14px;
    }
    
    .config-row-item .btn-toggle-file-config .settings-icon {
        width: 12px;
        height: 12px;
    }

    .threads-table {
        font-size: 0.8rem;
    }

    .threads-table th,
    .threads-table td {
        padding: 0.5rem;
    }
    
    /* Responsive font-size cho pagination-controls - phù hợp với table (0.8rem) */
    .system-info-top,
    .threads-stats-top {
        font-size: 0.8rem;
    }
    
    .system-info-label,
    .threads-stats-label {
        font-size: 0.8rem;
    }
    
    .system-info-value,
    .threads-stats-value {
        font-size: 0.85rem;
    }
    
    .system-info-value {
        min-width: 22.5px;
    }
    
    .threads-stats-value {
        min-width: 25px;
    }
    
    /* Responsive font-size cho stats cell trong cột Tổng */
    .threads-table .stats-cell {
        font-size: clamp(0.65rem, 0.9vw + 0.35rem, 0.75rem);
    }
    
    /* Đảm bảo empty message căn giữa ở mobile */
    /* Khi có empty message, bỏ min-width của table để table có thể thu nhỏ */
    .threads-table-container:has(.table-empty) .threads-table,
    .threads-table:has(.table-empty) {
        min-width: 0 !important;
        width: 100% !important;
        table-layout: auto !important;
    }
    
    .table-empty {
        text-align: center !important;
        width: 100% !important;
        display: table-cell !important;
        font-size: 0.8rem !important;
    }
    
    .threads-table tbody tr:has(.table-empty) {
        display: table-row;
    }
    
    .threads-table tbody tr:has(.table-empty) td {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

@media (max-width: 480px) {
    .results-summary-inline {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        height: auto;
        min-height: 0;
        margin-bottom: 0;
    }

    .results-summary-inline .summary-item {
        height: 76px;
        min-height: 76px;
        padding: 0.45rem 0.5rem;
    }

    .summary-label {
        font-size: 0.68rem;
    }

    .summary-value {
        font-size: 1rem;
    }

    .basic-config .config-group-right {
        margin-top: 0;
    }
}

@media (max-width: 560px) {
    .basic-config .config-group-right .config-row-item .config-group .config-input,
    .basic-config .config-group-right .config-row-item .btn,
    .basic-config .config-group-right .config-row-item .btn-toggle-file-config {
        height: var(--form-control-height) !important;
        min-height: var(--form-control-height) !important;
        max-height: var(--form-control-height) !important;
    }

    .basic-config .config-group-right .config-row-item .config-group .config-input {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
        line-height: 1.2;
    }

    .basic-config .config-group-right .config-row-item .btn,
    .basic-config .config-group-right .config-row-item .btn-toggle-file-config {
        align-items: center;
        justify-content: center;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

}

/* Hidden class for filtering options */
.hidden {
    display: none !important;
}

/* Orange button for "Đang dừng..." state */
.btn-orange {
    background-color: transparent !important;
    border-color: var(--button-warning) !important;
    color: var(--button-warning) !important;
}

.btn-orange:hover,
.btn-orange:focus-visible {
    background-color: var(--button-warning) !important;
    border-color: var(--button-warning) !important;
    color: #ffffff !important;
    transform: none !important;
    box-shadow: none !important;
}

.btn-orange:disabled {
    opacity: 1;
    cursor: wait;
}

/* ==================== Dark Mode ==================== */
body.dark-mode .results-summary {
    background: var(--surface-bg);
    box-shadow: var(--surface-shadow-soft);
}

body.dark-mode .summary-label {
    color: #b0b0b0;
}

body.dark-mode .summary-value {
    color: var(--primary);
}

body.dark-mode .summary-value.success {
    color: #28a745 !important;
}

body.dark-mode .summary-value.failed {
    color: #dc3545 !important;
}

html.dark-mode .summary-value.success,
body.dark-mode .summary-value.success {
    color: #28a745 !important;
}

html.dark-mode .summary-value.rate-medium,
body.dark-mode .summary-value.rate-medium {
    color: #ffc107 !important;
}

html.dark-mode .summary-value.failed,
body.dark-mode .summary-value.failed {
    color: #dc3545 !important;
}

/* Giữ nguyên màu status trong dark mode */
body.dark-mode .status-live .status-cell,
body.dark-mode .status-success .status-cell {
    color: #2e7d32 !important;
}

body.dark-mode .status-die .status-cell {
    color: #c62828 !important;
}

body.dark-mode .status-stopped .status-cell {
    color: #dc3545 !important;
}

body.dark-mode .status-stopping .status-cell {
    color: #ff9800 !important;
}

body.dark-mode .status-proxy-die .status-cell {
    color: #dc3545 !important;
}

body.dark-mode .status-error .status-cell {
    color: #dc3545 !important;
}

body.dark-mode .status-blocked .status-cell {
    color: #dc3545 !important;
}

body.dark-mode .status-success-text {
    color: #2e7d32 !important;
}

body.dark-mode .status-error-text {
    color: #dc3545 !important;
}

/* Giữ nguyên màu stats trong dark mode */
body.dark-mode .threads-table .stat-live {
    color: #28a745 !important;
}

body.dark-mode .threads-table .stat-die {
    color: #dc3545 !important;
}

body.dark-mode .threads-table .stat-error {
    color: #ffc107 !important;
}

body.dark-mode .control-card {
    background: var(--surface-bg);
    box-shadow: var(--surface-shadow-soft);
}


body.dark-mode .config-label,
body.dark-mode .file-config-label {
    color: #e0e0e0;
}

body.dark-mode .threads-table-container::-webkit-scrollbar {
    height: 8px;
}

body.dark-mode .threads-table-container::-webkit-scrollbar-track {
    background: var(--dropdown-scrollbar-track);
}

body.dark-mode .threads-table-container::-webkit-scrollbar-thumb {
    background: var(--dropdown-scrollbar-thumb);
    border-radius: 4px;
}

body.dark-mode .threads-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--dropdown-scrollbar-thumb-hover);
}

body.dark-mode .threads-table th:nth-child(1) {
    background: var(--table-header-bg) !important;
    border-right: none;
    box-shadow: none;
}

body.dark-mode .threads-table th:nth-child(5) {
    border-right: none;
}

body.dark-mode .threads-table th:nth-child(6) {
    background: var(--table-header-bg) !important;
    border-left: none;
    box-shadow: none;
}

body.dark-mode .threads-table th .resizer {
    border-right: 1px solid var(--threads-table-border-color);
}

body.dark-mode .threads-table th .resizer:hover {
    background: rgba(var(--primary-rgb), 0.3);
}

body.dark-mode .table-empty {
    color: #b0b0b0;
}

body.dark-mode .pagination-controls {
    background: var(--surface-bg);
    border-bottom: 1px solid var(--threads-table-border-color);
}

body.dark-mode .pagination-nav-bottom {
    background: var(--surface-bg);
    border-top: 1px solid var(--threads-table-border-color);
}

/* Giữ nguyên màu như light mode cho các thông số - dùng !important để override */
body.dark-mode .pagination-controls .system-info-item,
body.dark-mode .system-info-top .system-info-item,
body.dark-mode .system-info-item {
    color: #495057 !important;
}

body.dark-mode .pagination-controls .system-info-label,
body.dark-mode .system-info-top .system-info-label,
body.dark-mode .system-info-label {
    color: #6c757d !important;
}

body.dark-mode .pagination-controls .system-info-value,
body.dark-mode .system-info-top .system-info-value,
body.dark-mode .system-info-value {
    color: #212529 !important;
}

body.dark-mode .pagination-controls .system-info-item.stat-cpu-item .system-info-label,
body.dark-mode .pagination-controls .system-info-item.stat-cpu-item .system-info-value,
body.dark-mode .system-info-top .system-info-item.stat-cpu-item .system-info-label,
body.dark-mode .system-info-top .system-info-item.stat-cpu-item .system-info-value,
body.dark-mode .system-info-item.stat-cpu-item .system-info-label,
body.dark-mode .system-info-item.stat-cpu-item .system-info-value {
    color: #0d6efd !important;
}

body.dark-mode .pagination-controls .system-info-item.stat-ram-item .system-info-label,
body.dark-mode .pagination-controls .system-info-item.stat-ram-item .system-info-value,
body.dark-mode .system-info-top .system-info-item.stat-ram-item .system-info-label,
body.dark-mode .system-info-top .system-info-item.stat-ram-item .system-info-value,
body.dark-mode .system-info-item.stat-ram-item .system-info-label,
body.dark-mode .system-info-item.stat-ram-item .system-info-value {
    color: #6f42c1 !important;
}

body.dark-mode .pagination-controls .threads-stats-item,
body.dark-mode .threads-stats-top .threads-stats-item,
body.dark-mode .threads-stats-item {
    color: #495057 !important;
}

body.dark-mode .pagination-controls .threads-stats-label,
body.dark-mode .threads-stats-top .threads-stats-label,
body.dark-mode .threads-stats-label {
    color: #6c757d !important;
}

body.dark-mode .pagination-controls .threads-stats-value,
body.dark-mode .threads-stats-top .threads-stats-value,
body.dark-mode .threads-stats-value {
    color: #495057 !important;
}

body.dark-mode .pagination-controls .threads-stats-item:first-child .threads-stats-label,
body.dark-mode .pagination-controls .threads-stats-item:first-child .threads-stats-value,
body.dark-mode .threads-stats-top .threads-stats-item:first-child .threads-stats-label,
body.dark-mode .threads-stats-top .threads-stats-item:first-child .threads-stats-value,
body.dark-mode .threads-stats-item:first-child .threads-stats-label,
body.dark-mode .threads-stats-item:first-child .threads-stats-value {
    color: #0d6efd !important;
}

body.dark-mode .pagination-controls .threads-stats-item .threads-stats-label.stat-live-label,
body.dark-mode .pagination-controls .threads-stats-value.stat-live,
body.dark-mode .threads-stats-top .threads-stats-item .threads-stats-label.stat-live-label,
body.dark-mode .threads-stats-top .threads-stats-value.stat-live,
body.dark-mode .threads-stats-item .threads-stats-label.stat-live-label,
body.dark-mode .threads-stats-value.stat-live {
    color: #28a745 !important;
}

body.dark-mode .pagination-controls .threads-stats-item .threads-stats-label.stat-die-label,
body.dark-mode .pagination-controls .threads-stats-value.stat-die,
body.dark-mode .threads-stats-top .threads-stats-item .threads-stats-label.stat-die-label,
body.dark-mode .threads-stats-top .threads-stats-value.stat-die,
body.dark-mode .threads-stats-item .threads-stats-label.stat-die-label,
body.dark-mode .threads-stats-value.stat-die {
    color: #c62828 !important;
}

body.dark-mode .pagination-controls .threads-stats-item .threads-stats-label.stat-error-label,
body.dark-mode .pagination-controls .threads-stats-value.stat-error,
body.dark-mode .threads-stats-top .threads-stats-item .threads-stats-label.stat-error-label,
body.dark-mode .threads-stats-top .threads-stats-value.stat-error,
body.dark-mode .threads-stats-item .threads-stats-label.stat-error-label,
body.dark-mode .threads-stats-value.stat-error {
    color: #ff9800 !important;
}

body.dark-mode .pagination-controls .threads-stats-item .threads-stats-label.stat-rate-label,
body.dark-mode .threads-stats-top .threads-stats-item .threads-stats-label.stat-rate-label,
body.dark-mode .threads-stats-item .threads-stats-label.stat-rate-label {
    color: #28a745 !important;
}

body.dark-mode .pagination-controls .threads-stats-value.stat-rate,
body.dark-mode .threads-stats-top .threads-stats-value.stat-rate,
body.dark-mode .threads-stats-value.stat-rate {
    color: var(--primary) !important;
}

html.dark-mode .threads-stats-value.stat-rate.rate-high,
body.dark-mode .threads-stats-value.stat-rate.rate-high {
    color: #28a745 !important;
}

html.dark-mode .threads-stats-value.stat-rate.rate-medium,
body.dark-mode .threads-stats-value.stat-rate.rate-medium {
    color: #ff9800 !important;
}

html.dark-mode .threads-stats-value.stat-rate.rate-low,
body.dark-mode .threads-stats-value.stat-rate.rate-low {
    color: #dc3545 !important;
}

html.dark-mode .index .config-group label,
html.dark-mode .index .file-config-group label,
body.dark-mode .config-group label,
body.dark-mode .file-config-group label {
    color: #e0e0e0;
}

body.dark-mode .threads-table th {
    color: #e0e0e0;
}

body.dark-mode .threads-table td {
    color: #e0e0e0;
}

body.dark-mode .threads-table tbody tr {
    background-color: var(--table-row-bg);
}

body.dark-mode .threads-table td:nth-child(1) {
    background: var(--table-row-bg);
    border-right: none;
    box-shadow: none;
}

body.dark-mode .threads-table td:nth-child(5) {
    border-right: none;
}

body.dark-mode .threads-table td:nth-child(6) {
    background: var(--table-row-bg);
    border-left: none;
    box-shadow: none;
}

body.dark-mode .custom-select-search {
    background: var(--dropdown-search-bg);
    border-bottom: 1px solid var(--dropdown-search-border);
}


body.dark-mode .custom-select-option {
    color: var(--dropdown-option-text);
}




html.dark-mode .config-native-select-menu,
body.dark-mode .config-native-select-menu {
    background: var(--dropdown-bg);
    border-color: var(--dropdown-border);
    box-shadow: var(--dropdown-shadow);
}

body.dark-mode .config-native-select-option {
    color: var(--dropdown-option-text);
}

body.dark-mode .config-input:-webkit-autofill,
body.dark-mode .config-input:-webkit-autofill:hover,
body.dark-mode .config-input:-webkit-autofill:focus,
body.dark-mode .config-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--control-bg) inset !important;
    -webkit-text-fill-color: var(--control-text) !important;
    background-color: var(--control-bg) !important;
    color: var(--control-text) !important;
}

body.dark-mode .config-input::placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .config-input::-webkit-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .config-input::-moz-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .config-input:-ms-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}


body.dark-mode .file-config-input:-webkit-autofill,
body.dark-mode .file-config-input:-webkit-autofill:hover,
body.dark-mode .file-config-input:-webkit-autofill:focus,
body.dark-mode .file-config-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--control-bg) inset !important;
    -webkit-text-fill-color: var(--control-text) !important;
    background-color: var(--control-bg) !important;
    color: var(--control-text) !important;
}

body.dark-mode .file-config-input::placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-config-input::-webkit-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-config-input::-moz-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-config-input:-ms-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}



body.dark-mode .file-content-textarea:-webkit-autofill,
body.dark-mode .file-content-textarea:-webkit-autofill:hover,
body.dark-mode .file-content-textarea:-webkit-autofill:focus,
body.dark-mode .file-content-textarea:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--control-bg) inset !important;
    -webkit-text-fill-color: var(--control-text) !important;
    background-color: var(--control-bg) !important;
    color: var(--control-text) !important;
}

body.dark-mode .file-content-textarea::placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-content-textarea::-webkit-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-content-textarea::-moz-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}

body.dark-mode .file-content-textarea:-ms-input-placeholder {
    color: var(--control-placeholder) !important;
    opacity: 1;
}


body.dark-mode .file-content-textarea::-webkit-scrollbar {
    width: 8px;
}

body.dark-mode .file-content-textarea::-webkit-scrollbar-track {
    background: var(--dropdown-scrollbar-track);
}

body.dark-mode .file-content-textarea::-webkit-scrollbar-thumb {
    background: var(--dropdown-scrollbar-thumb);
    border-radius: 4px;
}

body.dark-mode .file-content-textarea::-webkit-scrollbar-thumb:hover {
    background: var(--dropdown-scrollbar-thumb-hover);
}

body.dark-mode .config-row-item .btn-toggle-file-config .settings-icon {
    filter: none;
}


body.dark-mode .eye-icon {
    stroke: currentColor;
    color: inherit;
}

/* Shared 38px height for visible form controls on the index page. */
.config-input,
.file-config-input,
.custom-select-trigger,
.config-row-item .btn,
.config-row-item .btn-toggle-file-config,
.custom-select-search input {
    height: var(--form-control-height);
    min-height: var(--form-control-height);
    padding-top: 0;
    padding-bottom: 0;
    border-radius: var(--form-control-radius);
    box-sizing: border-box;
}.file-content-textarea{
    height: var(--form-control-height);
    min-height: var(--form-control-height);
    padding: 0.45rem 0.75rem;
    line-height: 1.25;
    border-radius: var(--form-control-radius);
    box-sizing: border-box;
}

.file-upload-container .file-content-textarea {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-right-width: 0 !important;
}

.file-upload-container .btn-upload-inline {
    appearance: none !important;
    -webkit-appearance: none !important;
    margin-left: 0 !important;
    border-left: 0 !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;}

.custom-select-trigger,
.file-config-input {
    border-radius: var(--form-control-radius);
}

/* Final lock: keep shared module-header and thread-table controls identical across resize/zoom. */
.index .control-size,
.index .control-size-wrapper {
    height: var(--form-control-height) !important;
    min-height: var(--form-control-height) !important;
    max-height: var(--form-control-height) !important;
    border-radius: var(--form-control-radius) !important;
    box-sizing: border-box !important;
}

.index .basic-config .config-input.control-size {
    font-size: var(--form-control-font-size) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: var(--form-control-height) !important;
}

.index .basic-config .module-start-stop,
.index .basic-config .btn-toggle-file-config {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.45rem !important;
    font-size: var(--form-control-font-size) !important;
    width: var(--header-action-width) !important;
    min-width: var(--header-action-width) !important;
    max-width: var(--header-action-width) !important;
    flex: 0 0 var(--header-action-width) !important;
    padding: 0 0.75rem !important;
    text-align: center !important;
    vertical-align: middle !important;
}

.index .basic-config .module-start-stop {
    line-height: 1 !important;
    white-space: nowrap !important;
}

.index .basic-config .btn-toggle-file-config {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

.index .basic-config .module-start-stop,
.index .basic-config .btn-toggle-file-config,
.index .basic-config .module-start-stop span,
.index .basic-config .btn-toggle-file-config span {
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

.index .basic-config .module-start-stop span,
.index .basic-config .btn-toggle-file-config span {
    display: inline-flex !important;
    height: 1em !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
    text-align: center !important;
}

/* Primary/header buttons use inline SVG so icons render with the label immediately. */
.index .basic-config .module-start-stop .btn-icon,
.index .basic-config .btn-toggle-file-config .settings-icon {
    display: inline-block !important;
    flex: 0 0 auto !important;
    color: currentColor !important;
    fill: currentColor;
    stroke: currentColor;
    filter: none !important;
    transform-box: fill-box;
    transform-origin: center;
}

.index .basic-config .module-start-stop .btn-icon {
    width: clamp(14px, 1.2vw + 0.5rem, 18px);
    height: clamp(14px, 1.2vw + 0.5rem, 18px);
}

.index .basic-config .module-start-stop .btn-icon.btn-icon-loading,
.index .basic-config .module-start-stop .btn-icon.btn-icon-loading * {
    fill: none !important;
    stroke: currentColor !important;
}

.index .basic-config .btn-toggle-file-config .settings-icon {
    width: clamp(13px, 1.2vw + 0.45rem, 17px);
    height: clamp(13px, 1.2vw + 0.45rem, 17px);
    fill: none;
}

.index .basic-config .module-start-stop::before,
.index .basic-config .btn-toggle-file-config::before {
    content: none !important;
    display: none !important;
}

.index .basic-config .btn-toggle-file-config:not(.collapsed) .settings-icon {
    transform: rotate(90deg);
}


/* Thread table row paint uses one shared variable path for base, hover and sticky cells. */
.threads-table.threads-table tbody tr {
    --threads-row-bg: var(--table-row-bg);
    background: var(--table-row-bg) !important;
    background-color: var(--table-row-bg) !important;
    box-shadow: none !important;
}

.threads-table.threads-table tbody tr:hover {
    --threads-row-bg: var(--table-row-hover-bg);
    background: var(--threads-row-bg) !important;
    background-color: var(--threads-row-bg) !important;
    box-shadow: none !important;
}

.threads-table.threads-table tbody tr > td:not(.table-empty),
.threads-table.threads-table tbody tr:hover > td:not(.table-empty),
.threads-table.threads-table tbody tr[class*="status-"]:hover > td:not(.table-empty),
.threads-table.threads-table tbody tr > td:nth-child(1),
.threads-table.threads-table tbody tr > td:nth-child(6),
.threads-table.threads-table tbody tr:hover > td:nth-child(1),
.threads-table.threads-table tbody tr:hover > td:nth-child(6) {
    background-color: var(--table-row-bg) !important;
    background-image: linear-gradient(var(--threads-row-bg, var(--table-row-bg)), var(--threads-row-bg, var(--table-row-bg))) !important;
    background-clip: padding-box !important;
    box-shadow: none !important;
}

body.dark-mode .threads-table.threads-table tbody tr {
    --threads-row-bg: var(--table-row-bg);
}

body.dark-mode .threads-table.threads-table tbody tr:hover,
body.dark-mode .threads-table.threads-table tbody tr[class*="status-"]:hover {
    --threads-row-bg: var(--table-row-hover-bg);
}

.threads-table.threads-table tbody tr > td:nth-child(1):not(.table-empty),
.threads-table.threads-table tbody tr > td:nth-child(6):not(.table-empty),
.threads-table.threads-table tbody tr:hover > td:nth-child(1):not(.table-empty),
.threads-table.threads-table tbody tr:hover > td:nth-child(6):not(.table-empty),
.threads-table.threads-table tbody tr[class*="status-"]:hover > td:nth-child(1):not(.table-empty),
.threads-table.threads-table tbody tr[class*="status-"]:hover > td:nth-child(6):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr > td:nth-child(1):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr > td:nth-child(6):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr:hover > td:nth-child(1):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr:hover > td:nth-child(6):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr[class*="status-"]:hover > td:nth-child(1):not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr[class*="status-"]:hover > td:nth-child(6):not(.table-empty) {
    background-color: var(--table-row-bg) !important;
    background-image: linear-gradient(var(--threads-row-bg, var(--table-row-bg)), var(--threads-row-bg, var(--table-row-bg))) !important;
    background-clip: border-box !important;
}

/* Final border lock: thread table follows the shared results-table border thickness. */
.threads-table.threads-table th,
.threads-table.threads-table td:not(.table-empty),
body.dark-mode .threads-table.threads-table th,
body.dark-mode .threads-table.threads-table td:not(.table-empty) {
    border-bottom-width: var(--shared-table-border-width) !important;
    border-bottom-style: solid !important;
    border-bottom-color: var(--shared-table-border-color) !important;
    border-right-width: var(--shared-table-border-width) !important;
}

.threads-table.threads-table tbody tr:last-child > td:not(.table-empty),
body.dark-mode .threads-table.threads-table tbody tr:last-child > td:not(.table-empty) {
    border-bottom: var(--shared-table-border-width) solid var(--shared-table-border-color) !important;
}

body.dark-mode .index .pagination-info label {
    color: var(--control-text) !important;
}

.index :is(
    .custom-select-option,
    .config-native-select-option
) {
    border-radius: var(--dropdown-option-edge-radius) !important;
}

.index :is(
    .config-input,
    .file-config-input,
    .config-native-select-trigger,
    .config-native-select-option,
    .custom-select-trigger,
    .custom-select-option,
    .items-per-page-custom-trigger,
    .items-per-page-custom-option,
    .page-info,
    .page-selector-item
) {
    font-family: inherit !important;
    font-size: var(--form-control-font-size) !important;
    font-weight: var(--form-control-font-weight, 400) !important;
}


/* Register control-card corner cleanup: no shadow slab; card body inherits the canonical radius. */
.index .control-card {
    box-shadow: none !important;
}

.index .control-card .card-body {
    border-radius: inherit !important;
}
