/* Споделен стил за арбитраж таблото (/) и страницата за технически анализ
   (/analysis) - едно място за тъмната тема, за да не се разминават. */

* { box-sizing: border-box; }
body {
  margin: 0; padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115; color: #e6e6e6;
}
h1 { font-size: 20px; margin: 0 0 4px 0; }
.subtitle { color: #9aa0a6; font-size: 13px; margin-bottom: 16px; }

/* ---- Горна навигация между двете страници ---- */
.topnav { display: flex; gap: 4px; margin-bottom: 16px; }
.topnav a {
  color: #9aa0a6; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 6px 6px 0 0; border: 1px solid transparent;
}
.topnav a.active {
  color: #e6e6e6; background: #171a21; border-color: #262b36; border-bottom-color: #171a21;
}
.topnav a:hover:not(.active) { color: #e6e6e6; }

.statusbar {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  background: #171a21; border: 1px solid #262b36; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.statusbar b { color: #fff; }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #2ecc71; margin-right: 6px; animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.err { color: #ff6b6b; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid #22262f; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th {
  color: #9aa0a6; font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .03em;
}
tr.flagged { background: #10321f; }
tr.flagged td.spread { color: #4ade80; font-weight: 700; }
tr:hover { background: #1b1f28; }
.venue-symbol { color: #6b7280; font-size: 10.5px; display: block; }
.flag-badge {
  display: inline-block; background: #16a34a; color: white; font-size: 10px;
  padding: 1px 7px; border-radius: 10px; margin-left: 6px;
}
.legend { margin-top: 12px; font-size: 12px; color: #6b7280; }
.empty { color: #9aa0a6; padding: 20px 0; }
td.net-pos { color: #4ade80; font-weight: 700; }
td.net-neg { color: #ff6b6b; }
.net-note { color: #6b7280; font-size: 10.5px; }

.statusbar input[type=number] {
  width: 92px; background: #0f1115; color: #e6e6e6; border: 1px solid #333a48;
  border-radius: 4px; padding: 4px 7px; font-size: 13px; font-weight: 600;
}
.statusbar input[type=number]:focus { outline: none; border-color: #4ade80; }
.statusbar button {
  background: #262b36; color: #e6e6e6; border: 1px solid #333a48; border-radius: 4px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.statusbar button:hover { background: #333a48; }
#budgetStatus { font-size: 11.5px; color: #6b7280; }
#budgetStatus.ok { color: #4ade80; }
#budgetStatus.err { color: #ff6b6b; }

.rsi-ob { color: #ff6b6b; font-weight: 700; }     /* прекупено >70 */
.rsi-os { color: #4ade80; font-weight: 700; }     /* препродадено <30 */
.sig-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; cursor: help;
}
.sig-strong-bull { background: #14532d; color: #4ade80; }
.sig-bull        { background: #16321f; color: #86efac; }
.sig-neutral     { background: #262b36; color: #9aa0a6; }
.sig-bear        { background: #3a1f1f; color: #fca5a5; }
.sig-strong-bear { background: #4c1414; color: #ff6b6b; }
.ticker-link { cursor: pointer; }
.ticker-link:hover { text-decoration: underline; color: #4ade80; }
td.clickable { cursor: pointer; }

/* ---- Страница /analysis ---- */
.analysis-card {
  background: #171a21; border: 1px solid #262b36; border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.analysis-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.analysis-search-row { display: flex; gap: 8px; margin-bottom: 4px; }
.analysis-search-row input[type=text] {
  flex: 1; max-width: 320px; background: #0f1115; color: #e6e6e6;
  border: 1px solid #333a48; border-radius: 4px; padding: 7px 10px; font-size: 13px;
}
.analysis-search-row input[type=text]:focus { outline: none; border-color: #4ade80; }
.analysis-search-row button {
  background: #262b36; color: #e6e6e6; border: 1px solid #333a48; border-radius: 4px;
  padding: 7px 16px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.analysis-search-row button:hover { background: #333a48; }
.analysis-hint { font-size: 11px; color: #6b7280; margin-bottom: 10px; }
.analysis-result { margin-top: 8px; }
.analysis-placeholder { color: #6b7280; font-size: 13px; padding: 8px 0; }
.analysis-placeholder.err { color: #ff6b6b; }
.analysis-header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 10px; padding-bottom: 10px; border-bottom: 1px solid #262b36; margin-bottom: 12px;
}
.analysis-ticker { font-size: 18px; font-weight: 700; margin-right: 10px; }
.sig-badge-lg { font-size: 13px; padding: 5px 14px; }
.analysis-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px;
}
.analysis-group h4 {
  margin: 0 0 6px 0; font-size: 11px; color: #9aa0a6; text-transform: uppercase; letter-spacing: .03em;
}
.ar-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; gap: 8px; }
.ar-label { color: #9aa0a6; }
.ar-value { font-weight: 600; text-align: right; }
.analysis-signals h4 {
  margin: 0 0 8px 0; font-size: 11px; color: #9aa0a6; text-transform: uppercase; letter-spacing: .03em;
}
.signal-line { font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed #22262f; text-align: left; }
.sig-mark {
  display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 3px; font-size: 10px; font-weight: 700; margin-right: 6px;
}
.sig-mark-pos { background: #14532d; color: #4ade80; }
.sig-mark-neg { background: #4c1414; color: #ff6b6b; }
.sig-mark-zero { background: #262b36; color: #9aa0a6; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  background: #0f1115; color: #9aa0a6; border: 1px solid #333a48; border-radius: 14px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.chip:hover { color: #4ade80; border-color: #4ade80; }

@media (max-width: 800px) { .analysis-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .analysis-grid { grid-template-columns: 1fr; } }

/* ---- Пауза/Пусни копче + панел с настройки (на /) ---- */
.scan-toggle {
  border-radius: 4px; padding: 5px 14px; font-size: 12px; font-weight: 700;
  cursor: pointer; border: 1px solid;
}
.scan-toggle.running { background: #14532d; color: #4ade80; border-color: #1f6b3a; }
.scan-toggle.paused  { background: #3a1f1f; color: #fca5a5; border-color: #5a2a2a; }
.scan-toggle:hover { filter: brightness(1.15); }

.settings-panel {
  background: #171a21; border: 1px solid #262b36; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 16px;
}
.settings-row { display: flex; gap: 20px; align-items: end; flex-wrap: wrap; }
.settings-field { display: flex; flex-direction: column; gap: 4px; }
.settings-field label { font-size: 11px; color: #9aa0a6; text-transform: uppercase; letter-spacing: .03em; }
.settings-field input[type=number] {
  width: 110px; background: #0f1115; color: #e6e6e6; border: 1px solid #333a48;
  border-radius: 4px; padding: 6px 8px; font-size: 13px; font-weight: 600;
}
.settings-field input[type=number]:focus { outline: none; border-color: #4ade80; }
.settings-panel button {
  background: #262b36; color: #e6e6e6; border: 1px solid #333a48; border-radius: 4px;
  padding: 7px 16px; font-size: 12.5px; cursor: pointer; font-weight: 600; height: 32px;
}
.settings-panel button:hover { background: #333a48; }
#settingsStatus { font-size: 11.5px; color: #6b7280; }
#settingsStatus.ok { color: #4ade80; }
#settingsStatus.err { color: #ff6b6b; }

/* ---- Страница /tickers ---- */
.ticker-add-card {
  background: #171a21; border: 1px solid #262b36; border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.ticker-add-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.ticker-field { display: flex; flex-direction: column; gap: 4px; }
.ticker-field label { font-size: 11px; color: #9aa0a6; text-transform: uppercase; letter-spacing: .03em; }
.ticker-field-group { display: flex; gap: 4px; align-items: center; }
.ticker-field input[type=text] {
  width: 130px; background: #0f1115; color: #e6e6e6; border: 1px solid #333a48;
  border-radius: 4px; padding: 6px 8px; font-size: 13px;
}
.ticker-field input[type=text]:focus { outline: none; border-color: #4ade80; }
.verify-btn, .ticker-add-row > button, .ticker-remove-btn {
  background: #262b36; color: #e6e6e6; border: 1px solid #333a48; border-radius: 4px;
  padding: 6px 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.verify-btn:hover, .ticker-add-row > button:hover { background: #333a48; }
.verify-result { font-size: 11px; min-width: 90px; }
.verify-result.ok { color: #4ade80; }
.verify-result.err { color: #ff6b6b; }
.ticker-remove-btn { color: #fca5a5; border-color: #5a2a2a; padding: 4px 10px; }
.ticker-remove-btn:hover { background: #3a1f1f; }
#tickerAddStatus { font-size: 12px; margin-top: 8px; }
#tickerAddStatus.ok { color: #4ade80; }
#tickerAddStatus.err { color: #ff6b6b; }

/* ---- Режим/ADX бадж + бектест (на /analysis) ---- */
.regime-badge {
  font-size: 12.5px; color: #e6e6e6; background: #0f1115; border: 1px solid #262b36;
  border-radius: 6px; padding: 6px 10px; margin-bottom: 14px;
}
.backtest-result { margin-top: 16px; }
.backtest-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.backtest-table th, .backtest-table td { padding: 7px 8px; border-bottom: 1px solid #22262f; text-align: right; }
.backtest-table th:first-child, .backtest-table td:first-child { text-align: left; }
.backtest-table th {
  color: #9aa0a6; font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em;
}
.backtest-baseline { margin-top: 12px; font-size: 12px; color: #9aa0a6; line-height: 1.6; }
.backtest-note { margin-top: 10px; font-size: 11px; color: #6b7280; font-style: italic; }

/* ---- Страница /login ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  margin: -24px; padding: 24px;
}
.login-card {
  background: #171a21; border: 1px solid #262b36; border-radius: 10px;
  padding: 32px 28px; width: 100%; max-width: 320px; text-align: center;
}
.login-title { font-size: 19px; margin: 0 0 4px 0; }
.login-tagline {
  font-size: 16px; letter-spacing: .06em; text-transform: uppercase;
  color: #c0392b; font-weight: 700; margin: 4px 0 18px 0; line-height: 1.4;
}
.login-card .subtitle { margin-bottom: 20px; }
.login-input {
  width: 100%; background: #0f1115; color: #e6e6e6; border: 1px solid #333a48;
  border-radius: 6px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px;
  text-align: center; letter-spacing: .1em;
}
.login-input:focus { outline: none; border-color: #4ade80; }
.login-input:disabled { opacity: .5; }
.login-btn {
  width: 100%; background: #16a34a; color: white; border: none; border-radius: 6px;
  padding: 10px 12px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.login-btn:hover:not(:disabled) { background: #15803d; }
.login-btn:disabled { background: #3a1f1f; color: #fca5a5; cursor: not-allowed; }
.login-error {
  background: #3a1f1f; color: #fca5a5; border: 1px solid #5a2a2a; border-radius: 6px;
  padding: 8px 10px; font-size: 12.5px; margin-bottom: 14px;
}
.login-hint { margin-top: 14px; font-size: 11px; color: #6b7280; }
.logout-link { margin-left: auto; color: #6b7280 !important; font-weight: 400 !important; }
