body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    min-width: 1400px;
    max-width: 100%;
    overflow-x: hidden;
}

.container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    align-items: flex-start;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

/* Card cho phần đặt lệnh mới */
.card:first-child {
    flex: 0 0 30%;
    height: fit-content;
    position: sticky;
    top: 20px;
}

/* Cột bên phải chứa lịch sử và funding */
.right-column {
    flex: 0 0 69%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Card cho phần lịch sử lệnh */
.right-column .card {
    margin-bottom: 0;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    padding-right: 50px;
    white-space: nowrap;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #666;
}

select,
input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.radio-group {
    margin: 10px 0;
}

.radio-group label {
    display: inline;
    margin-right: 20px;
}

button {
    background: #1a73e8;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
}

button:hover {
    background: #1557b0;
}

table {
    margin: 0;
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th,
td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

th {
    background-color: #f8f9fa;
    font-weight: 500;
    color: #666;
    position: sticky;
    top: 0;
    z-index: 1;
}

.current-time {
    color: #666;
    margin-top: 20px;
    font-size: 0.9em;
}

.account-info {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0 auto 20px;
    display: flex;
    justify-content: space-between;
    max-width: 100%;
    width: 98%;
    gap: 20px;
}

.account-info-item {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border-right: 1px solid #eee;
}

.account-info-item:last-child {
    border-right: none;
}

.account-info-label {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
    white-space: nowrap;
}

.account-info-value {
    font-size: 1.2em;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.positive {
    color: #4caf50;
}

.negative {
    color: #f44336;
}

select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
}

select:hover {
    border-color: #1a73e8;
}

select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.form-group {
    margin-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-col {
    flex: 1;
}

/* Style cho badge trạng thái */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: help;
    display: inline-block;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending {
    background-color: #fff3cd;
    color: #856404;
}

.filled {
    background-color: #d4edda;
    color: #155724;
}

/* Style cho vị thế trong bảng lịch sử */
.position-long {
    color: #4caf50;
    font-weight: 500;
}

.position-short {
    color: #f44336;
    font-weight: 500;
}

.cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Style cho nút hủy */
.cancel-btn {
    padding: 4px 8px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.cancel-btn:hover {
    background-color: #c82333;
}

.clear-all-btn {
    padding: 8px 16px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.clear-all-btn:hover {
    background-color: #c82333;
}

input[readonly] {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
    cursor: default;
}

input[readonly]:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

input[type="number"] {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
}

/* Ẩn mũi tên tăng giảm của input number */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* Style cho placeholder */
input[type="number"]::placeholder {
    color: #999;
}

/* Style cho input số lượng readonly */
input#quantity {
    background-color: #f8f9fa;
    color: #495057;
    border: 1px solid #ced4da;
    cursor: not-allowed;
    font-weight: 500;
}

/* Loại bỏ outline khi focus vào input readonly */
input#quantity:focus {
    outline: none;
    box-shadow: none;
    border-color: #ced4da;
}

/* Thứ tự các trường form */
.form-group {
    display: flex;
    flex-direction: column;
}

/* Thứ tự cụ thể cho các trường */
.form-group[data-order="1"] {
    order: 1;
}

.form-group[data-order="2"] {
    order: 2;
}

.form-group[data-order="3"] {
    order: 3;
}

.form-group[data-order="4"] {
    order: 4;
}

.form-group[data-order="5"] {
    order: 5;
}

/* Style cho hàng chứa các options */
.options-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

.options-row>div {
    flex: 1;
    min-width: 0;
}

/* Style cho label trong options */
.options-row label {
    margin-bottom: 8px;
    display: block;
    color: #666;
}

/* Style cho select trong options */
.options-row select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

/* Style cho select vị thế */
select[name="position"] option[value="LONG"] {
    color: #4caf50;
    font-weight: 500;
}

select[name="position"] option[value="SHORT"] {
    color: #f44336;
    font-weight: 500;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px;
    border-radius: 4px;
    z-index: 1000;
    color: white;
    font-weight: bold;
}

.notification.success {
    background: #4CAF50;
}

.notification.error {
    background: #f44336;
}

/* Style cho cột vị thế trong bảng */
td.position-long,
td.position-short {
    font-weight: 500;
}

td.position-long {
    color: #4caf50;
}

td.position-short {
    color: #f44336;
}

/* Style cho text chờ khớp */
td span[style="color: #666;"] {
    font-style: italic;
    font-size: 0.9em;
}

input[type="date"] {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
    background-color: white;
}

input[type="date"]:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* Style cho cột thời gian */
td:nth-child(8) {
    white-space: nowrap;
}

/* Style cho bảng funding */
.funding-table-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 97%;
    height: fit-content;
}

.funding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.funding-header h2 {
    margin: 0;
    color: #333;
}

.view-all-btn {
    padding: 8px 16px;
    background: #1a73e8;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
}

.funding-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.funding-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: center;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.funding-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Điều chỉnh độ rộng các cột */
.funding-table th:nth-child(1),
.funding-table td:nth-child(1) {
    width: 15%;
    text-align: left;
}

.funding-table th:nth-child(2),
.funding-table td:nth-child(2) {
    width: 20%;
}

.funding-table th:nth-child(3),
.funding-table td:nth-child(3) {
    width: 30%;
}

.funding-table th:nth-child(4),
.funding-table td:nth-child(4) {
    width: 0%;
    display: none;
}

.funding-table th:nth-child(5),
.funding-table td:nth-child(5) {
    width: 35%;
    text-align: center;
}

.funding-table .symbol {
    font-weight: 500;
}

.funding-table .funding-rate.negative {
    color: #f44336;
    font-weight: 500;
}

.funding-table .countdown {
    color: #666;
    text-align: center;
}


.funding-table .no-data {
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Điều chỉnh độ rộng và căn chỉnh các cột trong bảng lịch sử */
#orderHistoryBody td:nth-child(1),
.right-column table th:nth-child(1) {
    width: 7%;
    text-align: left;
}

/* TÀI SẢN */

#orderHistoryBody td:nth-child(2),
.right-column table th:nth-child(2) {
    width: 5%;
    text-align: center;
}

/* LOẠI */

#orderHistoryBody td:nth-child(3),
.right-column table th:nth-child(3) {
    width: 6%;
    text-align: center;
}

/* CHẾ ĐỘ */

#orderHistoryBody td:nth-child(4),
.right-column table th:nth-child(4) {
    width: 5%;
    text-align: center;
}

/* VỊ THẾ */

#orderHistoryBody td:nth-child(5),
.right-column table th:nth-child(5) {
    width: 6%;
    text-align: center;
}

/* ĐÒN BẨY */

#orderHistoryBody td:nth-child(6),
.right-column table th:nth-child(6) {
    width: 10%;
    text-align: center;
}

/* SỐ LƯỢNG */

#orderHistoryBody td:nth-child(7),
.right-column table th:nth-child(7) {
    width: 10%;
    text-align: center;
}

/* GIÁ */

#orderHistoryBody td:nth-child(8),
.right-column table th:nth-child(8) {
    width: 7%;
    text-align: center;
}

/* BIÊN ĐỘ */

#orderHistoryBody td:nth-child(9),
.right-column table th:nth-child(9) {
    width: 6%;
    text-align: center;
}

/* SỐ TIỀN */

#orderHistoryBody td:nth-child(10),
.right-column table th:nth-child(10) {
    width: 15%;
    text-align: center;
}

/* THỜI GIAN */

#orderHistoryBody td:nth-child(11),
.right-column table th:nth-child(11) {
    width: 12%;
    text-align: center;
}

/* TRẠNG THÁI */

#orderHistoryBody td:nth-child(12),
.right-column table th:nth-child(12) {
    width: 10%;
    text-align: center;
}

/* HÀNH ĐỘNG */

/* Style đặc biệt cho cột thời gian */
#orderHistoryBody td:nth-child(8),
.right-column table th:nth-child(8) {
    font-size: 14px;
    text-align: center;
    padding: 10px 5px;
}

/* Điều chỉnh font-size cho các cột khác */
#orderHistoryBody td {
    font-size: 14px;
    padding: 10px 5px;
}

/* Giữ nguyên font-size cho cột số lượng và giá */
#orderHistoryBody td:nth-child(6),
#orderHistoryBody td:nth-child(7) {
    font-size: 14px;
}

/* Đảm bảo các cột trong bảng không bị tràn */
.right-column table th,
.right-column table td {
    padding: 10px;
    font-size: 14px;
}

/* Căn chỉnh nội dung các cột */
#orderHistoryBody td {
    text-align: inherit;
    /* Kế thừa từ header */
}

/* Style cho status-badge */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
    display: inline-block;
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
}

/* ===== MOBILE RESPONSIVE CSS ===== */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        min-width: 100%;
        overflow-x: auto;
    }

    /* Account info - 5 columns on mobile */
    .account-info {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        padding: 10px;
        width: 100%;
    }

    .account-info-item {
        border-right: none;
        border-bottom: none;
        padding: 4px;
        text-align: center;
    }

    .account-info-item:last-child {
        border-bottom: none;
    }

    .account-info-label {
        font-size: 0.65em;
        margin-bottom: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .account-info-value {
        font-size: 0.8em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Container - Stack vertically */
    .container {
        flex-direction: column;
        gap: 15px;
    }

    /* Card cho phần đặt lệnh */
    .card:first-child {
        flex: 1;
        position: static;
        width: 100%;
    }

    /* Right column */
    .right-column {
        flex: 1;
        width: 100%;
    }

    /* Form adjustments */
    h2 {
        font-size: 1.3em;
        padding-right: 0;
        white-space: normal;
    }

    .form-group {
        margin-bottom: 15px;
    }

    label {
        font-size: 0.9em;
    }

    select,
    input {
        padding: 10px;
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Options row - Stack on mobile */
    .options-row {
        flex-direction: column;
        gap: 10px;
    }

    .options-row>div {
        width: 100%;
    }

    /* Button */
    button {
        padding: 14px;
        font-size: 16px;
    }

    /* Tables - Horizontal scroll */
    .card {
        overflow-x: auto;
    }

    table {
        min-width: 800px;
        font-size: 12px;
    }

    th,
    td {
        padding: 8px 4px;
        font-size: 12px;
    }

    /* Funding table */
    .funding-table-container {
        width: 100%;
        padding: 10px;
        overflow-x: auto;
    }

    .funding-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 10px;
    }

    .funding-header h2 {
        font-size: 1.1em;
        margin: 0;
    }

    .view-all-btn {
        padding: 6px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    .funding-table {
        min-width: 100%;
        font-size: 11px;
    }

    .funding-table th,
    .funding-table td {
        padding: 6px 3px;
        font-size: 11px;
    }

    /* Tối ưu độ rộng cột cho mobile */
    .funding-table th:nth-child(1),
    .funding-table td:nth-child(1) {
        width: 1% !important;
    }

    .funding-table th:nth-child(2),
    .funding-table td:nth-child(2) {
        width: 1% !important;
    }

    .funding-table th:nth-child(3),
    .funding-table td:nth-child(3) {
        width: 1% !important;
    }

    .funding-table th:nth-child(5),
    .funding-table td:nth-child(5) {
        width: 3% !important;
    }

    /* Daily profits grid */
    .daily-profits-container {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
        padding: 10px;
    }

    .profit-box {
        padding: 8px;
    }

    .profit-box .day-number {
        font-size: 14px;
    }

    .profit-box .profit-amount {
        font-size: 10px;
    }

    /* Notification */
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        padding: 12px;
        font-size: 14px;
    }

    /* Status badge */
    .status-badge {
        font-size: 11px;
        padding: 3px 6px;
    }

    /* Cancel button */
    .cancel-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .clear-all-btn {
        padding: 10px;
        font-size: 14px;
        width: 100%;
    }

    /* Time input fields */
    .d-flex {
        flex-wrap: wrap;
        gap: 5px;
    }

    input[type="date"] {
        width: 100%;
        margin-bottom: 5px;
    }

    /* Adjust column widths for mobile table */
    #orderHistoryBody td:nth-child(1),
    .right-column table th:nth-child(1) {
        min-width: 80px;
    }

    #orderHistoryBody td,
    .right-column table td {
        font-size: 11px;
        padding: 6px 3px;
    }

    .right-column table th {
        font-size: 11px;
        padding: 8px 3px;
    }
}

/* Extra small devices (phones in portrait, less than 576px) */
@media screen and (max-width: 576px) {
    body {
        padding: 5px;
    }

    .card {
        padding: 12px;
        border-radius: 6px;
    }

    h2 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }

    .account-info {
        padding: 10px;
    }

    .account-info-value {
        font-size: 1em;
    }

    table {
        min-width: 700px;
        font-size: 11px;
    }

    th,
    td {
        padding: 6px 2px;
        font-size: 11px;
    }

    .funding-table {
        font-size: 11px;
    }

    .daily-profits-container {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }

    .profit-box .day-number {
        font-size: 12px;
    }

    .profit-box .profit-amount {
        font-size: 9px;
    }

    button {
        padding: 12px;
        font-size: 15px;
    }

    .notification {
        font-size: 13px;
        padding: 10px;
    }
}

/* Landscape orientation optimization */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .account-info {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .account-info-item {
        flex: 0 0 48%;
        border-right: 1px solid #eee;
        border-bottom: none;
    }

    .account-info-item:nth-child(2n) {
        border-right: none;
    }

    .container {
        flex-direction: row;
        gap: 10px;
    }

    .card:first-child {
        flex: 0 0 35%;
    }

    .right-column {
        flex: 0 0 63%;
    }
}