/* NBOT dashboard — Whole Glance UI.
 * Soft, light, modern minimalist. No framework. */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #1a1d21;
  --ink-soft: #5b6470;
  --ink-faint: #8a93a0;
  --line: #ececec;
  --line-soft: #f3f3f0;

  --green: #2e9e6a;
  --green-soft: #e8f6ef;
  --red: #cf4f48;
  --red-soft: #fbecea;
  --amber: #c98a16;
  --amber-soft: #fbf2dd;

  --accent: #2c6cdf;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --num-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 1px 2px rgba(20, 24, 30, 0.04), 0 4px 16px rgba(20, 24, 30, 0.04);
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ── page container ── */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 28px 24px;
}

/* ── hero (status + halt) ── */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.hero-status {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.status-led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(138, 147, 160, 0.12);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.status-led.is-ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(46, 158, 106, 0.16);
  animation: pulse-green 3s ease-in-out infinite;
}
.status-led.is-halted {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(207, 79, 72, 0.16);
}
.status-led.is-warn {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(201, 138, 22, 0.18);
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 4px rgba(46, 158, 106, 0.16); }
  50%      { box-shadow: 0 0 0 8px rgba(46, 158, 106, 0.06); }
}

.status-lines { min-width: 0; }
.status-lines h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 2px 0;
  letter-spacing: -0.01em;
}
.status-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.hero-actions { flex-shrink: 0; }
.halt-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--red);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-soft);
}
.halt-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.halt-btn.is-halted {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}
.halt-btn.is-halted:hover {
  background: var(--green);
  color: #fff;
}

/* ── dividers ── */
.divider {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: 28px 0;
}

/* ── section ── */
.section {
  display: block;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.14em;
  margin: 0 0 18px 0;
  text-transform: uppercase;
}

/* ── TODAY ── */
.today-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.today-grid.is-single {
  grid-template-columns: 1fr;
  max-width: 360px;
}
.today-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.today-card.is-faded { opacity: 0.55; }

.today-pnl {
  font-family: var(--num-font);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.today-pnl.is-pos { color: var(--green); }
.today-pnl.is-neg { color: var(--red); }
.today-pnl.is-flat { color: var(--ink); }
.today-market {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}
.today-meta {
  font-size: 13px;
  color: var(--ink-faint);
}
.today-streak {
  font-size: 12px;
  color: var(--green);
  margin-top: 2px;
}

/* ── positions ── */
.positions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.position-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.position-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.position-sym {
  font-weight: 600;
  color: var(--ink);
}
.position-tag {
  font-size: 12px;
  color: var(--ink-faint);
  background: var(--line-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.position-elapsed {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 13px;
}
.position-empty {
  color: var(--ink-faint);
  font-size: 14px;
  font-style: italic;
  padding: 4px 0;
}

/* ── latest trades ── */
.latest-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
/* Expanded mode: list grows up to ~60vh then scrolls so the page
   stays usable even with hundreds of trades (operator ask 2026-05-18). */
.latest-list.is-expanded {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.latest-list.is-expanded .latest-item {
  padding-left: 4px;
  padding-right: 4px;
}
.latest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}
.latest-item:last-child { border-bottom: 0; }
.latest-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.latest-icon.is-pos { background: var(--green-soft); color: var(--green); }
.latest-icon.is-neg { background: var(--red-soft); color: var(--red); }
.latest-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.latest-sym { font-weight: 600; }
.latest-reason {
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: 4px;
}
.latest-pnl {
  font-weight: 600;
  font-family: var(--num-font);
  flex-shrink: 0;
}
.latest-pnl.is-pos { color: var(--green); }
.latest-pnl.is-neg { color: var(--red); }
.latest-time {
  color: var(--ink-faint);
  font-size: 12px;
  width: 64px;
  text-align: right;
  flex-shrink: 0;
}
.latest-empty {
  color: var(--ink-faint);
  font-size: 14px;
  font-style: italic;
  padding: 4px 0;
}
.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
  padding: 4px 0;
  font-family: var(--font);
}
.link-btn:hover { text-decoration: underline; }

/* ── toggle ── */
.toggle-section {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: var(--shadow-soft);
}
.toggle-opt {
  background: transparent;
  border: 0;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 999px;
  font-family: var(--font);
  transition: all 0.2s ease;
}
.toggle-opt:hover { color: var(--ink); }
.toggle-opt.is-active {
  background: var(--ink);
  color: #fff;
}

/* ── footer ── */
.foot {
  text-align: center;
  margin-top: 32px;
  color: var(--ink-faint);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.foot-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}
.foot-led.is-warn { background: var(--amber); }
.foot-led.is-bad { background: var(--red); }
.foot-sep { color: var(--line); }

/* ── pulse on update ── */
.is-fresh {
  animation: fresh 0.6s ease-out;
}
@keyframes fresh {
  0%   { opacity: 0.55; transform: translateY(2px); }
  100% { opacity: 1;    transform: translateY(0); }
}

/* ── modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 33, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(20, 24, 30, 0.15);
}
.modal h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}
.modal p {
  margin: 0 0 20px 0;
  color: var(--ink-soft);
  font-size: 14px;
}
.modal-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-confirm {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-confirm:hover { filter: brightness(0.92); }

/* ── view transitions ── */
.view-fade {
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.view-fade.is-leaving {
  opacity: 0;
  transform: translateY(-4px);
}

/* ── responsive ── */
@media (max-width: 540px) {
  .page { padding: 24px 18px 18px; }
  .status-lines h1 { font-size: 18px; }
  .today-grid { grid-template-columns: 1fr; gap: 20px; }
  .today-pnl { font-size: 36px; }
  .halt-btn { padding: 8px 14px; font-size: 12px; }
  .latest-time { width: 52px; font-size: 11px; }
  .toggle-opt { padding: 8px 16px; }
}

/* ─── STATS view (operator 2026-05-18) ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.stat-market {
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-pnl {
  font-family: var(--num-font);
  font-weight: 600;
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-pnl.is-pos { color: var(--green); }
.stat-pnl.is-neg { color: var(--red); }
.stat-pnl.is-flat { color: var(--ink-soft); }
.stat-meta {
  font-size: 13px;
  color: var(--ink-soft);
}
.stat-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line-soft);
  font-size: 13px;
  gap: 8px;
  min-width: 0;
}
.stat-key {
  color: var(--ink-faint);
  white-space: nowrap;       /* no label wraps onto two lines */
  flex-shrink: 0;
}
.stat-val {
  color: var(--ink);
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-reasons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.stat-reasons-label {
  font-size: 12px;
  color: var(--ink-faint);
}
.stat-reason-chip {
  background: var(--line-soft);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.stat-section-h {
  margin: 8px 0 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-trades {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line-soft);
}
.stat-trade-item {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.stat-trade-item:last-child { border-bottom: 0; }
