/* 
  TRADINGVIEW PRO - PROFESSIONAL TERMINAL STYLES 
  System: 8px / 12px / 16px Grid
*/

:root {
    /* Color Palette - Professional Dark */
    --bg-main: #06090F;
    --bg-panel: #0D1117;
    --bg-surface: #161B22;
    --bg-input: #090C10;
    --border-main: #30363D;
    --border-subtle: #21262D;

    /* Semantic Colors */
    --buy-color: #23D160;
    --buy-hover: #1EBB56;
    --buy-bg: rgba(35, 209, 96, 0.1);
    --sell-color: #FF4757;
    --sell-hover: #E84150;
    --sell-bg: rgba(255, 71, 87, 0.1);
    --accent-cyan: #00D4AA;

    /* Text Colors */
    --text-primary: #F0F6FC;
    --text-secondary: #ffffff;
    --text-tertiary: #ffffff;

    /* Spacing System */
    --gap-s: 8px;
    --gap-m: 12px;
    --gap-l: 16px;

    /* Typography */
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Roboto Mono', monospace;

    /* Layout Constants */
    --header-h: 56px;
    --bottom-panel-h: 240px;
    --symbols-w: 240px;
    --order-panel-w: 300px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.4;
    overflow: hidden;
    /* Terminal feel */
    height: 100vh;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   MT5-STYLE MOBILE NAV (structure only; enabled via mobile breakpoint)
   ========================================================================== */
.mt5-nav-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mt5-mobile-nav {
    display: none; /* only shown on mobile */
}

.mobile-messages-panel {
    display: none; /* only shown on mobile */
}

.mobile-messages-content {
    padding: 16px;
}

.mobile-message-empty {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 18px 14px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input {
    font-family: var(--font-mono);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-main);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Main Grid Layout */
.terminal-layout {
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh;
    width: 100vw;
}

.header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--gap-l);
    z-index: 1000;
}

.main-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr auto;
    grid-template-areas:
        "symbols chart order"
        "bottom bottom bottom";
    gap: 1px;
    background: var(--border-main);
    overflow: hidden;
}

/* Panels Area */
.symbol-panel {
    grid-area: symbols;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    width: var(--symbols-w);
    transition: width 0.3s ease, border-left 0.3s ease;
    overflow: hidden;
    position: relative;
    border-right: 1px solid var(--border-main);
}

.symbol-panel.collapsed {
    width: 0;
    border-right: none;
}

.chart-section {
    grid-area: chart;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-width: 0;
    /* Allow shrinking */
}

.order-panel {
    grid-area: order;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    width: var(--order-panel-w);
    transition: width 0.3s ease, border-left 0.3s ease;
    overflow: hidden;
    position: relative;
    border-left: 1px solid var(--border-main);
}

.order-panel.collapsed {
    width: 0;
    border-left: none;
}

.bottom-panel {
    grid-area: bottom;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    height: var(--bottom-panel-h);
    transition: height 0.3s ease;
    overflow: hidden;
    border-top: 1px solid var(--border-main);
}

.bottom-panel.collapsed {
    height: 0;
    border-top: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-m);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.panel-toggle-btn {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    z-index: 100;
}

.panel-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--border-main);
    border-color: var(--accent-cyan);
}

/* Edge Re-open Buttons */
.edge-reopen-btn {
    position: absolute;
    z-index: 1001;
    display: none;
    /* Shown via JS */
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.edge-reopen-btn:hover {
    color: var(--accent-cyan);
    background: var(--bg-panel);
    border-color: var(--accent-cyan);
}

.edge-reopen-btn.left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.edge-reopen-btn.right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.edge-reopen-btn.bottom {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 28px;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    padding-bottom: 2px;
}

/* Header Elements */
.logo {
    display: flex;
    align-items: center;
    gap: var(--gap-s);
}

.logo-icon {
    width: 28px;
    height: 28px;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-accent {
    color: var(--accent-cyan);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--gap-l);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 4px 10px;
    border-radius: 4px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--buy-color);
}

.header-balance {
    display: flex;
    align-items: center;
    gap: var(--gap-s);
    background: var(--bg-surface);
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.real-tag {
    background: #E3B341;
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 2px;
}

.header-balance-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Symbols Panel */
.panel-header {
    padding: var(--gap-m);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.symbol-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: var(--gap-s);
    background: var(--bg-input);
}

.symbol-cat-btn {
    padding: 6px 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    background: transparent;
    border-radius: 4px;
    transition: 0.2s;
}

.symbol-cat-btn:hover {
    color: var(--text-primary);
}

.symbol-cat-btn.active {
    background: var(--bg-surface);
    color: var(--accent-cyan);
}

.symbol-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.symbol-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: 0.2s;
    border-left: 2px solid transparent;
}

.symbol-item:hover {
    background: var(--bg-surface);
}

.symbol-item.active {
    background: rgba(0, 212, 170, 0.05);
    border-left-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Chart Area */
.chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    height: 40px;
}

.current-symbol-display {
    display: flex;
    align-items: center;
    gap: var(--gap-m);
}

.current-symbol {
    font-size: 1rem;
    font-weight: 700;
}

.market-status {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--buy-color);
    background: var(--buy-bg);
    padding: 1px 6px;
    border-radius: 3px;
}

.timeframe-selector {
    display: flex;
    gap: 2px;
}

.tf-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #FFFFFF;
    background: #000000;
    border: 1px solid #333;
    border-radius: 4px;
    transition: 0.2s;
    margin: 0 1px;
}

.tf-btn:hover {
    background: #111;
    border-color: #555;
}

.tf-btn.active {
    background: #2196F3;
    color: #FFFFFF;
    border-color: #2196F3;
    font-weight: 700;
}

#tv_chart_container {
    flex: 1;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
}

/* Order Panel (Right Side) */
.live-price-display {
    padding: var(--gap-m) var(--gap-l);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.live-price-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.live-price-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.live-price-change {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.live-price-change.positive {
    color: var(--buy-color);
    background: var(--buy-bg);
}

.live-price-change.negative {
    color: var(--sell-color);
    background: var(--sell-bg);
}

.order-type-tabs {
    display: flex;
    background: var(--bg-input);
    padding: 2px;
    margin: var(--gap-m) var(--gap-l);
    border-radius: 6px;
}

.order-tab {
    flex: 1;
    padding: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-radius: 4px;
    background: transparent;
    transition: all 0.2s;
}

.order-tab.active {
    background: var(--bg-surface);
    color: var(--accent-cyan);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.limit-tab-text {
    color: inherit !important;
    font-weight: 700 !important;
}

.order-form {
    padding: var(--gap-m) var(--gap-l) var(--gap-l);
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--gap-m);
}

.price-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--gap-m);
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    margin-top: var(--gap-s);
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
}

.stat-value.buy-color {
    color: var(--buy-color);
}

.stat-value.sell-color {
    color: var(--sell-color);
}

.spread-center {
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    padding: 0 10px;
}

.spread-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
}

/* Buy/Sell Buttons Block */
/* ===== Login Overlay ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 15, 20, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body:not(.logged-out) .login-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.login-logo svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.login-logo span {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form input,
.login-form select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.login-form input:focus,
.login-form select:focus {
    border-color: var(--primary);
    outline: none;
}

.login-submit-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, transform 0.1s;
}

.login-submit-btn:hover {
    background: #00bfa5;
}

.login-submit-btn:active {
    transform: scale(0.98);
}

.login-submit-btn .loader {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.login-footer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== User Profile Info ===== */
.user-profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid var(--border-subtle);
    margin-right: 16px;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}

.p-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.p-value {
    color: var(--primary);
    font-weight: 600;
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--sell);
    color: var(--sell);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-transform: uppercase;
}

.logout-btn:hover {
    background: var(--sell);
    color: white;
}

/* Hide UI elements when logged out */
body.logged-out .main-grid,
body.logged-out .header-right .connection-status,
body.logged-out .header-right .header-balance {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

.execution-buttons {
    display: flex;
    gap: var(--gap-s);
}

.exec-btn {
    flex: 1;
    height: 64px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: 0.2s;
}

.exec-btn.buy {
    background: var(--buy-color);
    color: #000;
    box-shadow: 0 4px 15px rgba(35, 209, 96, 0.2);
}

.exec-btn.sell {
    background: var(--sell-color);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.2);
}

.exec-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.exec-btn:active {
    transform: translateY(0);
}

.exec-label {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Fields */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.input-wrapper {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: visible;
    transition: 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-cyan);
}

.input-wrapper input {
    flex: 1;
    min-width: 0;
    padding: 10px 4px;
    font-size: 0.95rem;
    font-weight: 700;
    background: transparent;
    border: none;
    color: #fff;
    text-align: center;
}

.input-wrapper.small input {
    font-size: 0.9rem;
    padding: 8px;
}

.vol-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
    flex-shrink: 0;
}

.vol-btn:first-child {
    border-radius: 6px 0 0 6px;
    border-right: none;
}

.vol-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.vol-btn:hover {
    color: var(--accent-cyan);
    background: var(--border-main);
    border-color: var(--accent-cyan);
}

.lot-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.lot-btn {
    padding: 6px 0;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-radius: 3px;
}

.lot-btn:hover {
    background: var(--border-main);
    color: #fff;
}

.order-protection-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-m);
}

.form-select {
    background: var(--bg-input);
    color: #fff;
    padding: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-weight: 600;
    outline: none;
}

.place-order-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-cyan);
    color: #000;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    margin-top: auto;
}

/* Bottom Panel (Trade / History) */
.bottom-tabs {
    display: flex;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    gap: 4px;
    padding: 4px;
}

.bottom-tab {
    padding: 10px 24px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    position: relative;
    transition: all 0.2s;
}

.bottom-tab:hover {
    color: var(--text-primary);
    background: var(--bg-panel);
    border-color: var(--border-main);
}

.bottom-tab.active {
    color: var(--accent-cyan);
    background: var(--bg-panel);
    border-color: var(--accent-cyan);
}

.bottom-tab.active::after {
    display: none;
}

.bottom-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-main);
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    color: #ffffff;
}

.trades-table th {
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    padding: 12px;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-main);
    z-index: 10;
}

.trades-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    border-right: 1px solid var(--border-subtle);
    background: transparent;
}

.trades-table td:last-child {
    border-right: none;
}

/* Column Widths */
.trades-table th:nth-child(1),
.trades-table td:nth-child(1) {
    width: 120px;
}

/* Symbol */
.trades-table th:nth-child(2),
.trades-table td:nth-child(2) {
    width: 100px;
}

/* Type */
.trades-table th:nth-child(3),
.trades-table td:nth-child(3) {
    width: 80px;
}

/* Volume */
.trades-table th:nth-child(4),
.trades-table td:nth-child(4) {
    width: 120px;
}

/* Open Price */
.trades-table th:nth-child(5),
.trades-table td:nth-child(5) {
    width: 120px;
}

/* Current Price */
.trades-table th:nth-child(6),
.trades-table td:nth-child(6) {
    width: 100px;
}

/* SL */
.trades-table th:nth-child(7),
.trades-table td:nth-child(7) {
    width: 100px;
}

/* TP */
.trades-table th:nth-child(8),
.trades-table td:nth-child(8) {
    width: 120px;
}

/* P/L */
.trades-table th:nth-child(9),
.trades-table td:nth-child(9) {
    width: auto;
}

/* Action */

.trades-table .positive {
    color: var(--buy-color);
}

.trades-table .negative {
    color: var(--sell-color);
}

.trades-table .buy {
    color: var(--buy-color);
    font-weight: 700;
}

.trades-table .sell {
    color: var(--sell-color);
    font-weight: 700;
}

.close-trade-btn {
    padding: 4px 8px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 0.75rem;
}

.close-trade-btn:hover {
    background: var(--sell-color);
    color: #fff;
    border-color: var(--sell-color);
}

/* Trading Summary (Below Table) */
.trading-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-input);
    border-top: 1px solid var(--border-main);
    height: 48px;
}

.summary-group-left {
    display: flex;
    gap: 24px;
    align-items: center;
}

.summary-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.summary-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-weight: 700;
    text-transform: uppercase;
}

.summary-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-value.highlight {
    color: var(--accent-cyan);
    font-size: 1rem;
}

.close-all-btn {
    padding: 6px 16px;
    background: var(--sell-bg);
    color: var(--sell-color);
    border: 1px solid var(--sell-color);
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    transition: 0.2s;
}

.close-all-btn:hover {
    background: var(--sell-color);
    color: #fff;
}

/* Modals */
.edit-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.edit-modal {
    position: relative;
    background: var(--bg-panel);
    width: 320px;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-main);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.edit-modal h3 {
    margin-bottom: 20px;
    font-size: 1rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
    font-weight: 700;
}

.modal-btn.save {
    background: var(--accent-cyan);
    color: #000;
}

.modal-btn.cancel {
    background: var(--bg-surface);
    color: #fff;
}

.empty-row td {
    text-align: center;
    color: var(--text-tertiary);
    padding: 48px !important;
    border: none;
}

/* Z-Index Hierarchy */
/* 
   - Chart Layer: 1
   - Order Lines: 10
   - Panels: 100
   - Header: 1000
   - Tooltips: 2000
   - Modals: 5000
*/

/* Chart Resize Fix */
.tradingview-widget-container {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM - UNIVERSAL MOBILE SUPPORT
   ========================================================================== */

/* Large Tablets & Small Laptops (under 1200px) */
@media (max-width: 1200px) {
    :root {
        --symbols-w: 200px;
        --order-panel-w: 280px;
    }

    .summary-group-left {
        gap: 12px;
    }
}

/* Medium Tablets & Small Desktops (under 992px) */
@media (max-width: 992px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .terminal-layout {
        display: block;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    .main-grid {
            display: flex;
            flex-direction: column;
            height: auto;
            background: var(--bg-main);
        }

        .symbol-panel,
        .order-panel,
        .chart-section,
        .bottom-panel {
            width: 100% !important;
            height: auto !important;
            position: relative !important;
            border: none;
            border-bottom: 1px solid var(--border-main);
            transition: none;
        }

        .symbol-panel.collapsed,
        .order-panel.collapsed,
        .bottom-panel.collapsed {
            height: 60px !important;
            min-height: 60px !important;
            overflow: hidden;
        }

        .chart-section {
            height: 450px !important;
            /* Fixed height for chart on mobile/tablet */
        }

        .bottom-panel {
            height: auto !important;
            min-height: 400px;
        }

        .bottom-content {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        .trades-table {
            min-width: 900px;
        }

        .trading-summary {
            position: sticky;
            bottom: 0;
            z-index: 100;
            background: var(--bg-panel);
        }

        /* Edge toggles are less useful when stacked */
        .edge-reopen-btn {
            display: none !important;
        }

        .header {
            flex-wrap: wrap;
            padding: 8px 12px;
        }

        .header-right {
            flex-wrap: wrap;
            gap: 8px;
        }
}

/* Small Tablets & Portrait Mobiles (under 768px) */
@media (max-width: 768px) {
    :root {
        --header-h: auto;
        --symbols-w: 100%;
        --order-panel-w: 100%;
    }

    body {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .terminal-layout {
        min-height: 100vh;
        height: auto;
    }

    .header {
        flex-direction: column;
        height: auto;
        min-height: auto;
        padding: 12px;
        gap: 12px;
        align-items: flex-start;
    }

    .logo {
        width: 100%;
        justify-content: space-between;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
    }

    .user-profile-info {
        padding: 4px 8px;
        flex: 1;
        justify-content: center;
        min-width: 0;
        overflow: hidden;
    }

    .user-profile-info .profile-item {
        display: none;
    }

    .user-profile-info .profile-item:last-child {
        display: flex;
    }

    .header-balance {
        padding: 6px 12px;
        flex-shrink: 0;
    }

    .connection-status {
        flex-shrink: 0;
    }

    .chart-toolbar {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
        align-items: stretch;
    }

    .current-symbol-display {
        width: 100%;
        justify-content: space-between;
    }

    .timeframe-selector {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 5px;
        justify-content: flex-start;
        display: flex;
        -webkit-overflow-scrolling: touch;
    }

    .tf-btn {
        flex-shrink: 0;
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .chart-section {
        height: 400px !important;
        min-height: 400px;
    }

    .order-form {
        padding: 16px;
    }

    .execution-buttons {
        margin-bottom: 16px;
        gap: 8px;
    }

    .exec-btn {
        height: 60px;
    }

    .order-entry-columns {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .form-group.row-align {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group.row-align label {
        margin-bottom: 4px;
        text-align: left;
    }

    .input-wrapper {
        width: 100%;
    }

    .vol-btn {
        width: 50px;
        height: 45px;
    }

    .price-stats {
        flex-direction: column;
        gap: 8px;
    }

    .stat-item {
        width: 100%;
        padding: 8px 0;
    }

    .spread-center {
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--border-subtle);
        border-bottom: 1px solid var(--border-subtle);
        padding: 8px 0;
    }

    .trading-summary {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        height: auto;
    }

    .summary-group-left {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    .summary-item {
        background: var(--bg-input);
        padding: 8px;
        border-radius: 6px;
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-actions {
        width: 100%;
    }

    .close-all-btn {
        width: 100%;
        height: 45px;
    }

    .login-card {
        padding: 24px;
        margin: 16px;
        max-width: calc(100% - 32px);
    }

    .login-header h1 {
        font-size: 1.3rem;
    }

    .login-form input,
    .login-form select {
        padding: 10px 14px;
    }

    .panel-header {
        padding: 10px 12px;
    }

        .panel-header h2 {
            font-size: 0.8rem;
        }

        .live-price-display {
            padding: 12px;
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }

        .live-price-value {
            font-size: 1.2rem;
        }

        .order-type-tabs {
            margin: 12px;
        }

        .symbol-categories {
            padding: 8px;
        }

        .symbol-item {
            padding: 8px 10px;
            font-size: 0.8rem;
        }

        .bottom-tabs {
            padding: 4px;
        }

        .bottom-tab {
            padding: 8px 16px;
            font-size: 0.75rem;
        }

    /* ==========================
       MT5 Mobile UI (Mobile only)
       ========================== */
    .terminal-layout {
        /* space for fixed footer nav */
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }

    .mt5-mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(64px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(13, 17, 23, 0.98);
        border-top: 1px solid var(--border-main);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        z-index: 3000;
        backdrop-filter: blur(10px);
    }

    .mt5-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-secondary);
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        user-select: none;
        cursor: pointer;
        min-height: 64px;
    }

    .mt5-nav-icon {
        font-size: 1.05rem;
        line-height: 1;
    }

    /* Active tab highlighting */
    #mt5-tab-quotes:checked ~ .mt5-mobile-nav label[for="mt5-tab-quotes"],
    #mt5-tab-charts:checked ~ .mt5-mobile-nav label[for="mt5-tab-charts"],
    #mt5-tab-trade:checked ~ .mt5-mobile-nav label[for="mt5-tab-trade"],
    #mt5-tab-history:checked ~ .mt5-mobile-nav label[for="mt5-tab-history"],
    #mt5-tab-messages:checked ~ .mt5-mobile-nav label[for="mt5-tab-messages"] {
        color: var(--accent-cyan);
    }

    /* Default: hide all panels in mobile, then show per tab */
    .main-grid {
        display: block;
        background: transparent;
        gap: 0;
    }

    .symbol-panel,
    .chart-section,
    .order-panel,
    .bottom-panel,
    .mobile-messages-panel {
        display: none !important;
        width: 100% !important;
        border: none;
        border-bottom: 1px solid var(--border-main);
    }

    /* Quotes → Market Watch */
    #mt5-tab-quotes:checked ~ .terminal-layout .symbol-panel {
        display: flex !important;
        height: auto !important;
        min-height: calc(100vh - 160px);
    }

    /* Charts → TradingView chart only */
    #mt5-tab-charts:checked ~ .terminal-layout .chart-section {
        display: flex !important;
        height: calc(100vh - 200px) !important;
        min-height: 420px;
    }

    /* Trade → Order Entry + Positions */
    #mt5-tab-trade:checked ~ .terminal-layout .order-panel {
        display: flex !important;
        height: auto !important;
    }

    #mt5-tab-trade:checked ~ .terminal-layout .bottom-panel {
        display: flex !important;
        height: auto !important;
        min-height: 360px;
    }

    /* History → History (bottom panel only; user can tap Account History tab) */
    #mt5-tab-history:checked ~ .terminal-layout .bottom-panel {
        display: flex !important;
        height: auto !important;
        min-height: calc(100vh - 220px);
    }

    /* Messages → notifications/alerts placeholder */
    #mt5-tab-messages:checked ~ .terminal-layout .mobile-messages-panel {
        display: flex !important;
        flex-direction: column;
        min-height: calc(100vh - 220px);
    }

    /* Hide edge reopen buttons in MT5 mobile mode */
    .edge-reopen-btn {
        display: none !important;
    }
}

/* Small Phones (under 480px) */
@media (max-width: 480px) {
    :root {
        --header-h: auto;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .header-balance-amount {
        font-size: 0.8rem;
    }

    .header-balance {
        padding: 4px 8px;
    }

    .real-tag {
        font-size: 0.6rem;
        padding: 1px 3px;
    }

    .chart-section {
        height: 350px !important;
        min-height: 350px;
    }

    .current-symbol {
        font-size: 0.9rem;
    }

    .market-status {
        font-size: 0.6rem;
    }

    .tf-btn {
        padding: 5px 6px;
        font-size: 0.65rem;
    }

    .summary-group-left {
        grid-template-columns: 1fr;
    }

    .order-tab {
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .limit-tab-text {
        font-size: 0.65rem;
    }

    .exec-btn {
        height: 56px;
    }

    .exec-label {
        font-size: 0.9rem;
    }

    .exec-sublabel {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 0.8rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .symbol-cat-btn {
        font-size: 0.65rem;
        padding: 5px 0;
    }

        .form-group label {
            font-size: 0.7rem;
        }

        .input-wrapper input {
            font-size: 0.85rem;
            padding: 8px 4px;
        }

        .vol-btn {
            width: 45px;
            height: 40px;
            font-size: 1rem;
        }

        .lot-btn {
            padding: 5px 0;
            font-size: 0.65rem;
        }

        .live-price-value {
            font-size: 1.1rem;
        }

        .live-price-change {
            font-size: 0.75rem;
        }

        .trades-table th,
        .trades-table td {
            padding: 8px 6px;
            font-size: 0.75rem;
        }

        .trades-table {
            min-width: 800px;
        }

        .panel-header h2 {
            font-size: 0.75rem;
        }

    .panel-toggle-btn {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .login-card {
        padding: 20px;
        margin: 12px;
        max-width: calc(100% - 24px);
    }

    .login-header h1 {
        font-size: 1.2rem;
    }

    .login-logo span {
        font-size: 1.2rem;
    }
}

/* Extra Small Phones (under 360px) */
@media (max-width: 360px) {
    .header {
        padding: 8px;
    }

    .logo-text {
        font-size: 0.85rem;
    }

    .chart-section {
        height: 300px !important;
        min-height: 300px;
    }

    .tf-btn {
        padding: 4px 5px;
        font-size: 0.6rem;
    }

    .exec-btn {
        height: 50px;
    }

    .exec-label {
        font-size: 0.85rem;
    }

    .order-form {
        padding: 12px;
    }

    .vol-btn {
        width: 40px;
        height: 38px;
    }

    .summary-item {
        padding: 6px;
    }

    .summary-label {
        font-size: 0.6rem;
    }

    .summary-value {
        font-size: 0.8rem;
    }
}

/* Landscape Mobile Devices */
@media (max-width: 992px) and (orientation: landscape) {
    .chart-section {
        height: 300px !important;
        min-height: 300px;
    }

    .header {
        padding: 8px 12px;
    }

    .header-right {
        flex-direction: row;
    }
}

/* iPhone/Samsung specific height fixes */
@media (max-height: 700px) and (max-width: 768px) {
    .chart-section {
        height: 300px !important;
        min-height: 300px;
    }

    .bottom-panel {
        min-height: 300px;
    }
}

/* Very Short Screens */
@media (max-height: 600px) {
    .chart-section {
        height: 250px !important;
        min-height: 250px;
    }

    .header {
        padding: 6px 8px;
    }
}

/* Touch Device Optimizations */
@media (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    .tf-btn,
    .symbol-cat-btn,
    .order-tab,
    .bottom-tab {
        min-height: 44px;
        min-width: 44px;
    }

    .vol-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .panel-toggle-btn {
        min-height: 32px;
        min-width: 32px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-icon svg,
    .edge-reopen-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}