* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0b1220;
  color: #e2e8f0;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #1e293b;
  background: linear-gradient(90deg, #0f172a, #0b1220);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.nav { display: flex; gap: 0.5rem; }
.pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #1e293b;
  color: #94a3b8;
  text-decoration: none;
  transition: background .15s;
}
.pill:hover { background: #334155; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}
.status-dot.ok { background: #22c55e; }
.status-dot.off { background: #ef4444; }
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
}
.card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.card.wide { grid-column: 1 / -1; }
h2 { margin: 0 0 0.75rem; font-size: 1.1rem; font-weight: 600; }
h3 { margin: 1rem 0 0.5rem; font-size: 0.95rem; font-weight: 600; }
.list { margin: 0; padding-left: 1.1rem; color: #94a3b8; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 0.75rem; }
.row.wrap { flex-wrap: wrap; }
label { font-size: 0.85rem; color: #94a3b8; display: flex; flex-direction: column; gap: 0.25rem; }
label.grow { flex: 1 1 200px; min-width: 160px; }
select, input[type="number"], input[type="text"] {
  background: #020617;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
}
button {
  background: #14b8a6;
  color: #042f2e;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: #334155; color: #e2e8f0; }
button.secondary:hover { filter: brightness(1.1); }
button.danger { background: #dc2626; color: #fff; }
button.danger:hover { filter: brightness(1.1); }
button.btn-buy { background: #14b8a6; color: #042f2e; }
.out {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 200px;
  overflow: auto;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.out.small { max-height: 120px; margin-top: 0.5rem; }
.plot { min-height: 320px; margin-top: 0.75rem; }
.hint {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0.5rem 0 0;
  line-height: 1.4;
}
.hint code { color: #94a3b8; }
.cx-row { align-items: flex-end; margin-top: 0.5rem; }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.lbl { display: block; font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.35rem; }
textarea.code {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.8rem;
  resize: vertical;
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; margin-top: 0.5rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #334155;
  color: #94a3b8;
  font-weight: 600;
}
td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #1e293b;
}
td button {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

/* ---- Engine status ---- */
.engine-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0;
}
.dot.stopped { background: #64748b; }
.dot.starting { background: #eab308; animation: pulse 1s infinite; }
.dot.running { background: #22c55e; animation: pulse 2s infinite; }
.dot.stopping { background: #f97316; }
.dot.error { background: #ef4444; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---- Log box ---- */
.log-box {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  max-height: 280px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
}
.log-box .ev { margin: 0; }
.log-box .ev.trade { color: #5eead4; }
.log-box .ev.warn { color: #fbbf24; }
.log-box .ev.error { color: #f87171; }
.log-box .ev.info { color: #94a3b8; }

/* ---- Searchable pair selector ---- */
.pair-search {
  position: relative;
}
.pair-input {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
}
.pair-input:focus { outline: 1px solid #14b8a6; }
.pair-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0 0 8px 8px;
  z-index: 20;
}
.pair-list.open { display: block; }
.pair-list .pair-opt {
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: #cbd5e1;
}
.pair-list .pair-opt:hover,
.pair-list .pair-opt.active {
  background: #1e293b;
  color: #e2e8f0;
}
.pair-list .pair-empty {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: #64748b;
}

/* ---- Param / risk form grids ---- */
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem 0.75rem;
}
.param-grid label {
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.param-grid .full-row {
  grid-column: 1 / -1;
}
.param-grid .cb-row {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.3rem;
}
.param-grid input[type="checkbox"] {
  accent-color: #14b8a6;
  width: 16px;
  height: 16px;
}
.param-grid .hint-text {
  font-size: 0.72rem;
  color: #475569;
  grid-column: 1 / -1;
  margin: 0;
}
