:root {
  --bg: #0b0e14;
  --bg-panel: #131722;
  --bg-hover: #1b2130;
  --border: #262e42;
  --text: #d1d4dc;
  --text-dim: #787b86;
  --green: #26a69a;
  --red: #ef5350;
  --blue: #2962ff;
  --gold: #f0b90b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Segoe UI", -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }

/* ---------- Navbar ---------- */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
nav .brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}
nav .links a {
  margin-left: 24px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
}
nav .links a:hover, nav .links a.active { background: var(--bg-hover); color: var(--gold); }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.card h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.card .value { font-size: 26px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.panel h2 { font-size: 16px; margin-bottom: 16px; color: var(--gold); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 180px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn.gold { background: var(--gold); color: #111; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.dim { background: var(--bg-hover); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--border); }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg-hover); }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #2a2e39; border-radius: 26px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; height: 20px; width: 20px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #16233a 0%, var(--bg) 60%);
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 34px;
}
.login-box .brand { text-align: center; font-size: 30px; font-weight: 800; color: var(--gold); margin-bottom: 4px; }
.login-box .tag { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.tab-bar { display: flex; margin-bottom: 18px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.tab-bar button { flex: 1; padding: 10px; background: none; border: none; color: var(--text-dim); font-weight: 600; cursor: pointer; }
.tab-bar button.active { background: var(--blue); color: #fff; }

/* ---------- Misc ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0; display: none; }
.alert.error { background: rgba(239,83,80,.15); color: var(--red); display: block; }
.alert.success { background: rgba(38,166,154,.15); color: var(--green); display: block; }
.alert.info { background: rgba(41,98,255,.15); color: var(--blue); display: block; }
.pos-long { color: var(--green); }
.pos-short { color: var(--red); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.text-dim { color: var(--text-dim); }
.badge {
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge.green { background: rgba(38,166,154,.18); color: var(--green); }
.badge.red { background: rgba(239,83,80,.18); color: var(--red); }
.badge.gold { background: rgba(240,185,11,.18); color: var(--gold); }
.badge.dim { background: var(--bg-hover); color: var(--text-dim); }

#chart { width: 100%; height: 300px; }
.engine-status { font-size: 13px; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
