:root {
  --bg: #0a0e17;
  --panel: #111726;
  --panel-2: #0c1322;
  --border: #1e2940;
  --text: #e6edf7;
  --muted: #8a97ad;
  --green: #00e3a5;
  --red: #ff5b6e;
  --blue: #4da3ff;
  --amber: #ffb454;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
  font-size: 15px;
  line-height: 1.45;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(10,14,23,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--green); }
.flags { display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--panel); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}
.chip.paper { color: var(--amber); border-color: #5a4520; background: #2a2010; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  animation: pulse 2s infinite; }

/* Language switch (dropdown) */
.lang { position: relative; }
.lang-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 9px 5px 10px; color: var(--text); cursor: pointer; line-height: 1;
}
.lang-trigger:hover { border-color: #2a3c5e; background: #15233c; }
.lang-flag { font-size: 19px; line-height: 1; }
.lang-caret { font-size: 10px; color: var(--muted); transition: transform 0.15s; }
.lang.open .lang-caret { transform: rotate(180deg); }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 5px; min-width: 150px; display: none; flex-direction: column; gap: 2px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.55);
}
.lang.open .lang-menu { display: flex; }
.lang-opt {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 8px; padding: 9px 10px;
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
}
.lang-opt:hover { background: var(--panel-2); }
.lang-opt.active { background: #15233c; }
.lang-opt .lang-flag { font-size: 17px; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(0,227,165,.6)} 70%{box-shadow:0 0 0 8px rgba(0,227,165,0)} 100%{box-shadow:0 0 0 0 rgba(0,227,165,0)} }

main { max-width: 720px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }

/* Hero */
.hero-top { display: flex; justify-content: space-between; align-items: flex-end; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.equity { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.pnl-box { text-align: right; }
.pnl { font-size: 22px; font-weight: 700; }
.up { color: var(--green); } .down { color: var(--red); }
.chart-wrap { margin: 14px -4px 6px; }
#chart { width: 100%; height: 140px; display: block; }
.hero-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 13px;
  color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.hero-foot b { color: var(--text); font-weight: 600; }

/* Generic rows */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px;
}
.row .l { min-width: 0; flex: 1; }
.row .name { font-weight: 600; overflow-wrap: anywhere; word-break: break-word; }
.row .sub { font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow-wrap: anywhere; word-break: break-word; }
.row .r { text-align: right; white-space: nowrap; flex: 0 0 auto; }
.row .r .v { font-weight: 600; }

/* Log rows: monospace-ish, fully wrapping, never overflow the screen */
.logrow { display: block; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; }
.logrow .msg { font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere;
  word-break: break-word; white-space: pre-wrap; }
.logrow .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.logrow.error .msg { color: var(--red); }
.logrow.warn .msg { color: var(--amber); }

/* Latest decision */
.decision-latest { background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; }
.decision-latest .dsum { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.decision-latest .drat { color: var(--muted); white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border);
  color: var(--muted); margin-left: 6px; }
.badge.buy { color: var(--green); border-color: #145a48; background: #0a3a30; }
.badge.sell { color: var(--red); border-color: #5a2030; background: #3a1018; }
.badge.bull { color: var(--green); }
.badge.bear { color: var(--red); }
.badge.neu { color: var(--muted); }

/* Token stats */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 10px; text-align: center; }
.stat-v { font-size: 22px; font-weight: 700; }
.stat-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab { flex: 0 0 auto; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--text); background: #15233c; border-color: #2a3c5e; }
.tabpane { display: none; } .tabpane.active { display: block; }

/* Collapsible decision rationale */
details.row { display: block; }
details.row summary { list-style: none; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between; gap: 10px; }
details.row summary::-webkit-details-marker { display: none; }
details.row[open] .drat { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.drat { color: var(--muted); white-space: pre-wrap; font-size: 13px; line-height: 1.5; }

/* Bot control panel */
.ctl-status { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.ctl-led { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.ctl-led.on { background: var(--green); box-shadow: 0 0 10px rgba(0,227,165,.6); }
.ctl-led.off { background: var(--red); }
.ctl-state { font-weight: 700; }
.ctl-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { flex: 1 1 auto; min-width: 110px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); border-radius: 11px;
  padding: 12px 14px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.start { color: var(--green); border-color: #145a48; background: #0a3a30; }
.btn.stop { color: var(--red); border-color: #5a2030; background: #3a1018; }
.btn.ghost { color: var(--muted); }
.ctl-login { display: flex; gap: 8px; flex-wrap: wrap; }
.ctl-login input { flex: 1 1 160px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 12px 14px; color: var(--text); font-size: 15px; }
.ctl-login input:focus { outline: none; border-color: var(--blue); }
.ctl-msg { font-size: 13px; margin-top: 10px; min-height: 16px; }
.ctl-msg.err { color: var(--red); } .ctl-msg.ok { color: var(--green); }
.lock-note { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Footer / ticker */
.foot { text-align: center; color: var(--muted); font-size: 12px; }
.ticker { display: block; overflow-x: auto; white-space: nowrap; padding-bottom: 8px;
  -webkit-overflow-scrolling: touch; }
.ticker .t { display: inline-block; margin-right: 14px; }
.ticker .t b { color: var(--text); }

a { color: var(--blue); text-decoration: none; }
.empty { color: var(--muted); text-align: center; padding: 14px; font-size: 13px; }
