:root {
  --bg0: #0c1210;
  --bg1: #121a17;
  --bg2: #1a2420;
  --line: #2a3a33;
  --text: #e7f0ea;
  --muted: #8aa396;
  --accent: #b8f26e;
  --accent-dim: #6f9a3f;
  --warn: #f0c35a;
  --danger: #ff6b6b;
  --ok: #5ddea0;
  --font-display: "Syne", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1c3328 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #24301a 0%, transparent 50%),
    var(--bg0);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top, .layout { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; flex-direction: column; gap: 0.25rem; }
.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
}
.logo em {
  font-style: normal;
  color: var(--warn);
  font-size: 0.55em;
  vertical-align: super;
  letter-spacing: 0.08em;
}
.tag { color: var(--muted); font-size: 0.75rem; }

.status-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  border: 1px solid var(--line);
  background: var(--bg2);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}
.pill.on { color: var(--ok); border-color: #2f6b4f; }
.pill.off { color: var(--danger); border-color: #6b2f2f; }
.pill.live { color: var(--warn); border-color: #6b5a2f; }

.layout {
  display: grid;
  grid-template-columns: 340px 1fr 1fr;
  grid-template-areas:
    "settings stats stats"
    "settings positions positions"
    "feed feed history";
  gap: 1rem;
  padding: 1rem 1.75rem 2rem;
}

.settings { grid-area: settings; }
.stats { grid-area: stats; }
.positions { grid-area: positions; }
.feed { grid-area: feed; }
.history { grid-area: history; }

.panel {
  background: linear-gradient(180deg, rgba(26, 36, 32, 0.9), rgba(18, 26, 23, 0.95));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.2rem;
  min-height: 0;
}

h2 {
  margin: 0 0 0.9rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}
.row-head h2 { margin: 0; }

form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

label.check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  color: var(--text);
}
label.check input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

input, select {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.btn-row { display: flex; gap: 0.5rem; margin-top: 0.3rem; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent-dim); }
.btn.primary {
  background: var(--accent);
  color: #102010;
  border-color: var(--accent);
  font-weight: 600;
}
.btn.danger { color: var(--danger); border-color: #6b2f2f; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hint {
  margin: 1rem 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
}
.hint code {
  color: var(--accent);
  font-size: 0.72rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.subh {
  margin: 0.85rem 0 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
label.tall {
  align-items: stretch;
}
label.tall textarea {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  resize: vertical;
  min-height: 4rem;
  width: 100%;
}
label.tall textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}
.stat-grid.stats-6 {
  grid-template-columns: repeat(6, 1fr);
}
.stat-grid.stats-7 {
  grid-template-columns: repeat(7, 1fr);
}
@media (max-width: 1100px) {
  .stat-grid.stats-7 { grid-template-columns: repeat(4, 1fr); }
}
.stat-grid > div {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
}
.stat-grid .k {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.stat-grid .v {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.table-wrap { overflow: auto; }
.empty { color: var(--muted); margin: 0; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.68rem;
  text-transform: uppercase;
}
.badge.watching, .badge.pending_buy { color: var(--warn); }
.badge.open { color: var(--ok); }
.badge.buying, .badge.selling { color: var(--accent); }
.badge.error, .badge.closed { color: var(--muted); }

.events {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}
.events li {
  display: grid;
  grid-template-columns: 70px 64px 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.events .t { color: var(--muted); }
.events .ty {
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--accent-dim);
}
.events .ty.buy, .events .ty.sell { color: var(--ok); }
.events .ty.error { color: var(--danger); }
.events .ty.new { color: var(--warn); }

  @media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "settings"
      "stats"
      "positions"
      "feed"
      "history";
  }
  .stat-grid,
  .stat-grid.stats-6 { grid-template-columns: repeat(2, 1fr); }
}

/* Landing */
body.landing .land-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1;
}
.land-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.land-main {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.hero-land { text-align: left; margin-bottom: 3rem; }
.hero-land .eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  margin: 0 0 1rem;
}
.hero-land h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 0;
}
.hero-land h1 span { color: var(--accent); }
.hero-land .lede {
  margin: 1.25rem 0 1.75rem;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.auth-msg { margin-top: 1rem; color: var(--warn); }
.land-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 2.5rem;
}
.card-land {
  border: 1px solid var(--line);
  background: var(--bg1);
  border-radius: 14px;
  padding: 1.25rem;
}
.card-land h3 {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.card-land p { margin: 0; color: var(--muted); line-height: 1.5; }
.land-guide ol.steps {
  margin: 1rem 0;
  padding-left: 1.25rem;
  color: var(--text);
  line-height: 1.6;
}
.land-guide li { margin-bottom: 0.75rem; }
.land-guide a { color: var(--accent); }
.land-foot {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.75rem 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}
.land-foot a { color: var(--accent); }
@media (max-width: 800px) {
  .land-grid { grid-template-columns: 1fr; }
}
