:root {
  --bg: #14110e;
  --bg2: #1c1814;
  --paper: #221e19;
  --line: #3a332b;
  --ink: #f3ebe1;
  --muted: #b7aa9a;
  --quiet: #8c8073;
  --sage: #8fbf9a;
  --copper: #d4a054;
  --rose: #d9786a;
  --warn: #e0c36e;
  --live: #7ec8b8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a2218 0%, transparent 55%),
    var(--bg);
}

#app { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }

.top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  min-width: 72px;
  height: 48px;
  padding: 6px 10px;
  border-radius: 14px;
  background: linear-gradient(145deg, #d4a054, #8f5b24);
  color: #1a140e;
  font-weight: 800;
  font-size: 11px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  display: grid;
  place-items: center;
  text-align: center;
}
h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  flex: 1;
  min-width: min(100%, 520px);
}
.status-grid > .chip {
  min-width: 0;
  overflow: hidden;
}
.status-grid > .chip.pair { overflow: visible; }
.chip {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.chip .k { display: block; color: var(--quiet); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.chip .v { display: block; margin-top: 4px; font-size: 15px; }
.chip .ago { color: var(--quiet); font-size: 11px; margin-top: 2px; }
.chip.pair {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}
.chip.pair .pair-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  row-gap: 2px;
  min-width: 0;
}
.chip.pair .sym {
  color: var(--quiet);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chip.pair .pct { font-size: 15px; white-space: nowrap; }
.chip.pair .pct.up { color: var(--live); }
.chip.pair .pct.down { color: var(--rose); }
.chip.pair .unit { color: var(--quiet); font-size: 11px; white-space: nowrap; }
.chip.pair .px {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  flex: 0 0 auto;
}
.chip.bad { border-color: #7a3d36; }
.chip.ok .v { color: var(--live); }
.chip.auto { border-color: var(--copper); }
.chip.auto .v { color: var(--copper); }

.logout-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.bottom-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.journal-open {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.journal-open:hover { border-color: var(--copper); color: var(--copper); }
.journal-open.on {
  background: var(--ink);
  color: #16120e;
  border-color: var(--ink);
}

.journal-page h2 { margin: 0 0 8px; font-size: 22px; }
.journal-page .jsym { cursor: pointer; color: var(--copper); font-weight: 650; }
.journal-page .jsym:hover { text-decoration: underline; }
.jtable td.jrr { font-weight: 650; color: var(--ink); }

.jdeposit {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
}
.jdeposit-label { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.jdeposit-pct { font-size: 28px; font-weight: 700; margin: 4px 0; }
.jdeposit-pct.up { color: #8fbf9a; }
.jdeposit-pct.down { color: #d9786a; }

.jdays { margin-top: 20px; }
.jdays-title { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.jdays-table td.jday-date { white-space: nowrap; font-weight: 650; }
.jdays-table thead th { font-size: 11px; }
.jdeposit + .jdeposit { margin-top: 10px; }
button.chip.logout {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  width: min(100%, 220px);
}
button.chip.logout:hover { border-color: var(--copper); }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-box {
  width: min(400px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.gate-box h1 { font-size: 22px; margin: 0 0 8px; }
.gate-box .sub { margin: 0 0 22px; }
.gate-box label { display: block; color: var(--quiet); font-size: 12px; margin: 12px 0 6px; }
.gate-box input {
  width: 100%;
  background: #161310;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}
.pass-wrap { display: flex; gap: 8px; align-items: stretch; }
.pass-wrap input { flex: 1; min-width: 0; }
.pass-wrap button {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
}
.pass-wrap button:hover { border-color: var(--copper); color: var(--copper); }
.gate-box button[type="submit"] {
  width: 100%;
  margin-top: 18px;
  background: var(--copper);
  color: #1a140e;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
}
.gate-box .err { color: var(--rose); font-size: 13px; margin-top: 12px; min-height: 1.2em; }

.daybar {
  margin: 18px 0 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #262019;
  border: 1px solid var(--line);
}
.daybar-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.daybar .now { font-weight: 400; color: var(--muted); }
.toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
}
.toggle.on { border-color: var(--copper); color: var(--copper); }
.toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.bybit-btn, .bybit-send {
  margin-top: 12px;
  background: #3a2c1c;
  color: var(--ink);
  border: 1px solid var(--copper);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.bybit-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bybit-box { place-self: center; width: min(520px, 92vw); border-radius: 16px; border: 1px solid var(--line); }
.daybar p.dump { color: var(--rose); font-weight: 650; }

.bybit-settings {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.bybit-settings.live-mode {
  border-top-color: var(--rose);
}
.bybit-settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: end;
}
.bybit-settings label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.bybit-settings input,
.bybit-settings select {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 110px;
}
.bybit-live-confirm {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  font-size: 13px;
}
.bybit-live-confirm input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--rose);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
}
.journal { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 10px 0 12px; }
.tile.weak { border-left: 3px solid var(--warn); padding-left: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.tabs { display: flex; gap: 8px; margin: 18px 0; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
.tab.on { background: var(--ink); color: #16120e; border-color: var(--ink); font-weight: 650; }

.layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.watch { grid-column: 1 / -1; margin-top: 4px; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } .status-grid { grid-template-columns: 1fr 1fr; } }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .columns { grid-template-columns: 1fr; } }

h2 { font-size: 15px; margin: 0 0 8px; font-weight: 650; }
.aside-hint, .hint { color: var(--quiet); font-size: 12px; margin: 0 0 12px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--line);
}
.card.long { border-left-color: var(--sage); }
.card.short { border-left-color: var(--rose); }
.card.wait { border-left-color: #6e655c; }
.card.weak { border-left-color: var(--warn); }
.card.stale { opacity: 0.55; filter: grayscale(0.4); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.zones { display: grid; gap: 4px; font-size: 13px; color: var(--ink); }
.why { margin: 10px 0 0; padding: 0 0 0 16px; color: var(--muted); font-size: 13px; }
.disclaimer { margin: 12px 0 0; font-size: 11px; color: var(--quiet); }
.note { margin-top: 10px; padding: 8px 10px; background: #2c261c; border-radius: 8px; color: var(--warn); font-size: 13px; }
.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 22px;
  color: var(--muted);
  line-height: 1.5;
}

.tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
}
.tile .head { color: var(--copper); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.tile h3 { margin: 8px 0; }
.cycle {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 16px;
  border-left: 4px solid var(--copper);
}
.cycle.winter { border-left-color: #6e8ca8; }
.cycle.accumulation { border-left-color: var(--warn); }
.cycle.bull { border-left-color: var(--sage); }
.cycle.euphoria { border-left-color: var(--rose); }
.cycle h2 { margin: 0 0 8px; }
.cycle .why { margin: 10px 0 0; }

.event {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.event:last-child { border-bottom: 0; }
.event .t { font-size: 13px; font-weight: 650; }
.event .when,
.event .b { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.45; }
.event .when { margin-top: 2px; }
.event.red .t { color: var(--rose); }
.event.orange .t, .event.yellow .t { color: var(--copper); }
.event.gray .t { color: var(--quiet); }

.sheet {
  position: fixed; inset: 0;
  background: rgba(8, 7, 6, 0.72);
  display: grid; place-items: end;
  padding: 36px 0 0;
  z-index: 20;
  cursor: pointer;
}
.sheet.hidden { display: none; }
.sheet-inner {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  padding: 22px;
  cursor: default;
}
@media (max-width: 640px) {
  .sheet {
    place-items: stretch;
    padding: 0;
  }
  .sheet-inner {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-left: none;
    padding: 14px 12px 24px;
  }
  #sheet-body canvas {
    width: calc(100% + 24px);
    max-width: none;
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
  }
  #sheet-body #deriv-chart {
    margin-left: -12px;
    margin-right: -12px;
  }
}
.close {
  float: right;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.strip {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
}
.strip.long { background: #1b241c; }
.strip.short { background: #2a1c1a; }
.strip.wait { background: #1e1c19; }
.strip.weak { background: #2a2518; }
.strip h3 { margin: 0 0 6px; font-size: 15px; }

canvas { width: 100%; height: 220px; background: #161310; border-radius: 12px; margin: 12px 0; }
#sheet-body canvas { margin: 8px 0 6px; width: 100%; height: auto; display: block; }
#sheet-body #deriv-chart { height: auto; margin: 8px 0 2px; }
a, a:hover { cursor: pointer; }
details { margin-top: 8px; color: var(--muted); }
details summary { cursor: pointer; color: var(--ink); }
details summary:hover { color: var(--copper); }
details > *:not(summary) { cursor: default; }
details table { width: 100%; border-collapse: collapse; font-size: 13px; cursor: default; }
details td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
details td:last-child { text-align: right; color: var(--ink); }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-right: 6px; }
.live-dot.off { background: var(--rose); }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.detail-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.detail-btn:hover { border-color: var(--copper); color: var(--copper); }
.tile .detail-btn { margin-top: 10px; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--quiet);
}
.chart-legend .lg-tf {
  color: var(--copper);
  font-weight: 650;
  margin-right: 2px;
}
.chart-legend .lg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chart-legend .lg-mark {
  display: inline-block;
  flex: 0 0 auto;
  width: 14px;
  height: 3px;
  border-radius: 1px;
}
.chart-legend .lg-mark.lg-bars {
  width: 12px;
  height: 10px;
  border-radius: 0;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0 2px,
    transparent 2px 3px
  );
  opacity: 0.85;
}
.chart-legend .lg-mark.lg-band {
  width: 12px;
  height: 8px;
  border-radius: 1px;
  opacity: 0.85;
}
.chart-legend .lg-asset { color: #8fbf9a; }
.chart-legend .lg-asset .lg-mark { background: #8fbf9a; }
.chart-legend .lg-btc { color: #c9a87c; }
.chart-legend .lg-btc .lg-mark { background: #c9a87c; }
.chart-legend .lg-profile { color: #d4a054; }
.chart-legend .lg-profile .lg-mark { background: #d4a054; }
.chart-legend .lg-long { color: #d9786a; }
.chart-legend .lg-long .lg-mark { background: rgba(217, 120, 106, 0.85); }
.chart-legend .lg-short { color: #8fbf9a; }
.chart-legend .lg-short .lg-mark { background: rgba(143, 191, 154, 0.85); }
.chart-legend .lg-fund { color: #d4a054; }
.chart-legend .lg-fund .lg-mark { background: #d4a054; }
.chart-legend .lg-oi { color: #8fbf9a; }
.chart-legend .lg-oi .lg-mark { background: #8fbf9a; }
.deriv-legend { margin-top: 2px; margin-bottom: 6px; }

.gate-warn {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a1c1a;
  border: 1px solid rgba(217, 120, 106, 0.45);
  color: #e8b4ac;
  font-size: 13px;
}

.decision-box {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(243, 235, 225, 0.03);
}
.decision-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-transform: none;
}
.decision-box p {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.decision-box p:last-child { margin-bottom: 0; }

.book-strip { display: grid; gap: 10px; }
.book-imb-labels, .book-spread-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--quiet);
  margin-bottom: 4px;
}
.book-imb-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9786a 0%, #6e655c 50%, #8fbf9a 100%);
  opacity: 0.85;
}
.book-imb-track i {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 16px;
  margin-left: -2px;
  border-radius: 2px;
  background: #f3ebe1;
  box-shadow: 0 0 0 1px rgba(22, 19, 16, 0.6);
}
.book-spread-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(243, 235, 225, 0.08);
  overflow: hidden;
}
.book-spread-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #8fbf9a;
}
.book-spread.thin .book-spread-track i { background: #d9786a; }

.layer-bars { display: grid; gap: 8px; }
.layer-row {
  display: grid;
  grid-template-columns: 92px 1fr 52px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.layer-name { color: var(--muted); }
.layer-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(243, 235, 225, 0.08);
  overflow: hidden;
}
.layer-fill {
  height: 100%;
  border-radius: 999px;
  background: #6e655c;
}
.layer-fill.up { background: #8fbf9a; }
.layer-fill.down { background: #d9786a; }
.layer-fill.flat { background: #6e655c; }
.layer-side { text-align: right; color: var(--quiet); }
.layer-side.up { color: #8fbf9a; }
.layer-side.down { color: #d9786a; }

.jbars { display: grid; gap: 10px; }
.jbar-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.jbar-empty { font-size: 12px; color: var(--quiet); }
.jbar-meters { display: grid; gap: 5px; }
.jm {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--quiet);
}
.jm-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(243, 235, 225, 0.08);
  overflow: hidden;
}
.jm-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.jm-track i.dir { background: #8fbf9a; }
.jm-track i.tp { background: #d4a054; }
.jm-track i.stop { background: #d9786a; }
.jm-track i.tp2 { background: #c4a574; }
.jm-track i.none { background: #6e655c; }
.jmeta { margin: 6px 0 0; font-size: 11px; color: var(--quiet); }
.jtable-wrap { overflow-x: auto; margin-top: 10px; }
.jtable { width: 100%; border-collapse: collapse; font-size: 11px; }
.jtable th, .jtable td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.jtable th { color: var(--muted); font-weight: 600; }
.jtable td.up { color: #8fbf9a; }
.jtable td.down { color: #d9786a; }
.jtable td.long { color: #8fbf9a; }
.jtable td.short { color: #d9786a; }
.jtable .jctx { color: var(--quiet); max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.csv-link { color: var(--copper); text-decoration: none; border-bottom: 1px solid rgba(201,168,124,0.35); }
.csv-link:hover { color: var(--ink); }
