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

:root {
    --bg: #0a0a0f;
    --bg-card: #14141f;
    --bg-input: #1a1a2e;
    --text: #e0e0e0;
    --text-muted: #6b6b80;
    --primary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2a2a3e;
    --accent: #818cf8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    gap: 1.5rem;
}

.logo {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-small {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

input[type="password"] {
    width: 100%;
    max-width: 320px;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="password"]:focus {
    border-color: var(--primary);
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.2em;
}

.btn {
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    padding: 0.75rem 1.5rem;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-large {
    width: 100%;
    padding: 1.1rem;
    font-size: 1.1rem;
    border-radius: 14px;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 8px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px dashed var(--border); }
.btn-pause { background: #e67e22; color: #fff; border: 1px solid #e67e22; animation: pulse-pause 2s infinite; }
@keyframes pulse-pause { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

header {
    padding: 1rem 1.2rem 0.5rem;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status.running {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status.running .status-dot {
    background: var(--success);
    animation: pulse 1.5s infinite;
}

.status.stopped {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status.stopped .status-dot { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.mode-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.7rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.mode-badge.dry-run {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.mode-badge.live {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    padding: 1rem 1.2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-card.full-width { grid-column: 1 / -1; }

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-breakdown {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-top: -2px;
}

.confluence-section {
    padding: 0.5rem 1.2rem;
}

.confluence-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.confluence-bar-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
}

.confluence-bar {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s ease, background 0.3s;
    width: 0%;
}

.confluence-bar.weak { background: var(--danger); }
.confluence-bar.moderate { background: var(--warning); }
.confluence-bar.strong { background: var(--success); }

.confluence-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.signal-bull { color: var(--success); font-weight: 700; }
.signal-bear { color: var(--danger); font-weight: 700; }
.signal-none { color: var(--text-muted); }

.timeframe-section {
    padding: 0.8rem 1.2rem;
}

.timeframe-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tf-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.tf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    transition: border-color 0.3s, background 0.3s;
}

.tf-card.bullish {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.08);
}

.tf-card.bearish {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

.tf-card.neutral {
    border-color: var(--border);
}

.tf-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.tf-arrow {
    font-size: 1.2rem;
    font-weight: 900;
    line-height: 1;
}

.tf-card.bullish .tf-arrow { color: var(--success); }
.tf-card.bearish .tf-arrow { color: var(--danger); }
.tf-card.neutral .tf-arrow { color: var(--text-muted); }

.tf-detail {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.equity-section {
    padding: 0.5rem 1.2rem;
}

.equity-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.equity-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.equity-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: center;
}

.equity-stat .stat-label {
    font-size: 0.6rem;
}

.equity-stat .stat-value {
    font-size: 1rem;
}

.equity-chart-container {
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
}

.equity-chart-container canvas {
    display: block;
    width: 100%;
}

.position-section {
    padding: 0.5rem 1.2rem;
}

.position-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.position-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.8rem;
}

.pos-header {
    font-weight: 800;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.pos-header.pos-long { color: var(--success); }
.pos-header.pos-short { color: var(--danger); }

.pos-field {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.8rem;
}

.pos-field span:first-child { color: var(--text-muted); }
.pos-field span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

.trail-sl-pct {
    font-size: 0.7em;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.3em;
}

.pnl-positive { color: var(--success); }
.pnl-negative { color: var(--danger); }

.btn-close-pos {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-pos:hover, .btn-close-pos:active {
    background: var(--danger);
    color: #fff;
}

.btn-refresh-header {
    padding: 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
}

.controls {
    padding: 0.8rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.cooldown-controls {
    grid-template-columns: auto auto 1fr;
    align-items: center;
}

.cooldown-status {
    font-size: 0.75rem;
    color: var(--warning);
    text-align: right;
}

.position-card.closing {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.trade-history-section {
    padding: 0.5rem 1.2rem;
}

.trade-history-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trade-history {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
}

.history-row {
    display: grid;
    grid-template-columns: 70px 40px 1fr 1fr 50px;
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
    align-items: center;
}

.history-row:last-child { border-bottom: none; }

.hist-side {
    font-weight: 700;
    font-size: 0.7rem;
}

.hist-entry {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.hist-pnl {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.hist-status {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: right;
}

.logs-section {
    padding: 0 1.2rem 2rem;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.logs-header h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.logs-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.7rem;
    line-height: 1.7;
    scroll-behavior: smooth;
}

.logs-container .log-line {
    padding: 0.15rem 0;
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
    word-break: break-all;
}

.logs-container .log-line:last-child { border-bottom: none; }

.log-line.trade { color: var(--success); }
.log-line.error { color: var(--danger); }
.log-line.system { color: var(--accent); }
.log-line.analysis { color: var(--text-muted); }

.header-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.exchange-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.pairs-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(107, 107, 128, 0.15);
    color: var(--text-muted);
}

.tf-pair-label {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 400;
}

.scanner-section {
    padding: 0.5rem 1.2rem;
}

.scanner-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scanner-grid {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.scan-row {
    display: grid;
    grid-template-columns: 1fr 30px 45px 1fr 60px;
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
    align-items: center;
}

.scan-row:last-child { border-bottom: none; }

.scan-row.scan-bull, .scan-row-wrap.scan-bull { border-left: 2px solid var(--success); }
.scan-row.scan-bear, .scan-row-wrap.scan-bear { border-left: 2px solid var(--danger); }
.scan-row.scan-neutral, .scan-row-wrap.scan-neutral { border-left: 2px solid var(--text-muted); }

.scan-pair {
    font-weight: 700;
    font-size: 0.75rem;
}

.scan-arrow {
    font-weight: 900;
    text-align: center;
}

.scan-bull .scan-arrow { color: var(--success); }
.scan-bear .scan-arrow { color: var(--danger); }
.scan-neutral .scan-arrow { color: var(--text-muted); }

.scan-score {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
}

.scan-price {
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    text-align: right;
}

.scan-vol {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: right;
}

.scanner-mode-label {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--accent);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.5rem;
    opacity: 0.85;
}

.scan-row-wrap {
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
    cursor: pointer;
}
.scan-row-wrap:last-child { border-bottom: none; }

.scan-row-wrap .scan-row {
    border-bottom: none;
}

.scan-signals {
    display: none;
    padding: 0.2rem 0.5rem 0.4rem 0.5rem;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.scan-row-wrap.expanded .scan-signals {
    display: flex;
}

.scan-signal-tag {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    line-height: 1.2;
}

.scan-signal-tag.sig-bull {
    background: rgba(0, 200, 83, 0.15);
    color: var(--success);
}

.scan-signal-tag.sig-bear {
    background: rgba(255, 82, 82, 0.15);
    color: var(--danger);
}

.positions-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-line.scan { color: var(--warning); }

.muted { color: var(--text-muted); }

.hist-pair {
    font-weight: 600;
    font-size: 0.68rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combo-badge {
    display: inline-block;
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
    font-size: 0.5rem;
    font-weight: 700;
    background: rgba(245, 158, 11, 0.25);
    color: var(--warning);
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.rsi-badge {
    display: inline-block;
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
    font-size: 0.5rem;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.25);
    color: #818cf8;
    vertical-align: middle;
    letter-spacing: 0.03em;
    margin-left: 2px;
}

.tier-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
    margin-left: 0.3rem;
}

.tier-entry {
    background: rgba(107, 107, 128, 0.2);
    color: var(--text-muted);
}

.tier-momentum {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.tier-trend {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.tier-power {
    background: rgba(239, 68, 68, 0.25);
    color: #ff6b6b;
    animation: power-pulse 2s ease-in-out infinite;
}

@keyframes power-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.log-line.power {
    color: #ff6b6b;
    font-weight: 700;
}

footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.pos-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-adjust-pos {
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-adjust-pos:hover, .btn-adjust-pos:active {
    background: var(--primary);
    color: #fff;
}

.pos-buttons-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.btn-tp-pos {
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 1px solid var(--positive);
    background: var(--positive);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.btn-tp-pos:hover, .btn-tp-pos:active {
    background: #00c853;
    border-color: #00c853;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 360px;
}

.modal-content h3 {
    margin: 0 0 0.3rem;
    color: var(--text);
    font-size: 1.1rem;
}

.modal-pair {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0 0 1rem;
}

.modal-field {
    margin-bottom: 1rem;
}

.modal-field label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}

.modal-field input {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    box-sizing: border-box;
}

.modal-field input:focus {
    border-color: var(--primary);
    outline: none;
}

.modal-mode-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.modal-mode-btn {
    flex: 1;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

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

.modal-preview {
    display: block;
    font-size: 0.75rem;
    color: var(--success);
    margin-top: 0.2rem;
    font-variant-numeric: tabular-nums;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.balance-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.balance-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.balance-select {
    flex: 1;
    padding: 0.5rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b6b80'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.balance-select:focus {
    border-color: var(--primary);
    outline: none;
}

.balance-select option {
    background: var(--bg-card);
    color: var(--text);
}

.stepper-row {
    grid-template-columns: 1fr 1fr;
    align-items: start;
}

.stepper-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stepper-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-input);
}

.stepper-btn {
    width: 40px;
    height: 36px;
    border: none !important;
    border-radius: 0 !important;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.stepper-value {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 30px;
}

.stepper-info {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.strategy-section {
    padding: 0.5rem 1.2rem;
}

.strategy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.6rem 0;
    -webkit-tap-highlight-color: transparent;
}

.strategy-header h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.strategy-summary {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--accent);
    text-transform: none;
    letter-spacing: 0;
}

.strategy-toggle {
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.strategy-panel {
    padding-bottom: 0.8rem;
}

.strategy-presets {
    margin-bottom: 0.8rem;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.strategy-group {
    margin-bottom: 0.8rem;
}

.count-badge {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--accent);
}

.toggle-grid {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

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

.toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
}

.toggle-btn.active {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.12);
    color: var(--text);
}

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

.toggle-name {
    font-size: 0.75rem;
    font-weight: 700;
}

.toggle-cat {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toggle-btn.active .toggle-cat {
    color: var(--success);
}

.toggle-note {
    font-size: 0.5rem;
    color: var(--warning, #f59e0b);
    display: block;
    margin-top: 1px;
}

.toggle-desc {
    font-size: 0.48rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
    opacity: 0.7;
    line-height: 1.2;
}

.smart-scanner-group {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 0.8rem;
}
.smart-scanner-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.switch-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.switch-track {
    display: inline-block;
    width: 52px;
    height: 28px;
    background: #444;
    border-radius: 14px;
    position: relative;
    transition: background 0.25s ease;
}
.switch-track.active {
    background: var(--success, #22c55e);
}
.switch-thumb {
    display: block;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch-track.active .switch-thumb {
    transform: translateX(24px);
}
.switch-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    min-width: 100px;
}
.switch-container.saved .switch-label {
    color: var(--success, #22c55e);
}
.smart-scanner-desc {
    font-size: 0.7rem;
    color: var(--text-muted, #888);
    line-height: 1.3;
}

.strategy-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
    color: var(--danger);
    margin-bottom: 0.5rem;
}

.sticky-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 100;
    justify-content: center;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
}

.btn-bottom {
    flex: 1;
    max-width: 160px;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    font-weight: 800;
    border-radius: 10px;
}

.bottom-spacer {
    height: 70px;
}

.tf-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tf-header-row h3 {
    margin: 0;
    flex-shrink: 0;
}

.pair-inspector-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 120px;
    max-width: 180px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.pair-inspector-select:focus {
    border-color: var(--primary);
}

.pair-inspector-select:disabled {
    opacity: 0.5;
    cursor: wait;
}

.tf-loading {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.trading-controls-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 0;
    border: 1px solid var(--border);
    margin-bottom: 0.8rem;
}

.trading-controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.trading-controls-header h3 {
    margin: 0;
    font-size: 0.85rem;
}

.trading-controls-panel {
    padding: 0 1rem 1rem;
}

.controls-compact-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.compact-control {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.compact-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.controls-secondary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.anchor-pairs-row {
    align-items: center;
    flex-wrap: nowrap;
}

.anchor-pairs-input {
    background: var(--bg-input, #1a1a2e);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.7rem;
    padding: 6px 8px;
    font-family: monospace;
}

.anchor-pairs-input:focus {
    outline: none;
    border-color: var(--accent);
}

.manual-trade-row {
    flex-wrap: wrap;
    gap: 0.4rem;
}

.manual-trade-msg {
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 5px;
    margin: 2px 0 0;
    font-weight: 600;
}

.manual-trade-success {
    background: rgba(0, 200, 80, 0.12);
    color: #00c850;
    border: 1px solid rgba(0, 200, 80, 0.3);
}

.manual-trade-error {
    background: rgba(255, 80, 80, 0.12);
    color: #ff5050;
    border: 1px solid rgba(255, 80, 80, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #00c850 0%, #009940 100%);
    border-color: #00c850;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.btn-success:hover {
    background: linear-gradient(135deg, #00e060 0%, #00bb48 100%);
    border-color: #00e060;
}

.btn-success:disabled {
    background: #2a4a2a;
    border-color: #3a6a3a;
    color: #668866;
    cursor: not-allowed;
}

.scan-row-wrap {
    min-height: 44px;
}

.scan-row {
    min-height: 40px;
    align-items: center;
}

.trade-journal-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 12px;
    border: 1px solid var(--border);
}

.journal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
}

.journal-header h3 { font-size: 0.9rem; }

.journal-stats { margin-bottom: 12px; }

.journal-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.journal-stat {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.journal-stat .stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.journal-stat .stat-value {
    font-size: 0.8rem;
    font-weight: 600;
}

.journal-entries {
    max-height: 500px;
    overflow-y: auto;
}

.journal-entry {
    background: var(--bg-input);
    border-radius: 8px;
    margin-bottom: 6px;
    border-left: 3px solid var(--border);
    cursor: pointer;
    overflow: hidden;
}

.journal-entry.outcome-win { border-left-color: var(--success); }
.journal-entry.outcome-loss { border-left-color: var(--danger); }

.journal-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: wrap;
}

.journal-pair {
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 80px;
}

.journal-outcome {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-muted);
    text-transform: uppercase;
}

.journal-pnl {
    font-weight: 700;
    font-size: 0.8rem;
}

.journal-duration {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.journal-entry-details {
    display: none;
    padding: 0 10px 10px;
    font-size: 0.7rem;
}

.journal-entry.expanded .journal-entry-details {
    display: block;
}

.journal-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.journal-detail-row span { flex: 1; }

.journal-reason {
    padding: 6px 0 4px;
    color: var(--accent);
    font-size: 0.65rem;
    word-break: break-word;
}

.journal-tf-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 6px;
}

.journal-tf-tag {
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--bg-card);
}

.journal-tf-tag.sig-bull { color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.journal-tf-tag.sig-bear { color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.journal-tf-tag.sig-neutral { color: var(--text-muted); border: 1px solid var(--border); }

.fast-scan-badge {
    color: #fbbf24;
    font-size: 0.65rem;
    margin-right: 3px;
}

.scan-row-wrap.fast-scan-active {
    border-left: 2px solid #fbbf24;
}

.journal-patterns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0;
}

.journal-pattern-tag {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.bearish-alerts-section {
    background: var(--card);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.bearish-alerts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.bearish-alerts-title {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-count-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}
.bear-pause-status {
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
    animation: pulse-glow 1.5s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.bearish-alerts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.bearish-alert-card {
    background: rgba(30, 30, 40, 0.6);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    border-left: 3px solid var(--warning);
}
.bearish-alert-card.alert-strong {
    border-left-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.bearish-alert-card.alert-moderate {
    border-left-color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
}
.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}
.alert-pair {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
}
.alert-severity-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.alert-severity-badge.alert-strong {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}
.alert-severity-badge.alert-moderate {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}
.alert-card-body {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.75rem;
    color: var(--muted);
}
.alert-stat {
    font-weight: 600;
}
.alert-time {
    margin-left: auto;
    font-size: 0.65rem;
}
.alert-card-details {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
    font-size: 0.65rem;
    color: var(--muted);
}
.alert-patterns {
    color: var(--danger);
    font-weight: 600;
}
.alert-indicators {
    color: var(--warning);
    font-size: 0.6rem;
    word-break: break-all;
}
.alert-tfs {
    color: var(--accent);
}
.bear-config-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.bearish-alerts-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
.alert-history-panel {
    max-height: 200px;
    overflow-y: auto;
}
.alert-history-entry {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--muted);
}
.alert-history-entry.alert-strong {
    border-left: 2px solid var(--danger);
}
.alert-history-entry.alert-moderate {
    border-left: 2px solid var(--warning);
}

.backtest-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.backtest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.backtest-header h3 {
    margin: 0;
    font-size: 0.9rem;
}
.backtest-panel {
    margin-top: 0.75rem;
}
.backtest-config {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.backtest-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.backtest-row .compact-control {
    flex: 1;
}
.backtest-progress {
    margin-top: 0.75rem;
    text-align: center;
}
.backtest-progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}
.backtest-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.backtest-error-msg {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}
.backtest-no-trades {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #6b6b80;
    font-size: 0.9rem;
}
.backtest-results {
    margin-top: 0.75rem;
}
.backtest-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.backtest-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    font-size: 0.75rem;
}
.backtest-stat span:first-child {
    color: var(--muted);
}
.backtest-stat span:last-child {
    font-weight: 600;
}
.backtest-equity-container {
    margin: 0.5rem 0;
    border-radius: 12px;
    overflow: hidden;
}
.backtest-trades-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.5rem;
}
.bt-trade-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.5rem;
    font-size: 0.65rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.bt-trade-header, .bt-trade-prices, .bt-trade-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bt-trade-signals {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.15rem;
    padding-top: 0.2rem;
    border-top: 1px solid rgba(255,255,255,0.03);
}
.bt-trade-dates {
    color: var(--muted);
}
.bt-trade-reason {
    color: var(--muted);
    font-size: 0.6rem;
}
.bt-history-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.65rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    align-items: center;
}

@media (max-width: 480px) {
    .backtest-row {
        grid-template-columns: 1fr 1fr;
    }
    .backtest-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .bt-history-row {
        grid-template-columns: 1fr auto auto auto;
        font-size: 0.6rem;
    }
    .bt-history-row > span:last-child {
        display: none;
    }
}

.bt-chk {
    font-size: 11px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    background: var(--card-bg);
    border-radius: 4px;
    cursor: pointer;
}
.bt-chk input { margin: 0; width: 13px; height: 13px; }

.combo-stats-section {
    margin: 0.8rem 0.8rem 0;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
}

.combo-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.combo-stats-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.combo-stats-panel {
    padding: 0 0.8rem 0.8rem;
}

.combo-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.62rem;
}

.combo-stats-table th {
    text-align: left;
    padding: 4px 6px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 0.04em;
}

.combo-stats-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

.combo-stats-table tr:last-child td {
    border-bottom: none;
}

.combo-name {
    font-family: monospace;
    font-size: 0.58rem;
    color: var(--text-secondary);
    max-width: 160px;
    word-break: break-all;
}

.combo-trades, .combo-winrate {
    text-align: center;
    min-width: 40px;
}

.combo-pnl {
    text-align: right;
    font-weight: 600;
}

.combo-row-bad td {
    color: var(--danger, #ef4444);
    opacity: 0.85;
}

.combo-row-good td {
    color: var(--success, #22c55e);
    opacity: 0.85;
}

.combo-row-bad .combo-name,
.combo-row-good .combo-name {
    color: inherit;
}

@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .tf-grid { grid-template-columns: repeat(8, 1fr); }
    .logs-container { max-height: 600px; font-size: 0.75rem; }
    .toggle-grid-3 { grid-template-columns: repeat(4, 1fr); }
    .sticky-bottom-bar { justify-content: center; }
    .btn-bottom { max-width: 200px; }
    .journal-stat-row { grid-template-columns: repeat(6, 1fr); }
    .bearish-alerts-container { grid-template-columns: repeat(2, 1fr); }
    .backtest-summary { grid-template-columns: repeat(4, 1fr); }
    .backtest-row { grid-template-columns: 1fr 1fr 1fr; }
}
