* { margin:0; padding:0; box-sizing:border-box; }

body {
    background: #17130f;
    color: #e8ddd0;
    font-family: 'Segoe UI', 'Courier New', monospace;
    font-size: 1.05rem;
    height: 100vh;
    overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

#header {
    background: #231d18;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 2px solid #4a3a2a;
    flex-shrink: 0;
    gap: 6px;
}
#logo {
    font-weight: bold;
    font-size: 1.4rem;
    margin-right: 18px;
    color: #f5ebe0;
    letter-spacing: 1px;
    white-space: nowrap;
    min-width: 140px;
}

#mode-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
#btn-trade-mode, #btn-manual-mode {
    background: #2e2620;
    border: 2px solid #5a4a3a;
    color: #e8ddd0;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    transition: background 0.1s;
    border-radius: 0;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.2;
}
#btn-trade-mode:hover, #btn-manual-mode:hover { background: #3d3229; }

#status-bar {
    display: flex;
    gap: 10px;
    font-size: 0.95rem;
    flex: 1;
    flex-wrap: wrap;
}
#status-bar span {
    background: #1a1511;
    padding: 3px 10px;
    border: 1px solid #3a2f26;
    color: #e8ddd0;
}
#status-bar #mode-status { border-width: 2px; background: #1a1511; }
#status-bar #timeframe-display,
#status-bar #leverage-display {
    background: #2e2620;
    border-color: #5a4a3a;
    font-weight: bold;
}
#controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
#controls button {
    background: #2e2620;
    border: 1px solid #5a4a3a;
    color: #e8ddd0;
    padding: 5px 12px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    transition: background 0.1s;
}
#controls button:hover { background: #3d3229; }
#controls #btn-settings { background: #3d3229; border-color: #6a5a4a; }
#controls #btn-settings:hover { background: #4d4136; }
#controls #btn-tz {
    min-width: 130px;
    background: #1e3a4a;
    border-color: #5a4a3a;
    color: #c8e0f0;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#controls #btn-tz:hover { background: #2a4a5a; color: #e0f0ff; }
#controls #btn-scroll-start,
#controls #btn-scroll-end {
    font-size: 1.2rem;
    padding: 3px 12px;
    min-width: 40px;
    font-weight: 900;
}

#controls #tolerance-input {
    background: #ffffff;
    border: 1px solid #5a4a3a;
    color: #000000;
    padding: 5px 8px;
    font-size: 0.95rem;
    font-weight: bold;
    width: 72px;
    text-align: right;
    border-radius: 0;
    font-family: inherit;
    transition: border-color 0.1s, box-shadow 0.1s;
    -moz-appearance: textfield;
    appearance: textfield;
}
#controls #tolerance-input::-webkit-outer-spin-button,
#controls #tolerance-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#controls #tolerance-input:hover { border-color: #a8c880; }
#controls #tolerance-input:focus {
    outline: none;
    border-color: #a8c880;
    box-shadow: 0 0 0 2px rgba(168, 200, 128, 0.35);
}

#btn-toggle-net {
    min-width: 130px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#btn-toggle-net.net-on {
    background: #1e4228;
    border-color: #44dd44;
    color: #c8ffc8;
}
#btn-toggle-net.net-on:hover { background: #2a5a3a; }
#btn-toggle-net.net-off {
    background: #4a2020;
    border-color: #cc4444;
    color: #ffc8c8;
}
#btn-toggle-net.net-off:hover { background: #5e2a2a; }

#btn-toggle-hhll {
    min-width: 110px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#btn-toggle-hhll.hhll-on {
    background: #1e3a4a;
    border-color: #00c8ff;
    color: #c8e8ff;
}
#btn-toggle-hhll.hhll-on:hover { background: #2a4a5a; color: #e0f0ff; }
#btn-toggle-hhll.hhll-off {
    background: #2e2620;
    border-color: #5a4a3a;
    color: #a89880;
}
#btn-toggle-hhll.hhll-off:hover { background: #3d3229; color: #c8b8a0; }

#btn-toggle-markov {
    min-width: 130px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#btn-toggle-markov.markov-on {
    background: #1e3a4a;
    border-color: #66ccff;
    color: #c8e8ff;
}
#btn-toggle-markov.markov-on:hover { background: #2a4a5a; color: #e0f0ff; }
#btn-toggle-markov.markov-off {
    background: #2e2620;
    border-color: #5a4a3a;
    color: #a89880;
}
#btn-toggle-markov.markov-off:hover { background: #3d3229; color: #c8b8a0; }

#btn-toggle-alarm {
    min-width: 130px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#btn-toggle-alarm.alarm-on {
    background: #4a2a10;
    border-color: #ff8800;
    color: #ffcc88;
}
#btn-toggle-alarm.alarm-on:hover { background: #5e3a18; }
#btn-toggle-alarm.alarm-off {
    background: #2e2620;
    border-color: #5a4a3a;
    color: #a89880;
}
#btn-toggle-alarm.alarm-off:hover { background: #3d3229; color: #c8b8a0; }

#btn-web {
    min-width: 70px;
    background: #2a3a1e;
    border-color: #5a4a3a;
    color: #d0e0b8;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-width: 2px;
}
#btn-web:hover { background: #3a4a2a; color: #e8f0d8; }

#main { display: flex; flex: 1; overflow: hidden; min-height: 0; }

#right-panel {
    background: #1f1a15;
    padding: 10px 14px;
    overflow-y: auto;
    border-left: 2px solid #4a3a2a;
    flex-shrink: 0;
    width: 12%;
    min-width: 180px;
}

body:not(.mobile-view) #right-panel {
    zoom: 0.7;
}

body:not(.mobile-view) #header,
body:not(.mobile-view) #log-area,
body:not(.mobile-view) .chart-label,
body:not(.mobile-view) .chart-header,
body:not(.mobile-view) #minimized-bar,
body:not(.mobile-view) .modal-content,
body:not(.mobile-view) #signal-alarm-box {
    zoom: 0.7;
}

.panel {
    background: #1a1511;
    border: 1px solid #4a3a2a;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.panel h3 {
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: #f5ebe0;
    border-bottom: 1px dashed #4a3a2a;
    padding-bottom: 5px;
    font-weight: bold;
}
.panel h4 { font-size: 0.95rem; color: #f5ebe0; margin: 6px 0 4px 0; }
.panel label { font-size: 0.9rem; display: block; margin-top: 6px; color: #c8b8a0; }
.panel input, .panel select, .panel textarea {
    width: 100%;
    background: #231d18;
    border: 1px solid #4a3a2a;
    color: #e8ddd0;
    padding: 5px 8px;
    border-radius: 0;
    font-size: 0.9rem;
    margin-top: 2px;
}
.panel button {
    background: #2e2620;
    border: 1px solid #5a4a3a;
    color: #e8ddd0;
    padding: 5px 12px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background 0.1s;
}
.panel button:hover { background: #3d3229; }
#trade-notional {
    font-weight: bold;
    color: #f5ebe0;
    border-color: #6a5a4a;
    background: #2a221c;
}
#indicators-list { max-height: 160px; overflow-y: auto; margin-bottom: 6px; }
.indicator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #231d18;
    padding: 4px 8px;
    border: 1px solid #4a3a2a;
    margin-bottom: 3px;
    font-size: 0.9rem;
    cursor: pointer;
    color: #d8cdb8;
}
.indicator-item:hover { background: #2e2620; }
.indicator-item.active { background: #3d3229; border-color: #a8c880; color: #f5ebe0; }
.indicator-item .name { flex: 1; margin-right: 8px; }
.indicator-item .actions button {
    background: transparent;
    border: none;
    color: #c8b8a0;
    cursor: pointer;
    margin-left: 4px;
    font-size: 0.95rem;
    font-weight: bold;
    padding: 2px 4px;
}
.indicator-item .actions button:hover { color: #f5ebe0; }

#charts-container { flex: 1; display: flex; flex-direction: column; background: #17130f; min-height: 0; }
.chart-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chart-wrapper:first-child { border-bottom: 2px solid #4a3a2a; }

.chart-label {
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    font-size: 0.95rem;
    color: #c8b8a0;
    padding: 0;
    background: #1f1a15;
    border-bottom: 2px solid #4a3a2a;
    flex-shrink: 0;
    font-weight: bold;
    min-height: 28px;
}
.chart-label .chart-label-title {
    display: flex;
    align-items: center;
    padding: 0 12px;
    flex: 1;
    font-weight: bold;
    color: #c8b8a0;
}
.chart-label .tf-add-btn {
    background: #2a3a1e;
    color: #d0e0b8;
    border: none;
    border-right: 2px solid #4a3a2a;
    font-weight: 900;
    letter-spacing: 0.5px;
    padding: 0 16px;
    cursor: pointer;
    border-radius: 0;
    font-family: inherit;
    font-size: 0.9rem;
    transition: background 0.1s, color 0.1s;
}
.chart-label .tf-add-btn:hover { background: #3a4a2a; color: #e8f0d8; }
.tf-tabs {
    display: flex;
    align-items: stretch;
    background: #1f1a15;
}
.tf-tab {
    background: transparent;
    border: none;
    border-right: 2px solid #4a3a2a;
    color: #c8b8a0;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background 0.1s, color 0.1s, border-bottom-color 0.1s;
    border-bottom: 3px solid transparent;
    font-family: inherit;
}
.tf-tab:hover { background: #2e2620; color: #f5ebe0; }
.tf-tab.active { background: #2e2620; color: #f5ebe0; border-bottom-color: #a8c880; }

.chart-header {
    display: flex;
    align-items: stretch;
    background: #1f1a15;
    border-bottom: 2px solid #4a3a2a;
    flex-shrink: 0;
    min-height: 28px;
}
.chart-header .chart-tabs { flex: 1; border-bottom: none; }
.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    background: #1f1a15;
    border-bottom: 2px solid #4a3a2a;
    flex-shrink: 0;
    padding: 2px 6px;
    align-items: stretch;
}
.chart-tabs .tab-btn {
    background: transparent;
    border: none;
    color: #c8b8a0;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 3px solid transparent;
    transition: all 0.1s;
    font-weight: bold;
    border-radius: 0;
}
.chart-tabs .tab-btn:hover { background: #2e2620; color: #f5ebe0; }
.chart-tabs .tab-btn.active { background: #2e2620; color: #f5ebe0; border-bottom-color: #a8c880; }
.chart { flex: 1; min-height: 0; }
.chart-body { position: relative; flex: 1; min-height: 0; display: flex; }
.chart-body > .chart { flex: 1; min-height: 0; }
.position-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.connector-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.position-box {
    position: absolute;
    background: #1a1511;
    border: 2px solid #44dd44;
    color: #f5ebe0;
    font-size: 1.6rem;
    font-weight: bold;
    padding: 8px 40px 8px 16px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
    transform: translate(-50%, -50%) scale(0.4);
    transform-origin: center center;
    pointer-events: none;
    font-family: 'Segoe UI', 'Courier New', monospace;
    z-index: 2;
}
.position-box .size-label { padding: 0 8px; user-select: none; }
.position-box .info-box {
    font-size: 1rem;
    font-weight: bold;
    padding: 2px 10px;
    min-width: 78px;
    text-align: center;
    background: #231d18;
    border: 1px solid #5a4a3a;
    color: #e8ddd0;
    font-family: 'Courier New', monospace;
    user-select: none;
}
.position-box .info-box.pos { color: #44dd44; border-color: #2a5a3a; }
.position-box .info-box.neg { color: #ff6666; border-color: #7a2020; }
.position-box button {
    background: #2e2620;
    border: 2px solid #5a4a3a;
    color: #e8ddd0;
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: inherit;
    pointer-events: auto;
    border-radius: 0;
}
.position-box button:hover { background: #3d3229; color: #a8c880; }
.position-box .btn-close-pos {
    position: absolute;
    top: 0;
    right: 0;
    background: #3a1818;
    border-top: none;
    border-right: none;
    border-left: 2px solid #5a4a3a;
    border-bottom: 2px solid #5a4a3a;
    width: 32px;
    height: 32px;
    font-size: 1.4rem;
}
.position-box .btn-close-pos:hover { background: #7a2020; color: #ff8888; }

.chart-ctrl-btn {
    background: #2e2620;
    border: none;
    border-left: 2px solid #4a3a2a;
    color: #e8ddd0;
    padding: 0 14px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    font-family: inherit;
}
.chart-ctrl-btn:hover { background: #3d3229; color: #a8c880; }

.chart-wrapper.minimized { display: none !important; }
#log-area.minimized { display: none !important; }
body.price-maximized .indicator-wrapper { display: none !important; }
body.price-maximized #log-area { display: none !important; }
body.price-maximized #minimized-bar { display: none !important; }

#minimized-bar {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 900;
    display: none;
    gap: 6px;
    padding: 4px;
    background: #231d18;
    border: 2px solid #4a3a2a;
    box-shadow: 0 4px 14px rgba(0,0,0,0.6);
}
#minimized-bar.has-tabs { display: flex; }
.minimized-tab {
    background: #2e2620;
    border: 2px solid #5a4a3a;
    color: #e8ddd0;
    padding: 6px 16px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    font-family: inherit;
    letter-spacing: 0.5px;
}
.minimized-tab:hover { background: #3d3229; border-color: #a8c880; color: #f5ebe0; }

#log-area {
    height: 200px;
    background: #1a1511;
    border-top: 2px solid #4a3a2a;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
#log-tabs {
    display: flex;
    background: #231d18;
    border-bottom: 2px solid #4a3a2a;
    align-items: stretch;
    min-height: 28px;
}
#log-tabs .tab {
    padding: 6px 18px;
    cursor: pointer;
    background: #231d18;
    border-right: 2px solid #4a3a2a;
    font-size: 0.95rem;
    font-weight: bold;
    color: #c8b8a0;
    display: flex;
    align-items: center;
}
#log-tabs .tab.active { background: #17130f; color: #f5ebe0; }
#log-tabs .chart-ctrl-btn { margin-left: auto; border-left: 2px solid #4a3a2a; border-right: none; }
#log-content { flex: 1; overflow: hidden; }
.log-panel {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    background: #17130f;
    color: #d8cdb8;
}
.log-panel.active { display: block; }
#log-console .log-entry { border-bottom: 1px solid #231d18; padding: 2px 0; }
#log-console .log-entry .time { color: #7a6b5a; margin-right: 12px; }
#command-output {
    background: #17130f;
    padding: 6px 12px;
    height: 100%;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #d8cdb8;
}
#command-input {
    background: #231d18;
    border: 1px solid #4a3a2a;
    color: #e8ddd0;
    padding: 6px 10px;
    border-radius: 0;
    font-family: monospace;
    flex: 1;
    font-size: 0.9rem;
}
#command-send {
    background: #2e2620;
    border: 1px solid #5a4a3a;
    color: #e8ddd0;
    padding: 6px 14px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
}
#command-send:hover { background: #3d3229; }

.modal {
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #1f1a15;
    padding: 22px;
    border: 3px solid #5a4a3a;
    min-width: 340px;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    color: #e8ddd0;
}
.modal-content .close-btn {
    float: right;
    font-size: 2rem;
    cursor: pointer;
    color: #c8b8a0;
    line-height: 1;
}
.modal-content .close-btn:hover { color: #ff8888; }
.modal-content h2 {
    margin-top: 0;
    margin-bottom: 14px;
    color: #f5ebe0;
    font-size: 1.3rem;
    border-bottom: 2px solid #4a3a2a;
    padding-bottom: 8px;
}
.modal-content h4.web-section {
    font-size: 0.95rem;
    color: #a8c880;
    margin-top: 16px;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px dashed #4a3a2a;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.modal-content .param-row { margin-bottom: 10px; }
.modal-content .param-row label { display: block; font-size: 0.95rem; color: #c8b8a0; }
.modal-content .param-row input {
    width: 100%;
    background: #231d18;
    border: 1px solid #4a3a2a;
    color: #e8ddd0;
    padding: 6px 8px;
    border-radius: 0;
    font-size: 0.95rem;
}
.modal-content .param-row input[type="checkbox"] {
    width: auto;
    padding: 0;
    accent-color: #a8c880;
}
.modal-content .param-row input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.modal-content button {
    background: #2e2620;
    border: 1px solid #5a4a3a;
    color: #e8ddd0;
    padding: 6px 14px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: bold;
    transition: background 0.1s;
}
.modal-content button:hover { background: #3d3229; }
.modal-content button:disabled { opacity: 0.5; cursor: not-allowed; }
.modal-content #api-keys-list .key-item {
    padding: 4px 8px;
    cursor: pointer;
    border: 2px solid transparent;
    color: #d8cdb8;
}
.modal-content #api-keys-list .key-item:hover { background: #2e2620; }
.modal-content #api-keys-list .key-item.selected {
    border-color: #a8c880;
    background: #2a3a1e;
    color: #f5ebe0;
}

#web-modal .modal-content,
.web-modal-content {
    min-width: 480px;
    max-width: 640px;
    max-height: 90vh;
}

#settings-modal { z-index: 1000; }
#indicator-modal { z-index: 1100; }
#trade-modal { z-index: 1050; }
#web-modal { z-index: 1080; }
#increase-modal { z-index: 1150; }
#tf-modal { z-index: 1200; }
#tz-modal { z-index: 1250; }
#leverage-modal { z-index: 1300; }
.settings-modal-content { min-width: 720px; max-width: 980px; width: 92%; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-grid .panel { margin-bottom: 0; }
.settings-grid .settings-wide-panel { grid-column: 1 / -1; }
.settings-grid .settings-wide {
    grid-column: 1 / -1;
    background: #3d3229;
    border: 2px solid #6a5a4a;
    color: #e8ddd0;
    padding: 8px 16px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.1s;
}
.settings-grid .settings-wide:hover { background: #4d4136; }
@media (max-width: 840px) {
    .settings-modal-content { min-width: 0; width: 95%; }
    .settings-grid { grid-template-columns: 1fr; }
    #web-modal .modal-content, .web-modal-content { min-width: 0; width: 95%; }
}
.trade-row { margin-bottom: 8px; }
.trade-row label { font-size: 0.9rem; color: #c8b8a0; }
.trade-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.trade-buttons button {
    flex: 1;
    min-width: 60px;
    padding: 6px 8px;
    font-size: 0.9rem;
    border: 1px solid #5a4a3a;
    border-radius: 0;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.1s;
    color: #e8ddd0;
}
.buy-btn { background: #1e4228; }
.buy-btn:hover { background: #2a5a3a; }
.sell-btn { background: #4a2020; }
.sell-btn:hover { background: #5e2a2a; }
.close-btn { background: #2e2620; }
.close-btn:hover { background: #3d3229; }
.reversal-btn { background: #1e3a4a; }
.reversal-btn:hover { background: #2a4a5a; }
.shift-btn { background: #2a1e3a; }
.shift-btn:hover { background: #3a2a4a; }
.hedge-btn { background: #1e3a3a; }
.hedge-btn:hover { background: #2a4a4a; }
.leverage-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 6px;
}
.leverage-btn {
    background: #2a3a1e;
    border: 1px solid #5a4a3a;
    color: #d0e0b8;
    padding: 5px 3px;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.1s;
}
.leverage-btn:hover { background: #3a4a2a; }
.leverage-btn.active { background: #a8c880; color: #1a1a1a; border-color: #e8ddd0; }

.leverage-modal-content {
    min-width: 340px;
    max-width: 480px;
    width: 92%;
}
#leverage-modal-buttons {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}
#leverage-modal-buttons .leverage-btn {
    padding: 10px 4px;
    font-size: 0.95rem;
    min-height: 44px;
}

.tz-list {
    max-height: 340px;
    overflow-y: auto;
    border: 1px solid #4a3a2a;
    background: #17130f;
    margin-top: 6px;
}
.tz-list .tz-item {
    padding: 6px 10px;
    cursor: pointer;
    color: #d8cdb8;
    font-size: 0.9rem;
    border-bottom: 1px solid #231d18;
    border-left: 3px solid transparent;
}
.tz-list .tz-item:hover { background: #2e2620; color: #f5ebe0; }
.tz-list .tz-item.selected {
    background: #2a3a1e;
    color: #f5ebe0;
    border-left-color: #a8c880;
}

#signal-alarm {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2001;
}
#signal-alarm-box {
    padding: 50px 100px;
    border-radius: 16px;
    box-shadow: 0 12px 60px rgba(0,0,0,0.9), 0 0 0 6px rgba(255,255,255,0.15);
    border: 4px solid rgba(255,255,255,0.95);
    text-align: center;
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: #ffffff;
    text-shadow: 3px 3px 10px rgba(0,0,0,0.6);
    cursor: pointer;
    animation: hhllPulse 0.6s ease-out;
    font-family: 'Segoe UI', 'Courier New', monospace;
    min-width: 400px;
    user-select: none;
}
#signal-alarm-box.alarm-long {
    background: linear-gradient(135deg, #0088ff 0%, #0055cc 100%);
}
#signal-alarm-box.alarm-short {
    background: linear-gradient(135deg, #ff0055 0%, #cc0033 100%);
}
#signal-alarm-box .signal-alarm-subtitle {
    font-size: 0.95rem;
    font-weight: bold;
    opacity: 0.9;
    margin-top: 16px;
    letter-spacing: 1.5px;
}
@keyframes hhllPulse {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

#mobile-trade-bar {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: #231d18;
    border-top: 2px solid #4a3a2a;
    flex-shrink: 0;
    position: relative;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

#mobile-trade-status {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    padding: 8px 12px;
    text-align: center;
    background: #1a1511;
    border-top: 2px solid #4a3a2a;
    border-bottom: 2px solid #4a3a2a;
    color: #c8b8a0;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 20;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.5);
}
#mobile-trade-status.show { display: block; }

.mob-trade-buttons {
    display: flex;
    gap: 6px;
}

.mob-trade-buttons button {
    flex: 1;
    min-height: 34px;
    padding: 8px 4px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 2px solid #5a4a3a;
    border-radius: 0;
    color: #e8ddd0;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.08s;
}
.mob-trade-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.mob-trade-buttons .mob-buy { background: #1e4228; }
.mob-trade-buttons .mob-buy:active { background: #2a5a3a; }
.mob-trade-buttons .mob-sell { background: #4a2020; }
.mob-trade-buttons .mob-sell:active { background: #5e2a2a; }
.mob-trade-buttons .mob-close { background: #2e2620; }
.mob-trade-buttons .mob-close:active { background: #3d3229; }
.mob-trade-buttons .mob-shift { background: #2a1e3a; }
.mob-trade-buttons .mob-shift:active { background: #3a2a4a; }
.mob-trade-buttons .mob-hedge { background: #1e3a3a; }
.mob-trade-buttons .mob-hedge:active { background: #2a4a4a; }
.mob-trade-buttons .mob-reversal { background: #1e3a4a; }
.mob-trade-buttons .mob-reversal:active { background: #2a4a5a; }

.mob-trade-buttons.mob-trade-top {
    justify-content: stretch;
    gap: 6px;
}
.mob-trade-buttons .mob-net {
    flex: 0 0 auto;
    min-width: 160px;
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.6px;
    background: #4a2020;
    border-color: #cc4444;
    color: #ffc8c8;
}
.mob-trade-buttons .mob-net.net-on {
    background: #1e4228;
    border-color: #44dd44;
    color: #c8ffc8;
}
.mob-trade-buttons .mob-net:active { filter: brightness(1.15); }

.mob-notional {
    flex: 1;
    min-height: 34px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 2px solid #6a5a4a;
    background: #2a221c;
    color: #f5ebe0;
    font-family: 'Courier New', monospace;
    text-align: right;
    border-radius: 0;
    -moz-appearance: textfield;
    appearance: textfield;
    transition: border-color 0.1s, box-shadow 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.mob-notional::-webkit-outer-spin-button,
.mob-notional::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.mob-notional::placeholder {
    color: #7a6b5a;
    font-weight: normal;
    text-align: center;
}
.mob-notional:focus {
    outline: none;
    border-color: #a8c880;
    box-shadow: 0 0 0 2px rgba(168, 200, 128, 0.28);
}

body.mobile-view #app {
    height: 100vh;
    height: 100dvh;
}

body.mobile-view #header {
    padding: 6px 8px;
    gap: 4px;
}

body.mobile-view #logo {
    font-size: 1rem;
    min-width: auto;
    margin-right: 6px;
    letter-spacing: 0.5px;
}

body.mobile-view #mode-controls {
    gap: 4px;
    flex-wrap: nowrap;
}
body.mobile-view #btn-trade-mode,
body.mobile-view #btn-manual-mode {
    padding: 3px 7px;
    font-size: 0.7rem;
    border-width: 1px;
    line-height: 1.1;
}

body.mobile-view #status-bar {
    font-size: 0.72rem;
    gap: 4px;
    flex-basis: 100%;
}

body.mobile-view #status-bar span {
    padding: 2px 6px;
}

body.mobile-view #status-bar #mode-status {
    padding: 2px 6px !important;
    border-width: 1px !important;
}

body.mobile-view #status-bar #leverage-display {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
body.mobile-view #status-bar #leverage-display:active {
    background: #3d3229;
    border-color: #a8c880;
}

body.mobile-view #controls {
    display: flex !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    width: 100%;
    order: 10;
    padding: 4px 0;
    margin-top: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
body.mobile-view #controls::-webkit-scrollbar { display: none; }
body.mobile-view #controls button {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 0.7rem;
    min-width: auto;
    border-width: 1px;
    line-height: 1.1;
}
body.mobile-view #controls #btn-toggle-net,
body.mobile-view #controls #btn-toggle-hhll,
body.mobile-view #controls #btn-toggle-alarm,
body.mobile-view #controls #btn-toggle-markov,
body.mobile-view #controls #btn-tz {
    min-width: auto;
}
body.mobile-view #controls #tolerance-input {
    flex-shrink: 0;
    width: 54px;
    padding: 4px 6px;
    font-size: 0.7rem;
}

body.mobile-view #right-panel,
body.mobile-view .indicator-wrapper,
body.mobile-view #log-area,
body.mobile-view #minimized-bar {
    display: none !important;
}

body.mobile-view #mobile-trade-bar {
    display: flex;
}

body.mobile-view #main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
body.mobile-view #charts-container {
    flex: 1;
    min-height: 0;
}
body.mobile-view .price-wrapper {
    flex: 1;
    min-height: 0;
    border-bottom: none;
}

body.mobile-view .chart-label {
    min-height: 22px;
    font-size: 0.8rem;
}
body.mobile-view .chart-label .tf-tabs,
body.mobile-view .chart-label .tf-add-btn,
body.mobile-view .chart-label #btn-maximize-price {
    display: none !important;
}
body.mobile-view .chart-label .chart-label-title {
    padding: 0 8px;
}

@media (max-width: 768px) {
    #signal-alarm-box {
        padding: 30px 40px;
        font-size: 1.8rem;
        min-width: 0;
        width: 85%;
        letter-spacing: 1.5px;
    }
    #signal-alarm-box .signal-alarm-subtitle {
        font-size: 0.8rem;
        margin-top: 10px;
    }
    .leverage-modal-content {
        min-width: 0;
        width: 92%;
    }
    #leverage-modal-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    body.mobile-view .mob-trade-buttons button {
        min-height: 30px;
        padding: 6px 4px;
        font-size: 0.8rem;
    }
    body.mobile-view #mobile-trade-bar {
        padding: 5px;
        gap: 4px;
    }
    body.mobile-view .mob-trade-buttons .mob-net {
        min-width: 140px;
    }
}
