:root {
  --bg: #07090c;
  --panel: #10141b;
  --panel-2: #161c25;
  --line: #232b38;
  --text: #e8eef6;
  --muted: #8b98ab;
  --buy: #0ecb81;
  --buy-dim: rgba(14, 203, 129, 0.14);
  --sell: #f6465d;
  --sell-dim: rgba(246, 70, 93, 0.14);
  --gold: #e6b84c;
  --warn: #f0b429;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 56px 1fr 34px;
}

.topbar, .status {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: nowrap;
}
.status { border-bottom: 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; justify-content: space-between; }

.brand { font-weight: 700; letter-spacing: 0.08em; color: var(--gold); }
.symbol { font-size: 18px; font-weight: 650; }
.px { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
.px.up { color: var(--buy); }
.px.down { color: var(--sell); }
.meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.pill {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.pill.live { color: var(--buy); border-color: rgba(14,203,129,.35); }
.pill.off { color: var(--sell); border-color: rgba(246,70,93,.35); }

.workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

.chart-wrap {
  display: grid;
  grid-template-rows: 1fr 180px;
  min-width: 0;
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 0;
}
#chart {
  width: 100%;
  height: 100%;
  min-height: 280px;
  position: relative;
  z-index: 0;
}
#chart table, #chart canvas {
  z-index: 0 !important;
}
.positions {
  border-top: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
}
.section-title {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 11px; font-weight: 600; }
tr { border-top: 1px solid var(--line); }
.pos { color: var(--buy); }
.neg { color: var(--sell); }

.ticket {
  background: var(--panel);
  padding: 14px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.stat span { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.stat b { display: block; margin-top: 4px; font-size: 16px; font-variant-numeric: tabular-nums; }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
input {
  width: 100%;
  background: #0b0f14;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
button {
  border: 0;
  border-radius: 10px;
  padding: 12px 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.buy { background: var(--buy); color: #062314; }
.sell { background: var(--sell); color: #2b070d; }
.ghost, .danger {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.danger { border-color: rgba(246,70,93,.5); color: var(--sell); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 0;
  font-weight: 600;
  cursor: pointer;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.open { display: flex; }
.modal {
  position: relative;
  z-index: 10001;
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.modal h2 { margin: 0 0 12px; font-size: 16px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 12px 0 16px; }
.warn { color: var(--warn); font-size: 12px; margin-bottom: 10px; }
.empty { color: var(--muted); padding: 20px; }

.confidence { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.conf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.signal { font-weight: 800; letter-spacing: 0.06em; }
.signal.BUY { color: var(--buy); }
.signal.SELL { color: var(--sell); }
.signal.NO_TRADE { color: var(--warn); }
.conf-num { font-size: 28px; font-variant-numeric: tabular-nums; }
.meters { display: grid; gap: 6px; }
.meter { display: grid; grid-template-columns: 92px 1fr 32px; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bar { height: 6px; background: #0b0f14; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.bar.buy > i { background: var(--buy); }
.bar.sell > i { background: var(--sell); }
.bar.ai > i { background: #6ea8ff; }

.signal-scores {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.signal-scores .score {
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}
.signal-scores .score span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.signal-scores .score b {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.signal-scores .score.side-buy b { color: var(--buy); }
.signal-scores .score.side-sell b { color: var(--sell); }
.signal-scores .score.side-none b { color: var(--warn); }
.signal-scores .score.active {
  box-shadow: inset 0 0 0 1px currentColor;
}
.signal-scores .score.side-buy.active { color: var(--buy); background: var(--buy-dim); }
.signal-scores .score.side-sell.active { color: var(--sell); background: var(--sell-dim); }
.signal-scores .score.side-none.active { color: var(--warn); background: rgba(240, 180, 41, 0.12); }

.nav-link {
  text-decoration: none;
}
.hdr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}
.hdr-btn:hover {
  color: var(--text);
  border-color: #3a4558;
}
button.hdr-btn {
  font-family: inherit;
  font-weight: 600;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.settings-app { grid-template-rows: 56px 1fr; }
.settings-main {
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}
.settings-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-card h1 { margin: 0; font-size: 22px; }
.toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.toggle input { width: auto; margin-top: 3px; }
.toggle b { display: block; margin-bottom: 4px; }
.toggle small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; font-weight: 400; }
.ok { color: var(--buy); font-size: 13px; }

.logout-form { display: flex; margin: 0; }
.header-actions {
  margin-left: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  background:
    radial-gradient(ellipse at top, #1a2214 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(380px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
}
.login-card h1 {
  margin: 8px 0 0;
  font-size: 22px;
}
.login-sub { color: var(--muted); margin: 6px 0 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.remember input { width: auto; }
.login-submit { width: 100%; margin-top: 4px; }
