* { box-sizing: border-box; }
body {
    margin: 0;
    background: #0b0f18;
    color: #e5e7eb;
    font-family: "Vazirmatn", "Tahoma", sans-serif;
}
a { color: inherit; text-decoration: none; }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; background: #111827; border-bottom: 1px solid #1f2937;
}
.brand { font-weight: bold; font-size: 1.2rem; }
.topbar nav a { margin-inline-start: 18px; color: #9ca3af; }
.topbar nav a:hover { color: #fff; }
.topbar nav a.logout { color: #f87171; }

.content { padding: 20px; max-width: 1200px; margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.conn-status { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #9ca3af; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background: #22c55e; }
.dot-off { background: #ef4444; }
.equity { margin-inline-start: 12px; color: #d1d5db; font-weight: bold; }
.symbol-picker select { background: #1f2937; color: #e5e7eb; border: 1px solid #374151; padding: 6px 10px; border-radius: 6px; }

.chart-box { width: 100%; height: 420px; background: #0f1420; border-radius: 8px; border: 1px solid #1f2937; }
.stoch-chart-box { width: 100%; height: 140px; background: #0f1420; border-radius: 8px; border: 1px solid #1f2937; margin-top: 8px; }
#stoch-panel { display: block; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #9ca3af; cursor: pointer; }
.hint { color: #6b7280; font-size: 0.8rem; margin: 4px 0 10px; }
.hint code { color: #9ca3af; }

.positions-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.positions-table th, .positions-table td { padding: 8px 10px; border-bottom: 1px solid #1f2937; text-align: right; }
.empty-row { text-align: center; color: #6b7280; }
.pnl-pos { color: #22c55e; }
.pnl-neg { color: #ef4444; }

.btn { background: #2563eb; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.btn:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 4px 10px; font-size: 0.85rem; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-box { background: #111827; border: 1px solid #374151; border-radius: 10px; padding: 24px; max-width: 420px; }
.modal-box code { display: block; background: #1f2937; padding: 6px 10px; border-radius: 6px; margin: 8px 0; text-align: center; }
.modal-box input { width: 100%; padding: 8px; margin-bottom: 12px; background: #1f2937; border: 1px solid #374151; color: #fff; border-radius: 6px; }
.modal-actions { display: flex; gap: 8px; }

.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: #0b0f18; }
.login-box { background: #111827; padding: 32px; border-radius: 10px; width: 320px; display: flex; flex-direction: column; gap: 10px; border: 1px solid #1f2937; }
.login-box h1 { text-align: center; margin-bottom: 10px; }
.login-box input { padding: 10px; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: #fff; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.alert-ok { background: #064e3b; color: #6ee7b7; }
.alert-error { background: #450a0a; color: #fca5a5; }

.config-form { display: flex; flex-direction: column; gap: 14px; max-width: 600px; }
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-row label { font-size: 0.85rem; color: #9ca3af; }
.field-row label code { color: #6b7280; }
.field-row input { padding: 8px; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: #fff; }
.hint { color: #6b7280; font-size: 0.85rem; margin-top: 14px; }

.monitor-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 20px; }
.card { background: #111827; border: 1px solid #1f2937; border-radius: 10px; padding: 16px; }
.stat-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.9rem; }
.bar { background: #1f2937; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar-fill { background: #2563eb; height: 100%; }
.badge-warn { font-size: 0.75rem; color: #fbbf24; margin-inline-start: 8px; }
.status-badge { padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; }
.status-running { background: #064e3b; color: #6ee7b7; }
.status-exited { background: #450a0a; color: #fca5a5; }
.status-restarting { background: #422006; color: #fbbf24; }

.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form select, .inline-form input { padding: 6px 10px; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: #fff; }
#candle-run-result { margin-top: 10px; color: #9ca3af; }

.log-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.log-filters select, .log-filters input { padding: 6px 10px; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: #fff; }
.log-filters input[type="text"] { min-width: 220px; }
.level-badge { padding: 2px 10px; border-radius: 10px; font-size: 0.8rem; color: #0b0b0b; font-weight: 600; }
.level-info { background: #3987e5; color: #fff; }
.level-success { background: #0ca30c; color: #fff; }
.level-warning { background: #fab219; }
.level-error { background: #d03b3b; color: #fff; }
.muted-cell { color: #9ca3af; font-size: 0.9rem; }
.nowrap { white-space: nowrap; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.pagination-buttons { display: flex; gap: 8px; }
.pagination-buttons button:disabled { opacity: 0.4; cursor: not-allowed; }
.paper-panel {
    margin: 18px 0;
    padding: 18px;
    border: 1px solid #2f7d68;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(32, 91, 78, .22), rgba(17, 24, 39, .92));
}
.paper-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.paper-panel-head h2 { margin: 0 0 6px; }
.paper-panel-head p { margin: 0; color: #a9b6c8; }
.paper-badge {
    direction: ltr; white-space: nowrap; font-size: 12px; font-weight: 700;
    color: #76e6bd; border: 1px solid #2f9b78; border-radius: 999px; padding: 6px 10px;
}
.paper-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px; margin: 16px 0;
}
.paper-stats > div { background: rgba(8, 15, 27, .65); border-radius: 9px; padding: 11px; }
.paper-stats span { display: block; color: #91a0b5; font-size: 12px; margin-bottom: 5px; }
.paper-stats strong { direction: ltr; display: block; text-align: right; }
.paper-reset-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 14px 0 20px; }
.paper-reset-form label { display: grid; gap: 5px; color: #b9c5d5; font-size: 13px; }
.paper-reset-form input { min-width: 190px; }
.paper-reset-form small { width: 100%; color: #d0a25b; }
.paper-fills-wrap { overflow-x: auto; }
.paper-fills-table { min-width: 850px; }
@media (max-width: 700px) {
    .paper-panel-head { flex-direction: column; }
    .paper-reset-form { display: grid; }
    .paper-reset-form input { min-width: 0; width: 100%; }
}

/* صفحه‌ی وضعیت سیستم */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.status-grid .card h3 { margin: 0 0 12px; font-size: 1rem; color: #e5e7eb; }
.status-grid .positions-table { margin-top: 4px; }
.mode-badge { display: inline-block; padding: 4px 14px; border-radius: 999px; font-weight: 700;
              letter-spacing: 0.5px; margin-bottom: 8px; }
/* رنگ هر حالت = میزان پولی که واقعاً در خطر است. */
.mode-disabled { background: #374151; color: #d1d5db; }
.mode-paper    { background: #064e3b; color: #6ee7b7; }
.mode-testnet  { background: #78350f; color: #fcd34d; }
.mode-live     { background: #7f1d1d; color: #fecaca; }
