:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #6c4cf1;
  --accent-dark: #5636d6;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

/* Nav */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 32px; background: #131a2b; color: #fff;
}
.nav-right { display: flex; align-items: center; gap: 22px; }
.logo { font-size: 22px; font-weight: 700; }
.logo span { color: #a58bff; }
.badge {
  display: inline-block; min-width: 22px; padding: 2px 7px; margin-left: 4px;
  background: var(--accent); border-radius: 999px; font-size: 13px; text-align: center;
}
.server { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #b8bfd0; }
.server i { width: 8px; height: 8px; border-radius: 50%; background: #9aa0b0; display: inline-block; }
.server.on i { background: #22c55e; }
.server.off i { background: #ef4444; }

.page { max-width: 1100px; margin: 28px auto; padding: 0 20px; }

/* Buttons */
.btn {
  border: 0; border-radius: 8px; padding: 10px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #e9ebf0; color: var(--text); }
.btn.secondary:hover { background: #dcdfe6; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.big { width: 100%; padding: 18px; font-size: 18px; }
.btn.discount {
  background: linear-gradient(135deg, #6c4cf1, #c04cf1);
  box-shadow: 0 6px 20px rgba(108, 76, 241, .35);
}
.btn.discount:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.added, .btn.added:hover, .btn.added:disabled {
  background: #9ca3af; color: #fff; opacity: 1; cursor: default;
}
.link-btn { background: none; border: 0; color: var(--bad); cursor: pointer; font-size: 13px; padding: 0; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

/* Products */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.product { display: flex; flex-direction: column; gap: 8px; }
.product-img {
  width: 100%; height: 180px; border-radius: 10px; object-fit: cover; display: block;
  background: linear-gradient(135deg, #eef0ff, #f8eeff);
}
.price { font-size: 20px; font-weight: 700; }

/* Cart / payment rows */
.row {
  display: flex; align-items: center; gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row .thumb {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover;
  background: #eef0ff; flex-shrink: 0;
}
.row .info { flex: 1; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 16px;
}
.totals { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; padding-top: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.divider { text-align: center; color: var(--muted); font-size: 13px; }

/* Trading page */
.trade-layout { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: start; }
.crypto-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.crypto-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 15px; text-align: left; width: 100%;
}
.crypto-item:hover { border-color: var(--accent); }
.crypto-item.active { border-color: var(--accent); background: #f3f0ff; box-shadow: 0 0 0 2px rgba(108,76,241,.15); }
.strategy-item { flex-direction: column; align-items: flex-start; gap: 4px; line-height: 1.4; }
.strategy-head { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.tag.low { background: #dcfce7; color: var(--good); }
.tag.medium { background: #fef3c7; color: var(--warn); }
.tag.high { background: #fee2e2; color: var(--bad); }
.tag.pending { background: #eceef3; color: var(--muted); }
.chart-loading {
  height: 260px; border-radius: 10px; background: #f7f8fb;
  display: grid; place-items: center; color: var(--muted); font-size: 14px;
}

label.field, div.field { display: block; margin-bottom: 16px; font-weight: 600; font-size: 14px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; }
.field-error { color: var(--bad); font-size: 12px; margin-top: 4px; font-weight: 600; }
.field-error:empty { display: none; }
input[type=number], select {
  width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input[type=range] { width: 100%; margin-top: 8px; accent-color: var(--accent); }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 12px; top: 17px; color: var(--muted); }
.input-prefix input { padding-left: 24px; }

.chips { display: flex; align-items: center; gap: 4px; margin: 2px 0 4px; font-size: 12px; color: var(--muted); }
.chips > span { white-space: nowrap; margin-right: 2px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 4px 8px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.duration { display: flex; gap: 10px; }
.dur { display: flex; align-items: center; gap: 6px; flex: 1; font-weight: 400; }
.dur input { margin-top: 0; }

canvas#chart { width: 100%; height: 260px; display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: #f7f8fb; border-radius: 10px; padding: 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.vol-row { display: grid; grid-template-columns: 52px 1fr 52px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.vol-bar { height: 8px; background: #eceef3; border-radius: 99px; overflow: hidden; }
.vol-bar div { height: 100%; background: #b9b0ee; border-radius: 99px; }
.vol-row.active .vol-bar div { background: var(--accent); }
.vol-row.active { font-weight: 700; }
ul.factors { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
ul.factors li { margin-bottom: 4px; }

.params { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.summary { background: #f7f8fb; border-radius: 10px; padding: 14px; font-size: 14px; margin-top: 6px; }
.summary .line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.summary .total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-size: 16px; }

/* Session card */
.run-row {
  display: flex; justify-content: space-between; font-size: 14px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.run-net { display: flex; justify-content: space-between; font-weight: 700; padding: 10px 0 14px; }

/* Modal */
.overlay {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  background: rgba(15, 20, 35, .55); display: grid; place-items: center;
}
.modal {
  background: #fff; border-radius: 16px; width: min(640px, 100%);
  max-height: 92vh; overflow: auto; padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.pill {
  padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: #eef0ff; color: var(--accent); white-space: nowrap;
}
.pill.good { background: #dcfce7; color: var(--good); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.bad { background: #fee2e2; color: var(--bad); }
.live-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.live-stats .value { font-size: 30px; }
.live-market { margin: 0 0 14px; }
.live-market .value { font-size: 16px; }
.live-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 14px 0 6px; font-size: 14px; }
.live-chart { display: block; width: 100%; height: 150px; border: 1px solid var(--border); border-radius: 10px; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.buy { background: var(--good); }
.dot.sell { background: var(--bad); margin-left: 8px; }
.live-fills { font-size: 13px; margin-bottom: 14px; }
.fill-row { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.fill-row .side { min-width: 52px; }

@media (max-width: 800px) {
  .two-col, .trade-layout, .params { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .nav { padding: 14px 16px; }
}