/* MT5 Base Styles */
.adminuiux-in-iframe ::-webkit-scrollbar {
  height: 0;
  width: 0;
}

/* ==============================================
   MT5 CSS Variables — Canonical Block
   Uses Material Design colors matching real MT5 Android app.
   DARK theme is the default (site default is dark).
   Light mode overrides via body.light-mode below.
   ============================================== */
:root {
    --bg-primary: #1C1E26;
    --bg-secondary: #252830;
    --bg-tertiary: #2E3038;
    --input-bg: #252830;
    --text-primary: #E8EAED;
    --text-secondary: #8B929A;
    --text-tertiary: #5F6671;
    --border-color: #363940;
    --buy-color: #42A5F5;
    --sell-color: #EF5350;
    --up-color: #66BB6A;
    --down-color: #EF5350;
    --pending-color: #FFB74D;
    --primary-color: #42A5F5;
    --accent-blue: #42A5F5;
    --balance-blue: #42A5F5;
    --tp-color: #66BB6A;
    --sl-color: #EF5350;
    --font-mono: 'Roboto Mono', 'SF Mono', 'Monaco', 'Courier New', monospace;
}

/* Light mode — activated when user toggles theme via layout.xml */
body.light-mode {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F2F3F5;
    --bg-tertiary: #E8E9ED;
    --input-bg: #F2F3F5;
    --text-primary: #191C21;
    --text-secondary: #6D7580;
    --text-tertiary: #9CA3AF;
    --border-color: #E5E7EB;
    --buy-color: #2196F3;
    --sell-color: #c62828;
    --up-color: #4CAF50;
    --down-color: #c62828;
    --pending-color: #FF9800;
    --primary-color: #2196F3;
    --accent-blue: #2196F3;
    --balance-blue: #2196F3;
    --tp-color: #4CAF50;
    --sl-color: #c62828;
    --profit-green: #2e7d32;
    --loss-red: #c62828;
}

/* History Page Styles */
.history-tabs {
    display: flex;
    /*background: var(--primary-color);*/
    position: sticky;
    top: 60px; /* Position below header */
    /*z-index: 100;*/
    margin: 0;
    padding: 0;
}

.history-tab {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    /*color: rgba(255, 255, 255, 0.7);*/
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.history-tab.active {
    color: var(--accent-blue, #2196F3);
    border-bottom-color: var(--accent-blue, #2196F3);
}

.history-tab-content {
    display: none;
    min-height: calc(100vh - 180px);
}

.history-tab-content.active {
    display: block;
}

/* Positions Tab Styles */
.positions-header {
    background: var(--bg-primary);
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profit-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-item-inline {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.summary-item-inline .dots {
    flex: 1;
    border-bottom: 1px dotted #ccc;
    margin: 0 8px 4px;
}

.summary-label-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-value-right {
    font-size: 18px;
    font-weight: 700;
    text-align: right;
}

.profit-positive {
    color: var(--up-color);
}

.profit-negative {
    color: var(--down-color);
}

.deposit-blue, .balance-blue, .blue-text {
    color: var(--balance-blue);
}

.positions-list-mt5 {
    padding: 0;
}

.position-row-mt5 {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.position-left {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.position-title-row {
    margin-bottom: 4px;
    line-height: 1.3;
}

.position-label-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.position-pair-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.position-comma {
    color: var(--text-primary);
}

.position-trade-type {
    font-size: 15px;
    font-weight: 400;
}

.position-trade-type.buy {
    color: var(--buy-color);
}

.position-trade-type.sell {
    color: var(--sell-color);
}

.position-prices {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.position-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 120px;
}

.position-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.position-profit-value {
    font-size: 16px;
    font-weight: 700;
    text-align: right;
}

.green-profit {
    color: var(--up-color);
}

.red-profit {
    color: var(--down-color);
}

.blue-profit {
    color: var(--balance-blue);
}

/* Orders Tab Styles */
.orders-list-mt5 {
    padding: 0;
}

.order-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.order-main {
    flex: 1;
}

.order-pair-type {
    margin-bottom: 4px;
    line-height: 1.3;
}

.order-pair {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.order-comma {
    color: var(--text-primary);
}

.order-type-text {
    font-size: 15px;
    font-weight: 400;
}

.order-type-text.buy {
    color: var(--buy-color);
}

.order-type-text.sell, .order-type-text.sell-stop {
    color: var(--sell-color);
}

.order-volume {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.order-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.order-datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.order-status {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.orders-summary {
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.summary-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    font-size: 14px;
}

.summary-line .dots {
    flex: 1;
    border-bottom: 1px dotted #ccc;
    margin: 0 8px 4px;
}

.summary-line.total {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 6px;
    font-weight: 600;
}

.summary-label {
    color: var(--text-primary);
    font-weight: 400;
}

.summary-count {
    color: var(--primary-color);
    font-weight: 600;
}

/* Deals Tab Styles */
.deals-list-mt5 {
    padding: 0;
}

.deal-row-mt5 {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.deal-left {
    flex: 1;
}

.deal-title-row {
    margin-bottom: 4px;
    line-height: 1.3;
}

.deal-pair-bold {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.deal-comma {
    color: var(--text-primary);
}

.deal-type-text {
    font-size: 15px;
    font-weight: 400;
}

.deal-type-text.buy {
    color: var(--buy-color);
}

.deal-type-text.sell {
    color: var(--sell-color);
}

.deal-direction {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-primary);
}

.deal-volume-price {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
}

.deal-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    min-width: 100px;
}

.deal-datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
}

.deal-profit-amount {
    font-size: 16px;
    font-weight: 700;
    text-align: right;
    color: var(--up-color);
}

.deals-summary-section {
    padding: 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.summary-balance-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    font-size: 15px;
}

.summary-balance-row .dots {
    flex: 1;
    border-bottom: 1px dotted #ccc;
    margin: 0 8px 4px;
}

.summary-balance-row.balance-total {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 6px;
    font-weight: 700;
}

.summary-balance-label {
    color: var(--text-primary);
    font-weight: 400;
}

.summary-balance-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .position-right,
    .order-right,
    .deal-right {
        min-width: 100px;
    }

    .history-tab {
        font-size: 12px;
        padding: 12px 8px;
    }

    .history-tabs {
        top: 56px; /* Adjust for smaller header on mobile */
    }
}

/* Main content adjustments for sidebar layout */
/*.adminuiux-content.has-sidebar {
    padding: 0 !important;
}

.adminuiux-content.has-sidebar .history-tabs {
    margin: 0;
    width: 100%;
}

.adminuiux-content.has-sidebar .history-tab-content {
    width: 100%;
}

.adminuiux-content.has-sidebar .trade-container {
    width: 100%;
    max-width: 100%;
}*/

/* Ensure proper background for content */
.positions-header,
.position-row-mt5,
.order-row,
.deal-row-mt5,
.orders-summary,
.deals-summary-section,
.account-info {
    background: var(--bg-secondary) !important;
}

.position-card {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Trade Page Styles */
.trade-container {
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
}

.account-info {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.account-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.account-label {
    color: var(--text-secondary);
}

.account-value {
    font-weight: 600;
    color: var(--text-primary);
}

.positions-section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.position-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.position-symbol {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 8px;
    display: inline-block;
}

.position-type {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.position-type.buy {
    background: var(--buy-color);
}

.position-type.sell {
    background: var(--sell-color);
}

.position-profit {
    font-size: 20px;
    font-weight: 700;
    text-align: right;
}

.position-profit.positive {
    color: var(--up-color);
}

.position-profit.negative {
    color: var(--down-color);
}

.position-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.detail-item {
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font-mono);
}

.position-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.close {
    background: var(--sell-color);
    color: white;
    border-color: var(--sell-color);
}

.new-order-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s;
}

.new-order-btn:hover {
    transform: scale(1.05);
}

.new-order-btn:active {
    transform: scale(0.95);
}

/* Empty State Styles */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
}

/* Input Background Variable — now defined in canonical :root block above */

/* ============================================
   MT5 CHART PAGE STYLES
   ============================================ */

/* Chart Header */
.chart-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
}

.chart-header-left,
.chart-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.header-icon-btn:hover,
.header-icon-btn:active {
    background: var(--bg-secondary);
}

.header-timeframe-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

.header-timeframe-btn:hover {
    background: var(--bg-secondary);
}

/* Chart Main Container */
.chart-main {
    margin-top: 50px !important;
    padding: 0 !important;
    background: var(--bg-primary);
}

/* Price Ticker */
.price-ticker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
}

.ticker-left,
.ticker-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ticker-btn {
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ticker-btn:active {
    opacity: 0.8;
}

.sell-btn {
    background: var(--sell-color);
    color: white;
}

.buy-btn {
    background: var(--buy-color);
    color: white;
}

.ticker-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ticker-price {
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.ticker-volume {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-display {
    width: 60px;
    padding: 6px 20px 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 13px;
    text-align: center;
}

.volume-arrows {
    position: absolute;
    right: 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-secondary);
}

.volume-arrows svg {
    width: 10px;
    height: 4px;
}

/* Symbol Info Banner */
.symbol-info-banner {
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.symbol-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.symbol-description {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Chart Canvas Container */
.chart-canvas-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 170px);
    background: var(--bg-primary);
}

#priceChart {
    width: 100%;
    height: 100%;
    display: block;
}

/* Chart Info Overlay */
.chart-info-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    z-index: 10;
    pointer-events: none;
}

.chart-info-overlay div {
    display: flex;
    gap: 8px;
}

/* Chart Orders Overlay */
.chart-orders-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.order-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    display: flex;
    align-items: center;
    pointer-events: all;
    cursor: move;
}

.order-line.buy-order {
    background: var(--buy-color);
}

.order-line.sell-order {
    background: var(--sell-color);
}

.order-line.tp-order {
    background: var(--tp-color);
}

.order-line.sl-order {
    background: var(--sl-color);
}

.order-label {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    margin-left: 8px;
}

.order-price {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    position: absolute;
    right: 8px;
}

.order-actions {
    position: absolute;
    right: 8px;
    display: flex;
    gap: 4px;
}

.order-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.order-action-btn.delete-btn {
    background: var(--sl-color);
    border-color: var(--sl-color);
}

.order-action-btn.close-btn {
    background: var(--pending-color);
    border-color: var(--pending-color);
}

/* Indicator Subwindow */
.indicator-subwindow {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.indicator-label {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

#indicatorChart {
    width: 100%;
    height: calc(100% - 30px);
    display: block;
}

/* Timeframe Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-body {
    overflow-y: auto;
    padding: 20px;
}

.timeframe-section {
    margin-bottom: 24px;
}

.timeframe-section:last-child {
    margin-bottom: 0;
}

.timeframe-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.timeframe-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.timeframe-option {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.timeframe-option:hover {
    border-color: var(--primary-color);
}

.timeframe-option.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Drawing Toolbar */
.drawing-toolbar {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    z-index: 100;
}

.tool-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tool-btn:first-child {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 50%;
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tool-btn:hover {
    opacity: 0.8;
}

/* Drawing Objects on Chart */
.chart-trendline {
    position: absolute;
    pointer-events: all;
    cursor: move;
}

.trendline-path {
    stroke: var(--sl-color);
    stroke-width: 2;
    fill: none;
}

.trendline-handle {
    fill: var(--sl-color);
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-header {
        height: 44px;
    }

    .chart-main {
        margin-top: 44px !important;
    }

    .chart-canvas-container {
        height: calc(100vh - 154px);
    }

    .header-icon-btn {
        width: 36px;
        height: 36px;
    }

    .timeframe-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==============================================
   MT5 Supersize Pip Digits
   Last 1-2 digits of price rendered larger (MT5 convention)
   ============================================== */
.pip-large {
    font-size: 1.3em;
    font-weight: 800;
}

/* ==============================================
   MT5 Price Flash Animations
   Briefly flash green/red when price ticks up/down
   ============================================== */
.price-flash-up {
    animation: flashUp 0.3s ease;
}
.price-flash-down {
    animation: flashDown 0.3s ease;
}
@keyframes flashUp {
    0% { color: var(--up-color); }
    100% { color: var(--text-primary); }
}
@keyframes flashDown {
    0% { color: var(--down-color); }
    100% { color: var(--text-primary); }
}

/* ==============================================
   MT5 Position Swipe-to-Reveal Actions
   ============================================== */
.pos-swipe-actions {
    display: flex;
    gap: 0;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.pos-swipe-actions button {
    width: 72px;
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.pos-swipe-actions .swipe-modify {
    background: var(--accent-blue);
}
.pos-swipe-actions .swipe-close {
    background: var(--sell-color);
}

/* ==============================================
   MT5 Position Type Badges (Material Design)
   ============================================== */
.pos-badge.buy,
.position-type.buy {
    background: rgba(33, 150, 243, 0.12) !important;
    color: var(--buy-color) !important;
}
.pos-badge.sell,
.position-type.sell {
    background: rgba(244, 67, 54, 0.12) !important;
    color: var(--sell-color) !important;
}

/* ==============================================
   MT5 Order Modal — Buy/Sell Buttons
   ============================================== */
.order-dir-btn {
    height: 52px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
}
.order-dir-btn.buy-selected,
.order-dir-btn .order-dir-label[style*="green"] {
    background: var(--buy-color);
    color: #fff;
}
.order-dir-btn.sell-selected,
.order-dir-btn .order-dir-label[style*="red"] {
    background: var(--sell-color);
    color: #fff;
}
.order-dir-price {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ==============================================
   MT5 Account Stats — Monospace + Themed
   ============================================== */
.mt5-stat-value {
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.mt5-stat-equity {
    font-family: var(--font-mono);
    color: var(--balance-blue) !important;
}
/* ===== MT5 MODULE TEMPLATE STYLES (moved from inline <style> in template_mt5.xml) ===== */

                /* ========== MT5 MODULE — FULL-SCREEN TAKEOVER ========== */

                /* Hide sidebar + ALL footers when MT5 is active */
                .mt5-active .adminuiux-sidebar,
                .mt5-active .adminuiux-footer,
                .mt5-active .mobile-footer,
                .mt5-active footer,
                .mt5-active #footer,
                .mt5-active .o_footer {
                    display: none !important;
                }

                /* Hide sidebar + ALL footers when JustMarkets is active */
                .jm-active .adminuiux-sidebar,
                .jm-active .adminuiux-footer,
                .jm-active .mobile-footer,
                .jm-active footer,
                .jm-active #footer,
                .jm-active .o_footer {
                    display: none !important;
                }
                .mt5-active .adminuiux-content {
                    margin-left: 0 !important;
                    padding: 0 !important;
                }
                .mt5-active #wrapwrap > .container,
                .mt5-active #wrapwrap > .container-fluid {
                    max-width: 100% !important;
                    padding: 0 !important;
                }

                /* MT5 Container */
                .mt5-container {
                    display: flex;
                    flex-direction: column;
                    height: calc(100vh - var(--header-height, 60px));
                    background: var(--bg-primary);
                    overflow: hidden;
                }

                /* MT5 Top Bar */
                .mt5-topbar {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    padding: 8px 16px;
                    background: var(--bg-secondary);
                    border-bottom: 1px solid var(--border-color);
                    flex-shrink: 0;
                    min-height: 44px;
                }
                .mt5-topbar-left {
                    display: flex;
                    align-items: center;
                    gap: 12px;
                }
                .mt5-back-btn {
                    width: 36px;
                    height: 36px;
                    border-radius: 8px;
                    background: var(--bg-tertiary);
                    border: 1px solid var(--border-color);
                    color: var(--text-secondary);
                    cursor: pointer;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 14px;
                    transition: all 0.15s;
                }
                .mt5-back-btn:hover {
                    color: var(--text-primary);
                    border-color: var(--accent-blue);
                }
                .mt5-title {
                    font-size: 15px;
                    font-weight: 700;
                    color: var(--text-primary);
                }
                .mt5-account-badge {
                    font-size: 11px;
                    font-weight: 600;
                    padding: 3px 10px;
                    border-radius: 6px;
                    background: rgba(33, 150, 243, 0.12);
                    color: var(--accent-blue);
                }
                .mt5-account-badge.live {
                    background: rgba(251, 191, 36, 0.12);
                    color: #FFB74D;
                }

                /* MT5 Tab Content Area */
                .mt5-content {
                    flex: 1;
                    overflow-y: auto;
                    overflow-x: hidden;
                    padding: 16px;
                    -webkit-overflow-scrolling: touch;
                }
                .mt5-tab-pane {
                    display: none;
                }
                .mt5-tab-pane.active {
                    display: block;
                }

                /* MT5 Bottom Navigation — Pixel-Accurate MT5 Mobile */
                .mt5-bottom-nav {
                    display: flex;
                    align-items: stretch;
                    background: var(--bg-primary, #fff);
                    border-top: 1px solid var(--border-color, #E5E7EB);
                    flex-shrink: 0;
                    height: 56px;
                    padding-bottom: env(safe-area-inset-bottom, 0);
                }
                .mt5-nav-item {
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    gap: 3px;
                    cursor: pointer;
                    transition: all 0.15s;
                    border: none;
                    background: none;
                    position: relative;
                    padding: 6px 0;
                    text-decoration: none;
                }
                .mt5-nav-item:hover {
                    text-decoration: none;
                }
                /* MD3 nav icon — pill shape container */
                .mt5-nav-icon {
                    font-size: 18px;
                    color: var(--text-tertiary, #9CA3AF);
                    transition: color 0.15s, background 0.2s;
                    line-height: 1;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    width: 48px;
                    height: 30px;
                    border-radius: 15px;
                    position: relative;
                }
                .mt5-nav-icon svg {
                    display: block;
                    stroke: var(--text-tertiary, #9CA3AF);
                    transition: stroke 0.15s;
                }
                .mt5-nav-item.active .mt5-nav-icon {
                    background: #e3f2fd;
                }
                .mt5-nav-item.active .mt5-nav-icon svg {
                    stroke: var(--accent-blue, #2196F3);
                }

                /* Trade tab — same light blue pill as all other active tabs */
                .mt5-nav-trade.active .mt5-nav-trade-icon {
                    background: #e3f2fd;
                }
                .mt5-nav-trade.active .mt5-nav-trade-icon svg {
                    stroke: var(--accent-blue, #2196F3);
                }

                .mt5-nav-label {
                    font-size: 10px;
                    font-weight: 600;
                    color: var(--text-tertiary, #9CA3AF);
                    letter-spacing: 0.3px;
                    transition: color 0.15s;
                }
                .mt5-nav-item.active .mt5-nav-label {
                    color: var(--accent-blue, #2196F3);
                }
                /* No top indicator line — MT5 Android uses color change only */

                /* ========== TAB-SPECIFIC INLINE STYLES ========== */

                /* Quotes Tab */
                .mt5-quotes-table { width: 100%; }
                .mt5-quote-row {
                    display: grid;
                    grid-template-columns: 2fr 1fr 1fr 0.8fr 1fr;
                    gap: 8px;
                    padding: 12px 0;
                    border-bottom: 1px solid var(--border-color);
                    align-items: center;
                    cursor: pointer;
                    transition: background 0.1s;
                }
                .mt5-quote-row:hover { background: rgba(99, 102, 241, 0.04); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
                .mt5-quote-row:last-child { border-bottom: none; }
                .mt5-q-symbol { font-size: 16px; font-weight: 700; color: var(--text-primary, #1a1a1a); }
                .mt5-q-desc { font-size: 11px; color: var(--text-secondary, #888); }
                .mt5-q-price { font-size: 14px; font-weight: 600; color: var(--text-primary, #1a1a1a); font-family: var(--font-mono); }
                .mt5-q-price .big { font-size: 24px; font-weight: 700; }
                .mt5-q-price .sup { font-size: 14px; vertical-align: super; }
                .mt5-q-spread { font-size: 11px; color: #999; font-family: var(--font-mono); }
                .mt5-q-lowhigh { font-size: 11px; color: #999; font-family: var(--font-mono); margin-top: 2px; }
                .mt5-q-change { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
                .mt5-q-change.up { background: rgba(76, 175, 80, 0.12); color: var(--up-color); }
                .mt5-q-change.down { background: rgba(244, 67, 54, 0.12); color: var(--down-color); }

                /* Chart Tab */
                .mt5-chart-container { position: relative; }
                .mt5-chart-symbols {
                    display: flex;
                    gap: 6px;
                    overflow-x: auto;
                    padding-bottom: 8px;
                    margin-bottom: 12px;
                    scrollbar-width: none;
                }
                .mt5-chart-symbols::-webkit-scrollbar { display: none; }
                .mt5-chart-chip {
                    padding: 6px 14px;
                    border-radius: 8px;
                    font-size: 12px;
                    font-weight: 700;
                    background: var(--bg-secondary);
                    border: 1px solid var(--border-color);
                    color: var(--text-secondary);
                    cursor: pointer;
                    white-space: nowrap;
                    transition: all 0.15s;
                }
                .mt5-chart-chip.active {
                    background: rgba(33, 150, 243, 0.12);
                    border-color: var(--accent-blue);
                    color: var(--accent-blue);
                }
                .mt5-chart-widget {
                    width: 100%;
                    height: calc(100vh - 260px);
                    min-height: 400px;
                    border-radius: 8px;
                    overflow: hidden;
                    background: var(--bg-secondary);
                    border: 1px solid var(--border-color);
                }

                /* News Tab */
                .mt5-news-item {
                    padding: 14px 0;
                    border-bottom: 1px solid var(--border-color);
                }
                .mt5-news-item:last-child { border-bottom: none; }
                .mt5-news-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
                .mt5-news-meta { font-size: 11px; color: var(--text-tertiary); display: flex; gap: 12px; align-items: center; }
                .mt5-news-impact {
                    display: inline-block;
                    width: 8px;
                    height: 8px;
                    border-radius: 50%;
                }
                .mt5-news-impact.high { background: var(--down-color); }
                .mt5-news-impact.medium { background: #FFB74D; }
                .mt5-news-impact.low { background: var(--up-color); }

                /* Responsive */
                @media (max-width: 600px) {
                    .mt5-quote-row { grid-template-columns: 1.5fr 1fr 1fr; }
                    .mt5-quote-row > div:nth-child(4) { display: none; }
                    .mt5-content { padding: 12px; }
                    .mt5-chart-widget { height: calc(100vh - 240px); min-height: 320px; }
                }
                @media (max-width: 400px) {
                    .mt5-quote-row { grid-template-columns: 1fr 1fr; }
                    .mt5-quote-row > div:nth-child(3),
                    .mt5-quote-row > div:nth-child(4) { display: none; }
                }
            

/* ===== ORDER MODAL STYLES (moved from template_trade.xml inline styles) ===== */
.order-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 1000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.order-overlay.show { display: flex; }
.order-modal { background: var(--bg-secondary, var(--bg2, #252830)); border: 1px solid var(--border-color, var(--brd, #363940)); border-radius: 16px; padding: 28px; width: 440px; max-width: 92vw; max-height: 90vh; overflow-y: auto; }
.order-modal-title { font-size: 18px; font-weight: 800; color: var(--text-primary, var(--t1, #E8EAED)); margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }
.order-modal-close { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-tertiary, var(--bg3, #2E3038)); border: 1px solid var(--border-color, var(--brd, #363940)); color: var(--text-secondary, var(--t2, #8B929A)); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.order-field { margin-bottom: 16px; }
.order-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary, var(--t3, #5F6671)); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 6px; display: block; }
.order-field select, .order-field input { width: 100%; padding: 10px 14px; border-radius: 10px; background: var(--bg-tertiary, var(--bg3, #2E3038)); border: 1px solid var(--border-color, var(--brd, #363940)); color: var(--text-primary, var(--t1, #E8EAED)); font-size: 14px; font-weight: 600; }
.order-field select:focus, .order-field input:focus { outline: none; border-color: var(--accent-blue, #42A5F5); }
.order-direction { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order-dir-btn { padding: 12px; border-radius: 10px; border: 2px solid var(--border-color, var(--border-color)); background: var(--bg-tertiary, var(--bg-tertiary)); cursor: pointer; text-align: center; transition: all 0.15s; }
.order-dir-btn:hover { border-color: var(--text-secondary, var(--text-tertiary)); }
.order-dir-btn input { display: none; }
.order-dir-btn.buy-selected { border-color: var(--buy-color, #42A5F5); background: rgba(66,165,245,0.08); }
.order-dir-btn.sell-selected { border-color: var(--sell-color, #EF5350); background: rgba(239,83,80,0.08); }
.order-dir-label { font-size: 14px; font-weight: 800; }
.order-dir-price { font-size: 11px; color: var(--text-secondary, var(--text-tertiary)); margin-top: 2px; font-family: var(--font-mono, monospace); }
.order-price-info { display: flex; justify-content: space-between; padding: 10px 14px; background: var(--bg-tertiary, var(--bg-tertiary)); border-radius: 10px; border: 1px solid var(--border-color, var(--border-color)); margin-bottom: 16px; }
.order-price-info div { text-align: center; }
.order-price-info .price-label { font-size: 10px; color: var(--text-secondary, var(--text-tertiary)); text-transform: uppercase; letter-spacing: 0.5px; }
.order-price-info .price-value { font-size: 14px; font-weight: 700; color: var(--text-primary, var(--text-primary)); font-family: var(--font-mono, monospace); }
.order-vol-row { display: flex; align-items: center; gap: 8px; }
.order-vol-btn { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-tertiary, var(--bg-tertiary)); border: 1px solid var(--border-color, var(--border-color)); color: var(--text-primary, var(--text-primary)); font-size: 18px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.order-vol-btn:hover { border-color: var(--accent-blue, #42A5F5); color: var(--accent-blue, #42A5F5); }
.order-sl-tp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.order-submit { width: 100%; padding: 14px; border-radius: 12px; background: var(--buy-color, #42A5F5); color: #fff; border: none; font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 8px; transition: transform 0.15s, box-shadow 0.15s; }
.order-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(66,165,245,0.35); }
.order-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Trade FAB */
.trade-fab { position: fixed; bottom: 72px; right: 20px; width: 52px; height: 52px; border-radius: 14px; background: var(--buy-color, #42A5F5); color: #fff; border: none; font-size: 22px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(66,165,245,0.4); transition: transform 0.2s, box-shadow 0.2s; z-index: 50; }
.trade-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(66,165,245,0.5); }

/* Position card styles (flat MT5 style) */
.pos-card, .pos-header, .pos-symbol, .pos-badge, .pos-ticket, .pos-profit, .pos-actions, .pos-btn { /* base reset */ }
.pos-symbol { font-size: 14px; font-weight: 700; color: var(--text-primary, var(--text-primary)); margin-right: 8px; }
.pos-badge { font-size: 12px; font-weight: 600; }
.pos-badge.buy { color: var(--buy-color, #42A5F5); }
.pos-badge.sell { color: var(--sell-color, #EF5350); }
.pos-ticket { font-size: 11px; color: var(--text-secondary, var(--text-tertiary)); font-family: var(--font-mono, monospace); }
.pos-profit { font-size: 16px; font-weight: 800; }
.pos-profit.positive { color: var(--up-color, #66BB6A); }
.pos-profit.negative { color: var(--down-color, #EF5350); }
.pos-btn { padding: 4px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; }
.pos-btn-modify { background: rgba(66,165,245,0.12); color: var(--accent-blue, #42A5F5); border: 1px solid rgba(66,165,245,0.25); }
.pos-btn-modify:hover { background: rgba(66,165,245,0.2); }
.pos-btn-close { background: rgba(239,83,80,0.12); color: var(--sell-color, #EF5350); border: 1px solid rgba(239,83,80,0.25); }
.pos-btn-close:hover { background: rgba(239,83,80,0.2); }
.pos-btn-cancel { background: rgba(255,183,77,0.12); color: var(--pending-color, #FFB74D); border: 1px solid rgba(255,183,77,0.25); }
.pos-btn-cancel:hover { background: rgba(255,183,77,0.2); }

/* ===== MT5 MOBILE FULL-WIDTH FIX ===== */
/* Override Odoo's website container padding on mobile for MT5 pages */
.mt5-active #wrapwrap,
.mt5-active #wrapwrap > main,
.mt5-active #wrapwrap .container,
.mt5-active #wrapwrap .container-fluid,
.mt5-active #wrapwrap .o_main_content,
.mt5-active .oe_website_sale,
.mt5-active #wrap {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}
.mt5-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}
/* Same for JustMarkets */
.jm-active #wrapwrap,
.jm-active #wrapwrap > main,
.jm-active #wrapwrap .container,
.jm-active #wrapwrap .container-fluid,
.jm-active #wrapwrap .o_main_content,
.jm-active #wrap {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}
.jm-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==============================================
   MT5 Supersize Pip Digits (named mt5- prefix)
   ============================================== */
.mt5-pip-large { font-size: 1.4em; font-weight: 700; }
.mt5-pip-super { font-size: 0.75em; vertical-align: super; font-weight: 700; }

/* ==============================================
   MT5 Price Flash Animations (background flash)
   ============================================== */
@keyframes flash-green { 0% { background: rgba(76,175,80,0.2); } 100% { background: transparent; } }
@keyframes flash-red { 0% { background: rgba(244,67,54,0.2); } 100% { background: transparent; } }
.mt5-flash-up { animation: flash-green 0.3s ease-out; }
.mt5-flash-down { animation: flash-red 0.3s ease-out; }
