/* ===== TOP TABS ===== */
  .top-tabs {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
  }
  .tab-btn {
    padding: 7px 22px;
    border-radius: 6px;
    border: none;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }
  .tab-btn.active {
    background: #1976d2;
    color: #fff;
  }
  .tab-btn.inactive {
    background: transparent;
    color: #555;
  }
  .tab-btn.inactive:hover { background: #f5f5f5; }

  /* ===== MAIN LAYOUT ===== */
  .main-layout {
    display: flex;
    width: 100%;
    align-items: flex-start; 
  }

  /* ===== LEFT PANEL ===== */
  .left-panel {
    width: 50%;
    padding: 15px 10px;
    border-right: 1px solid #f0f0f0;
    min-width: 0;
  }

  /* Symbol row */
  .symbol-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0px;
  }
  .symbol-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .symbol-icon {
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #555;
    line-height: 1;
  }
  .symbol-name {
    font-size: 16px;
    font-weight: 700;
    color: #111;
  }
  .chart-icon { color: #888; cursor: pointer; }

  /* Form labels */
  .form-label {
    font-size: 12.5px;
    color: #888;
    margin-bottom: 6px;
    display: block;
  }

  /* Select */
  .form-group { margin-bottom: 5px; }
  .custom-select {
    width: 100%;
    padding: 5px 5px;
    background: #f5f6f8;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    font-size: 13.5px;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23999' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
  }
  .custom-select:focus { border-color: #1976d2; background-color: #fafafa; }

  /* ===== AMOUNT INPUT — FIX MOBILE ===== */
  .amount-wrapper {
      display: flex;
      align-items: stretch;
      background: #f5f6f8;
      border: 1px solid #e8e8e8;
      border-radius: 6px;
      overflow: hidden;
      min-width: 0;
      margin-top: 5px;
  }
 .amount-input {
    flex: 1;
    min-width: 0; /* FIX KEY: không cho input đẩy unit ra ngoài */
    padding: 3px 3px;
    border: none;
    background: transparent;
    font-size: 13.5px;
    color: #333;
    outline: none;
    width: 100%;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.amount-unit {
    flex-shrink: 0; /* FIX KEY: không cho unit bị co mất */
    padding: 10px 8px;
    font-size: 12px;
    color: #aaa;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    border-left: 1px solid #e8e8e8;
    white-space: nowrap;
    user-select: none;
}
.amount-unit::after { content: '▾'; font-size: 11px; color: #ccc; }

  /* Info rows */
  .info-rows { margin: 0px 0 0px; }
  .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 13px;
  }
  .info-row .lbl { color: #999; }
  .info-row .val { color: #333; font-weight: 500; }
  .info-row .val-balance { color: #1976d2; font-weight: 700; }

  /* Trade buttons */
  .btn-buy {
    width: 100%;
    padding: 14px;
    background: #2ecc71;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.2s;
    letter-spacing: 0.2px;
  }
  .btn-buy:hover { background: #27ae60; }

  .btn-sell {
    width: 100%;
    padding: 14px;
    background: #e74c3c;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 0.2px;
  }
  .btn-sell:hover { background: #c0392b; }

  /* ===== RIGHT PANEL (ORDER BOOK) ===== */
  .right-panel {
      width: 50%;
      padding: 15px 10px;
      min-width: 0;
      position: sticky; /* FIX: right panel dính lại */
      top: 0;
      align-self: flex-start;
  }

  .orderbook-header {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: #aaa;
    font-weight: 600;
    margin-bottom: 6px;
    padding: 0 2px;
  }

  /* Order rows */
  .ob-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 4.5px 2px;
    font-size: 13px;
    overflow: hidden;
  }
  .ob-row .ob-price { font-weight: 600; z-index: 1; position: relative; }
  .ob-row .ob-amount {
    color: #444;
    font-size: 12.5px;
    z-index: 1;
    position: relative;
  }
  .ob-bg {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    opacity: 0.15;
    border-radius: 2px;
    transition: width 0.3s ease;
  }

  .ob-green .ob-price { color: #27ae60; }
  .ob-green .ob-bg { background: #2ecc71; }

  .ob-red .ob-price { color: #e74c3c; }
  .ob-red .ob-bg { background: #e74c3c; }

  /* Current price */
  .current-price-box {
    text-align: left;
    padding: 10px 2px;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    margin: 4px 0;
  }
  .current-price-val {
    font-size: 16px;
    font-weight: 800;
    color: #e74c3c;
    line-height: 1;
    margin-bottom: 3px;
    transition: color 0.3s;
  }
  .current-price-change {
    font-size: 12px;
    color: #e74c3c;
    font-weight: 600;
    transition: color 0.3s;
  }

  /* ===== BOTTOM TABS ===== */
  .bottom-section {
    border-top: 2px solid #f0f0f0;
  }
  .history-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid #f0f0f0;
  }
  .htab {
    padding: 12px 20px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    color: #aaa;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
  }
  .htab.active {
    color: #333;
    border-bottom-color: #333;
  }
  .htab:hover:not(.active) { color: #555; }

  .history-content {
    padding: 5px 20px;
    text-align: center;
    color: #bbb;
    font-size: 13.5px;
  }

/* ---- MODAL OVERLAY ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: fadeOverlay 0.2s ease;
}
.modal-overlay.show {
    display: flex;
}
@keyframes fadeOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- MODAL BOX ---- */
.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 88%;
    max-width: 380px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    animation: slideUp 0.25s cubic-bezier(.34,1.3,.64,1);
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ---- MODAL TITLE ---- */
.modal-title {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #f0f0f0;
}

/* ---- MODAL BODY ROWS ---- */
.modal-body {
    padding: 8px 24px 4px;
}
.modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid #f5f5f5;
}
.modal-row:last-child {
    border-bottom: none;
}
.modal-lbl {
    font-size: 14px;
    color: #888;
}
.modal-val {
    font-size: 14px;
    color: #1a1a1a;
    font-weight: 500;
}
.modal-val.buy  { color: #27ae60; font-weight: 600; }
.modal-val.sell { color: #e74c3c; font-weight: 600; }

/* ---- MODAL ACTIONS ---- */
.modal-actions {
    display: flex;
    border-top: 1px solid #f0f0f0;
    margin-top: 8px;
}
.btn-cancel,
.btn-confirm {
    flex: 1;
    padding: 16px 0;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-cancel {
    background: #fff;
    color: #666;
    border-right: 1px solid #f0f0f0;
}
.btn-cancel:active { background: #f5f5f5; }
.btn-confirm {
    background: #fff;
    color: #1a73e8;
}
.btn-confirm:active { background: #f0f6ff; }

/* ===== TP/SL COMBOBOX — FIX MOBILE ===== */
.leverage-display {
    display: flex; align-items: center; cursor: pointer;
    padding: 5px 5px; font-weight: 600; color: #333;
}
.leverage-option {
    padding: 12px 16px; font-size: 15px; font-weight: 600;
    color: #333; cursor: pointer; text-align: center; transition: background 0.2s;
}
.leverage-option:hover { background: #f5f5f5; }
.leverage-option.selected { color: #27ae60; }

.tpsl-combobox {
    display: flex;
    align-items: stretch;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    min-width: 0; /* FIX KEY */
    height: 28px;
}
.tpsl-input {
    flex: 1;
    min-width: 0; /* FIX KEY */
    border: none;
    outline: none;
    padding: 10px 8px;
    font-size: 14px;
    color: #333;
    background: transparent;
    width: 100%;
}
.tpsl-btn {
    flex-shrink: 0; /* FIX KEY */
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 5px;
    background: #f5f5f5;
    border-left: 1px solid #ddd;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    user-select: none;
}
.tpsl-btn:hover { background: #e8e8e8; }
.tpsl-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #ddd; border-radius: 8px;
    z-index: 200; box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    overflow: hidden; margin-top: 2px;
}
.tpsl-option {
    padding: 11px 16px; font-size: 14px; cursor: pointer;
    text-align: center; color: #333; transition: background 0.15s;
}
.tpsl-option:hover { background: #f5f5f5; }

/* ===== CONTRACT HISTORY TABLE ===== */
.contract-history-header {
    display: grid; gap: 4px; padding: 8px 10px;
    border-bottom: 1px solid #444; font-size: 11px;
    color: #888; font-weight: 600; text-transform: uppercase;
}
.contract-history-cell {
    display: grid; gap: 4px; padding: 10px;
    border-bottom: 1px solid #2a2a2a; font-size: 12px;
    color: #ccc; align-items: center;
}
.contract-history-cell div { word-break: break-all; }
.btn-close-contract {
    background: #e74c3c; color: #fff; border: none;
    border-radius: 6px; padding: 4px 8px; font-size: 11px;
    cursor: pointer; font-weight: 600;
}
.btn-close-contract:hover { background: #c0392b; }







.symbol-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 320px;
    height: 100vh;
    background: #fff;
    z-index: 3000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 20px rgba(0,0,0,0.15);
}
.symbol-sidebar.active { transform: translateX(0); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    z-index: 2999;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

.symbol-sidebar .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
}
.symbol-sidebar .close-x {
    background: none; border: none;
    font-size: 26px; cursor: pointer; color: #aaa; line-height: 1;
}
.symbol-sidebar .search-container { padding: 12px 16px; }
.symbol-sidebar .search-container input {
    width: 100%; padding: 9px 12px;
    background: #f5f5f5; border: none;
    border-radius: 8px; outline: none; font-size: 13px;
}

/* Tabs danh mục trong sidebar */
.sidebar-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    border-bottom: 1px solid #eee;
    padding: 0 12px;
    scrollbar-width: none;
}
.sidebar-tabs::-webkit-scrollbar { display: none; }
.sidebar-tab {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: all 0.15s;
}
.sidebar-tab.active { color: #1976d2; border-bottom-color: #1976d2; }

/* Danh sách coin */
.coin-list { flex: 1; overflow-y: auto; }
.coin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.15s;
}
.coin-item:hover { background: #f9f9f9; }
.coin-item.active-symbol { background: #e8f4fd; }
.coin-info { display: flex; align-items: center; gap: 10px; }
.coin-info img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.coin-info .coin-name { font-weight: 700; font-size: 14px; color: #222; }
.coin-info .coin-pair { font-size: 11px; color: #bbb; margin-top: 1px; }
.coin-price { text-align: right; }
.coin-price .price-val { font-weight: 600; font-size: 13px; color: #333; display: block; }
.coin-price .price-change { font-size: 11px; margin-top: 2px; display: block; }
.price-change.down { color: #e74c3c; }
.price-change.up   { color: #27ae60; }