/* ─── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0d1117; color: #e6edf3; line-height: 1.5; }
a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ─── Layout ───────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #161b22; border-right: 1px solid #30363d; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.main { margin-left: 220px; flex: 1; min-height: 100vh; }
.header { background: #161b22; border-bottom: 1px solid #30363d; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.content { padding: 24px; }

/* ─── Sidebar ──────────────────────────────────────────────────────── */
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid #30363d; }
.sidebar-logo .logo-title { font-size: 16px; font-weight: 700; color: #f0f6fc; }
.sidebar-logo .logo-sub { font-size: 11px; color: #8b949e; margin-top: 2px; }
.nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #8b949e; font-size: 13px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { color: #e6edf3; background: #21262d; }
.nav-item.active { color: #58a6ff; background: #161b22; border-left-color: #58a6ff; }
.nav-item .nav-icon { font-size: 16px; width: 20px; }
.sidebar-bottom { padding: 12px 16px; border-top: 1px solid #30363d; }
.bot-status-badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.bot-status-badge.paused  { background: #21262d; color: #8b949e; }
.bot-status-badge.auto    { background: #0d2214; color: #3fb950; }
.bot-status-badge.manual  { background: #251d0e; color: #e3b341; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.paused  { background: #8b949e; }
.status-dot.active  { background: #3fb950; animation: pulse 2s infinite; }
.status-dot.manual  { background: #e3b341; }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:0.4} }

/* ─── Cards ────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 20px; }
.card-title { font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.card-value { font-size: 26px; font-weight: 700; color: #f0f6fc; }
.card-sub { font-size: 12px; color: #8b949e; margin-top: 4px; }
.card-value.positive { color: #3fb950; }
.card-value.negative { color: #f85149; }

/* ─── Tables ───────────────────────────────────────────────────────── */
.table-wrap { background: #161b22; border: 1px solid #30363d; border-radius: 10px; overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid #30363d; display: flex; align-items: center; justify-content: space-between; }
.table-header h3 { font-size: 14px; font-weight: 600; color: #f0f6fc; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #30363d; font-weight: 600; }
td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #21262d; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #1c2128; }

/* ─── Badges ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-buy     { background: #0d2214; color: #3fb950; }
.badge-sell    { background: #2c0f0f; color: #f85149; }
.badge-hold    { background: #251d0e; color: #e3b341; }
.badge-avoid   { background: #2c0f0f; color: #f85149; }
.badge-open    { background: #0c2d6b; color: #58a6ff; }
.badge-closed  { background: #161b22; color: #8b949e; border: 1px solid #30363d; }
.badge-stopped { background: #2c0f0f; color: #f85149; }
.badge-tp      { background: #0d2214; color: #3fb950; }
.badge-sl      { background: #2c0f0f; color: #f85149; }
.badge-manual  { background: #251d0e; color: #e3b341; }

/* ─── Buttons ──────────────────────────────────────────────────────── */
.btn { padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; border: 1px solid transparent; transition: all 0.15s; }
.btn-primary  { background: #238636; color: #fff; border-color: #2ea043; }
.btn-primary:hover  { background: #2ea043; }
.btn-danger   { background: #da3633; color: #fff; border-color: #f85149; }
.btn-danger:hover   { background: #f85149; }
.btn-outline  { background: transparent; color: #8b949e; border-color: #30363d; }
.btn-outline:hover  { color: #f0f6fc; border-color: #8b949e; }
.btn-confirm  { background: #0d2214; color: #3fb950; border: 1px solid #238636; }
.btn-confirm:hover  { background: #238636; color: #fff; }
.btn-reject   { background: #2c0f0f; color: #f85149; border: 1px solid #da3633; }
.btn-reject:hover   { background: #da3633; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Mode switcher ────────────────────────────────────────────────── */
.mode-switcher { display: flex; gap: 6px; }
.mode-btn { padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid #30363d; background: transparent; color: #8b949e; transition: all 0.15s; }
.mode-btn.active-auto   { background: #0d2214; color: #3fb950; border-color: #238636; }
.mode-btn.active-manual { background: #251d0e; color: #e3b341; border-color: #9e6a03; }
.mode-btn.active-paused { background: #21262d; color: #8b949e; border-color: #6e7681; }
.mode-btn:hover { color: #e6edf3; border-color: #8b949e; }
.network-badge { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.network-badge.testnet { background: #251d0e; color: #e3b341; }
.network-badge.real    { background: #0d2214; color: #3fb950; }

/* ─── Signals ──────────────────────────────────────────────────────── */
.signal-card { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.signal-card.pending { border-color: #9e6a03; }
.signal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.signal-symbol { font-size: 16px; font-weight: 700; color: #f0f6fc; }
.signal-confidence { font-size: 12px; color: #8b949e; margin-left: auto; }
.signal-reasoning { font-size: 13px; color: #8b949e; margin-bottom: 10px; line-height: 1.5; }
.signal-actions { display: flex; gap: 8px; margin-top: 12px; }
.confidence-bar { height: 4px; background: #21262d; border-radius: 2px; margin: 6px 0; overflow: hidden; }
.confidence-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* ─── Forms ────────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.form-group input, .form-group select { width: 100%; padding: 8px 12px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #e6edf3; font-size: 13px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #58a6ff; }
.form-section { background: #161b22; border: 1px solid #30363d; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.form-section h3 { font-size: 14px; font-weight: 600; color: #f0f6fc; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid #30363d; }

/* ─── Toggle ───────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #21262d; border-radius: 22px; cursor: pointer; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; background: #8b949e; border-radius: 50%; top: 3px; left: 3px; transition: 0.2s; }
.toggle input:checked + .toggle-slider { background: #238636; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

/* ─── Logs ─────────────────────────────────────────────────────────── */
.log-container { background: #0d1117; border: 1px solid #30363d; border-radius: 10px; height: 500px; overflow-y: auto; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; padding: 12px; }
.log-line { padding: 2px 0; line-height: 1.6; }
.log-time { color: #484f58; }
.log-service { color: #58a6ff; }
.log-msg.info  { color: #8b949e; }
.log-msg.warn  { color: #e3b341; }
.log-msg.error { color: #f85149; }
.log-msg.debug { color: #6e7681; }

/* ─── Ticker bar ───────────────────────────────────────────────────── */
.ticker-bar { display: flex; gap: 20px; flex-wrap: wrap; }
.ticker-item { display: flex; align-items: center; gap: 6px; }
.ticker-symbol { font-size: 12px; color: #8b949e; font-weight: 600; }
.ticker-price { font-size: 13px; font-weight: 700; color: #f0f6fc; }
.ticker-change { font-size: 11px; }
.ticker-change.pos { color: #3fb950; }
.ticker-change.neg { color: #f85149; }

/* ─── P&L colors ───────────────────────────────────────────────────── */
.pnl-pos { color: #3fb950; font-weight: 600; }
.pnl-neg { color: #f85149; font-weight: 600; }

/* ─── Page title ───────────────────────────────────────────────────── */
.page-title { font-size: 20px; font-weight: 700; color: #f0f6fc; margin-bottom: 20px; }
.page-subtitle { font-size: 13px; color: #8b949e; margin-top: -14px; margin-bottom: 20px; }

/* ─── Empty state ──────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px; color: #8b949e; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Alert ────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-info    { background: #0c2d6b; color: #58a6ff; border: 1px solid #1f6feb; }
.alert-success { background: #0d2214; color: #3fb950; border: 1px solid #238636; }
.alert-warning { background: #251d0e; color: #e3b341; border: 1px solid #9e6a03; }
.alert-danger  { background: #2c0f0f; color: #f85149; border: 1px solid #da3633; }

/* ─── Mobile burger button (скрыта на десктопе) ────────────────────── */
.burger-btn {
  display: none;
  background: #161b22;
  border: 1px solid #30363d;
  color: #e6edf3;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* ─── Responsive: планшет ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card-value { font-size: 22px; }
  .content { padding: 18px; }
  th, td { padding: 10px 12px; font-size: 12.5px; }
}

/* ─── Responsive: мобилка ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar уезжает за экран, открывается бургером */
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }

  /* Бургер в хедере */
  .burger-btn { display: block; }

  /* Хедер адаптивно */
  .header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .ticker-bar {
    order: 3;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .ticker-bar::-webkit-scrollbar { height: 4px; }
  .ticker-bar::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

  /* Content — меньше паддинга */
  .content { padding: 12px; }
  .page-title { font-size: 18px; margin-bottom: 12px; }

  /* Карточки — в одну колонку */
  .cards { grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
  .card { padding: 14px; }
  .card-value { font-size: 20px; }

  /* Таблицы — горизонтальный скролл */
  .table-wrap { border-radius: 8px; }
  .table-wrap > table,
  .table-wrap > div > table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  th, td { padding: 8px 10px; font-size: 12px; }

  /* Формы */
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  .form-group input, .form-group select, .form-group textarea {
    font-size: 16px; /* iOS не зумит при фокусе */
  }
  .form-section { padding: 14px; }

  /* Кнопки побольше — удобнее тапать */
  .btn { padding: 10px 14px; font-size: 14px; }
  .btn-sm { padding: 7px 10px; font-size: 12px; }

  /* Mode switcher в одну колонку */
  .mode-switcher { flex-wrap: wrap; width: 100%; }
  .mode-btn { flex: 1; min-width: 80px; }

  /* Strategies page — колонки друг под другом */
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Header user — меньше */
  #headerUser { font-size: 11px; }
  .network-badge { font-size: 10px; padding: 3px 7px; }
}

/* ─── Очень маленькие экраны ──────────────────────────────────────── */
@media (max-width: 480px) {
  html { font-size: 13px; }
  .sidebar { width: 240px; }
  .content { padding: 10px; }
  .card { padding: 12px; }
  .card-value { font-size: 18px; }
  .page-title { font-size: 16px; }

  /* Bot mode buttons на полной ширине */
  .mode-switcher { flex-direction: column; }
  .mode-btn { width: 100%; }
}
