/* Gate.io Bot Dashboard — BotControl GUI 다크 테마와 일치 */
:root {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-tertiary:   #21262d;
  --text-primary:  #e6edf3;
  --text-muted:    #8b949e;
  --border:        #30363d;
  --accent-blue:   #1f6feb;
  --accent-green:  #3fb950;
  --accent-red:    #f85149;
  --accent-amber:  #d29922;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.meta { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.meta #last-updated { color: var(--text-muted); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok   { background: var(--accent-green); }
.dot-err  { background: var(--accent-red);   }
.dot-idle { background: var(--text-muted);   }

button {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
button:hover { background: #30363d; }
button.primary { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
button.primary:hover { background: #388bfd; }

/* 슬롯 그리드 */
main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  padding: 16px 20px;
}

.slot-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slot-card[data-state="running"]  { border-color: var(--accent-green); }
.slot-card[data-state="stopped"]  { border-color: var(--border); }
.slot-card[data-state="paused"]   { border-color: var(--accent-amber); }
.slot-card[data-state="error"]    { border-color: var(--accent-red); border-width: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tag {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.tag-demo { background: var(--accent-blue); color: #fff; padding: 3px 10px; border-radius: 8px; font-weight: 600; }
.tag-live { background: var(--accent-red);  color: #fff; padding: 3px 10px; border-radius: 8px; font-weight: 600; }

.nick { font-size: 15px; font-weight: 600; }
.strat { color: var(--text-muted); font-size: 12px; }

.state-badge { font-size: 12px; }
.state-running { color: var(--accent-green); font-weight: 600; }
.state-stopped { color: var(--text-muted); }
.state-paused  { color: var(--accent-amber); font-weight: 600; }

.risk-safe { color: var(--accent-green); font-weight: 600; }
.risk-warn { color: var(--accent-amber); font-weight: 600; }
.risk-dang { color: var(--accent-red);   font-weight: 600; }

.pnl-big {
  font-size: 17px;
  font-weight: 600;
}
.pnl-pos { color: var(--accent-green); }
.pnl-neg { color: var(--accent-red); }

.fee-line { font-size: 11px; color: var(--text-muted); }

/* 표 — 슬롯 내 sub-section */
.tbl {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: grid;
  gap: 0;
  padding: 4px 6px;
}
.tbl-head {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
}
.tbl-cell {
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  padding: 1px 4px;
}
.cell-pos { color: var(--accent-green); font-weight: 600; }
.cell-neg { color: var(--accent-red);   font-weight: 600; }
.cell-long  { color: var(--accent-blue); }
.cell-short { color: var(--accent-red);  }

/* Position 표: 4열 (Side / Margin / Amount / Avg) */
.tbl.pos { grid-template-columns: 1fr 1fr 1fr 1fr; }
/* Side PnL: 2열 */
.tbl.side { grid-template-columns: 1fr 1fr; }
/* Asset: 3열 */
.tbl.asset { grid-template-columns: 1fr 1fr 1fr; }
/* 누적: 4열 */
.tbl.totals { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* 빈 / 에러 상태 */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.error-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-red);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 100;
}

.hidden { display: none !important; }

/* 모달 */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  width: min(440px, 90vw);
}
.modal-card h2 { margin: 0 0 12px; font-size: 16px; }
.modal-card p  { color: var(--text-muted); font-size: 12px; margin: 0 0 12px; }
.modal-card .hint { color: var(--text-muted); font-size: 11px; margin-top: 12px; }
.modal-card input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: Consolas, monospace;
}
.modal-card input:focus { border-color: var(--accent-blue); outline: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* 모바일 반응형 — 카드 너비 자동 축소 */
@media (max-width: 480px) {
  header { padding: 10px 14px; }
  header h1 { font-size: 16px; }
  main { grid-template-columns: 1fr; padding: 12px; }
}
