/* MMV Invest Bot — minimal trading console styles */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --border: #e2e6ee;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --green: #15803d;
  --red: #dc2626;
  --amber: #b45309;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Inter, Arial, sans-serif;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--red); }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.danger { color: var(--red); }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-mark {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--brand); color: #fff;
  font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
  margin-bottom: 4px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .field span {
  display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
}
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.login-card input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

/* ---------- TOPBAR + LAYOUT ---------- */
#app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700;
}
.brand-dot {
  background: var(--brand); color: #fff;
  border-radius: 8px; padding: 4px 8px; font-size: 12px;
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  background: transparent; border: 1px solid transparent;
  padding: 8px 14px; border-radius: 8px; color: var(--muted);
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--brand); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: 12px; flex-wrap: wrap; }

.pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.pill.state-paper-trading, .pill.state-live-trading { background: #dbeafe; color: #1e40af; }
.pill.state-emergency-stopped { background: #fee2e2; color: var(--red); }
.pill.state-paused { background: #fef3c7; color: var(--amber); }

/* ---------- BUTTONS ---------- */
.primary, .ghost, .warn, .danger, .estop {
  border-radius: 8px; padding: 8px 14px; border: 1px solid transparent;
  font-weight: 600;
}
.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-2); }
.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.ghost:hover { background: var(--surface-2); }
.warn { background: #fef3c7; color: var(--amber); border-color: #fde68a; }
.danger { background: var(--red); color: #fff; }
.danger:hover { background: #b91c1c; }
.estop { background: var(--red); color: #fff; }
.estop:hover { background: #b91c1c; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row-btns.end { justify-content: flex-end; }

/* ---------- MAIN ---------- */
main {
  padding: 20px;
  max-width: 1280px; width: 100%; margin: 0 auto;
}
.panel { display: none; flex-direction: column; gap: 16px; }
.panel.active { display: flex; }
.row-2 {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

/* ---------- CARDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px; font-size: 12px; color: var(--muted);
}
.badge.danger { background: #fee2e2; color: var(--red); border-color: #fecaca; }
.callout {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
}
.callout.muted { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
th, td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
th { background: var(--surface-2); font-weight: 600; color: var(--muted); }
td.buy { color: var(--green); font-weight: 600; }
td.sell { color: var(--red); font-weight: 600; }
.sev-info { color: var(--muted); }
.sev-warn { color: var(--amber); font-weight: 600; }
.sev-error { color: var(--red); font-weight: 600; }

/* ---------- FORM FIELDS ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field span { font-size: 12.5px; color: var(--muted); }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
}
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline span { white-space: nowrap; }
.field.inline input { width: 80px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 200px; }

/* ---------- WATCHLIST ---------- */
.watch-input-row { display: flex; gap: 8px; margin: 8px 0; }
.watch-input-row input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  text-transform: uppercase;
}
.watch-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-top: 6px;
}
.watch-card {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); padding: 10px;
}
.watch-head { display: flex; justify-content: space-between; align-items: center; }
.watch-head .x {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 0 4px;
}
.watch-head .x:hover { color: var(--red); }
.watch-price { font-size: 18px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.watch-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }

/* ---------- TRADING: mode / style ---------- */
.mode-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.seg-group {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border);
}
.seg-label {
  padding: 6px 10px; color: var(--muted); font-size: 12px; font-weight: 600;
}
.seg, .seg-style {
  background: transparent; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 8px; color: var(--text);
}
.seg.active { background: var(--brand); color: #fff; }
.seg.danger.active { background: var(--red); }
.seg-style.active { background: var(--text); color: #fff; }

/* ---------- PREDICTIONS ---------- */
.predict-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 8px;
}
.predict-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.predict-card.verdict-safe { border-left-color: var(--green); }
.predict-card.verdict-balanced { border-left-color: var(--brand); }
.predict-card.verdict-risk { border-left-color: var(--amber); }
.predict-card.verdict-skip { border-left-color: var(--red); }
.predict-head { display: flex; justify-content: space-between; align-items: center; }
.predict-line { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.predict-price { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.verdict-pill {
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.verdict-safe .verdict-pill { color: var(--green); border-color: #bbf7d0; background: #dcfce7; }
.verdict-balanced .verdict-pill { color: var(--brand); border-color: #c7d2fe; background: #e0e7ff; }
.verdict-risk .verdict-pill { color: var(--amber); border-color: #fde68a; background: #fef3c7; }
.verdict-skip .verdict-pill { color: var(--red); border-color: #fecaca; background: #fee2e2; }
.ring {
  --p: 0deg;
  width: 52px; height: 52px; border-radius: 50%;
  background: conic-gradient(var(--brand) var(--p), var(--border) 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: 4px;
  border-radius: 50%; background: var(--surface-2);
}
.ring span { position: relative; font-weight: 800; font-size: 14px; }
.ai-reason { font-style: italic; }
.predict-checks summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.predict-checks ul { list-style: none; padding: 6px 0; margin: 0; font-size: 12.5px; }
.predict-checks li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.predict-checks li .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
}
.predict-checks li.ok .dot { background: var(--green); }
.predict-checks li em { color: var(--muted); font-style: normal; margin-left: auto; }

/* ---------- MULTI-SIM ---------- */
.sim-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.sim-controls {
  display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
  margin: 8px 0 4px;
}
.sim-coins {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 8px;
}
.sim-coin {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.sim-coin-head {
  display: flex; justify-content: space-between; align-items: center; font-weight: 700;
  margin-bottom: 6px;
}
.sim-coin-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  font-size: 12.5px;
}
.sim-coin-grid > div { display: flex; justify-content: space-between; }
.sim-coin-grid span { color: var(--muted); }
.sim-coin-grid b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sim-total { margin: 8px 0 0; }

/* ---------- AUTO TRADING ---------- */
.auto-card { border-left: 4px solid var(--red); }
.env-strip {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; margin: 8px 0;
}
.env-strip.has-bad { background: #fef2f2; border-color: #fecaca; }
.env-dot {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
}
.env-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.env-dot.ok .dot { background: var(--green); }
.env-dot.bad { color: var(--red); border-color: #fecaca; }
.auto-controls {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: end;
  margin: 8px 0;
}
.seg-auto {
  background: transparent; border: 1px solid transparent;
  padding: 6px 12px; border-radius: 8px; color: var(--text);
}
.seg-auto.active { background: var(--red); color: #fff; }
.quick-start {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin: 8px 0; padding: 8px 10px;
  background: #fef9c3; border: 1px solid #fde68a; border-radius: 8px;
  font-size: 13px;
}
.quick-start strong { color: #854d0e; }
.preset-btn { padding: 5px 10px; font-size: 12.5px; }
.auto-countdown {
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: #fef2f2; border: 1px solid #fecaca; color: var(--red);
  font-variant-numeric: tabular-nums;
}
.auto-candidates {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  background: #e0e7ff; border: 1px solid #c7d2fe; color: var(--brand);
}
.cand-chip {
  display: inline-block; padding: 2px 8px; margin: 0 4px;
  background: #fff; border: 1px solid #c7d2fe; border-radius: 999px;
  font-weight: 700; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
.auto-last {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--border);
}
.auto-last.kind-ok { border-left-color: var(--green); }
.auto-last.kind-fail { border-left-color: var(--red); background: #fef2f2; }
.auto-last.kind-neutral { border-left-color: var(--muted); }
.auto-last.kind-dust { border-left-color: var(--amber); background: #fef3c7; }
.dust-row {
  padding: 8px 10px; margin-top: 6px;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
}
.dust-row strong { color: #854d0e; }
.auto-history { margin-top: 10px; }
.auto-history summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.auto-history-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.auto-row {
  display: grid; grid-template-columns: 60px 110px 1fr; gap: 8px;
  padding: 4px 8px; border-radius: 6px;
  font-size: 12.5px; background: var(--surface-2);
}
.auto-row.kind-ok { background: #ecfdf5; }
.auto-row.kind-fail { background: #fef2f2; }
.auto-row.kind-dust { background: #fffbeb; }
.auto-row .t { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- TOAST + MODAL ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 100;
}
.toast[data-kind="error"] { background: var(--red); }
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5);
  display: grid; place-items: center; z-index: 50;
}
.modal-card {
  background: var(--surface); border-radius: 14px;
  padding: 24px; width: min(420px, 90vw);
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 12px; color: var(--red); }

@media (max-width: 720px) {
  .topbar { padding: 10px 12px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right { order: 2; margin-left: auto; }
  main { padding: 12px; }
  .field.inline input { width: 70px; }
}
