/* NAS100 Session Ledger — bold slate + signal palette
   Colorblind-aware: wins teal, losses orange (distinct hue AND luminance),
   always paired with +/− signs. Content sits on raised panels. */

:root {
  --bg: #14171d;
  --panel: #1e232d;
  --panel-2: #262c39;
  --line: #333b4c;
  --line-soft: #2a3140;
  --text: #f0f3f8;
  --text-dim: #a7b0c0;
  --text-faint: #737d92;
  --brand: #ffce3d;
  --brand-ink: #1d1608;
  --win: #37d3bc;
  --win-dim: rgba(55, 211, 188, 0.14);
  --loss: #ff8e5e;
  --loss-dim: rgba(255, 142, 94, 0.14);
  --sans: "Archivo", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", monospace;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  background-image: radial-gradient(1100px 420px at 75% -10%, rgba(255, 206, 61, 0.05), transparent 60%);
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px 96px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 26px 28px;
  margin-top: 18px;
}

/* ---------- masthead ---------- */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 26px 4px 6px;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand h1 {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.brand h1 em { color: var(--brand); font-style: normal; }
.label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  font-weight: 700;
}
#today-label { font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
  align-items: end;
}
.hero .stat .label { margin-bottom: 8px; }
.balance-num {
  font-size: clamp(2.7rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.balance-num .cents { font-size: 0.45em; color: var(--text-dim); font-weight: 700; }
.stat-num {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-family: var(--mono); font-size: 0.7rem; color: var(--text-faint); margin-top: 5px; }
.stat.duo { display: flex; gap: 28px; }
.stat.duo .stat-num { white-space: nowrap; }
.pos { color: var(--win); }
.neg { color: var(--loss); }

/* ---------- session columns ---------- */
.sessions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  background: none;
  border: none;
  padding: 0;
  margin-top: 30px;
  margin-bottom: 30px;
}
.session-col {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 20px 22px;
}
.session-col .name {
  font-weight: 800;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 12px;
}
.session-col .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.session-col .row .k {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---------- entry form ---------- */
.entry-grid { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field .label { font-size: 0.64rem; }

input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 11px 13px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { border-color: var(--brand); }
input[type="date"] { color-scheme: dark; }
#pnl-input { width: 140px; }
#deposit-amount { width: 130px; }
#deposit-note { width: 170px; }
#reconcile-balance { width: 150px; }

/* segmented session picker */
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.seg button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 11px 18px;
  cursor: pointer;
  transition: all 0.12s ease;
  border-left: 1px solid var(--line-soft);
}
.seg button:first-child { border-left: none; }
.seg button.active { background: var(--brand); color: var(--brand-ink); }

.btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 0.88rem;
  padding: 11px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--line);
}
.btn.ghost:hover { color: var(--text); border-color: var(--text-faint); filter: none; }
.btn.small { padding: 8px 14px; font-size: 0.78rem; }

/* money ops row */
.money-ops {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px dashed var(--line);
}
.money-ops .group { display: flex; gap: 10px; align-items: end; }
.group-title { margin-bottom: 14px; display: block; }

/* ---------- history ---------- */
.history-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }

.day { border-bottom: 1px solid var(--line-soft); padding: 12px 0 10px; }
.day:last-child { border-bottom: none; }
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.day-head .date { font-weight: 800; font-size: 0.95rem; }
.day-head .date .dow { color: var(--text-faint); font-weight: 600; margin-left: 8px; font-size: 0.78rem; }
.day-pnl {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 12px;
  border-radius: 8px;
}
.day-pnl.pos { background: var(--win-dim); }
.day-pnl.neg { background: var(--loss-dim); }

/* percentages read as secondary info everywhere */
.pct { opacity: 0.65; font-size: 0.86em; font-weight: 500; }

.sess-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 5px 0 2px;
}
.sess-line .sname {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  width: 74px;
  flex-shrink: 0;
}
.sess-line .spnl {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  min-width: 150px;
  text-align: right;
  color: var(--text-dim);
}
.sess-line .spnl.pos, .sess-line .spnl.neg { color: inherit; }
.sess-line .spnl.pos { color: var(--win); }
.sess-line .spnl.neg { color: var(--loss); }

/* trade chips — one per trade, sign + color coded */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
}
.chip.pos { color: var(--win); background: var(--win-dim); border-color: rgba(55, 211, 188, 0.25); }
.chip.neg { color: var(--loss); background: var(--loss-dim); border-color: rgba(255, 142, 94, 0.25); }
.chip .tag {
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.chip .note { font-family: var(--sans); font-weight: 500; color: var(--text-dim); font-size: 0.72rem; }
.chip .entry-actions { display: none; gap: 0; }
.chip:hover .entry-actions { display: inline-flex; }
.icon-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 4px;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.danger:hover { color: var(--loss); }

.other-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0 2px; }
.other-line .sname { width: 74px; flex-shrink: 0; }

.inline-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; }
.inline-edit input, .inline-edit select { padding: 6px 9px; font-size: 0.8rem; }
.inline-edit input.pnl { width: 100px; }

#show-more { margin: 18px auto 0; display: block; }

/* ---------- token gate ---------- */
.gate {
  max-width: 470px;
  margin: 80px auto;
  padding: 36px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--panel);
}
.gate h2 { font-weight: 800; margin-bottom: 10px; letter-spacing: -0.01em; }
.gate p { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 10px; }
.gate ol { color: var(--text-dim); font-size: 0.85rem; padding-left: 20px; margin-bottom: 18px; }
.gate ol li { margin-bottom: 5px; }
.gate a { color: var(--brand); }
.gate input { width: 100%; margin-bottom: 12px; }
.gate .btn { width: 100%; }
.gate .error { color: var(--loss); font-size: 0.82rem; margin-top: 10px; font-weight: 600; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--loss); }

/* ---------- load-in ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hero, .sessions, .entry, .history { animation: rise 0.45s ease both; }
.sessions { animation-delay: 0.05s; }
.entry { animation-delay: 0.1s; }
.history { animation-delay: 0.15s; }

.hidden { display: none !important; }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .wrap { padding: 0 12px 72px; }
  .brand .label { display: none; }
  .brand h1 { font-size: 1.15rem; }
  .panel { padding: 20px 18px; }
  .hero { grid-template-columns: 1fr 1fr; gap: 20px; }
  .hero .stat.balance { grid-column: 1 / -1; }
  .sessions { grid-template-columns: 1fr; gap: 10px; }
  .entry-grid .field { flex: 1 1 45%; }
  .entry-grid input, .entry-grid select { width: 100% !important; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 11px 0; }
  .entry-grid .btn { flex: 1 1 100%; padding: 13px; }
  .money-ops { flex-direction: column; gap: 22px; }
  .sess-line .sname, .other-line .sname { width: 100%; }
  .chip .entry-actions { display: inline-flex; }
  .inline-edit { padding-left: 0; }
}
