/* WM Perps Lean Dashboard — C1 */
:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-dim: #a8a8a8;
  --text-muted: #707070;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --good: #34d399;
  --zorg: #fbbf24;
  --kritiek: #f87171;
  --normaal: #a8a8a8;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Topbar ── */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-light { color: var(--text-dim); font-weight: 400; }

.hb { font-size: 12px; padding: 4px 10px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.hb-good     { background: rgba(52,211,153,0.15); color: var(--good); }
.hb-zorg     { background: rgba(251,191,36,0.15); color: var(--zorg); }
.hb-kritiek  { background: rgba(248,113,113,0.15); color: var(--kritiek); }
.hb-pending  { background: var(--surface-2); color: var(--text-muted); }

/* ── Main ── */
main { padding: 12px; padding-bottom: 40px; }
#account-cards { display: flex; flex-direction: column; gap: 14px; }

.acct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.acct-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.acct-name { font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.acct-equity {
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.acct-meta {
  display: flex; gap: 10px;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 12px; flex-wrap: wrap;
}
.acct-meta .pill {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

/* ── Positie-bar ── */
.pos-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.pos-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.pos-symbol { font-weight: 600; }
.pos-side-LONG  { color: var(--green); font-size: 12px; }
.pos-side-SHORT { color: var(--red);   font-size: 12px; }
.pos-upnl { font-variant-numeric: tabular-nums; font-weight: 600; }
.pos-upnl.pos { color: var(--green); }
.pos-upnl.neg { color: var(--red); }

.pos-bar-wrap { position: relative; height: 30px; margin: 14px 0 8px; }
.pos-bar-track {
  position: absolute; left: 0; right: 0; top: 14px;
  height: 2px; background: var(--border);
}
.pos-bar-mark {
  position: absolute; top: 6px; width: 2px; height: 18px;
  background: var(--text);
}
.pos-bar-entry {
  position: absolute; top: 8px; width: 2px; height: 14px;
  background: var(--blue);
}
.pos-bar-liq {
  position: absolute; top: 8px; width: 2px; height: 14px;
  background: var(--red);
}
.pos-bar-stop {
  position: absolute; top: 8px; width: 2px; height: 14px;
  background: var(--amber);
}
.pos-bar-label {
  position: absolute; font-size: 10px; transform: translateX(-50%);
  white-space: nowrap;
}
.pos-bar-label.top { top: -2px; color: var(--text-dim); }
.pos-bar-label.bot { bottom: -14px; color: var(--text-dim); }

.pos-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px 14px; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pos-stat-label { color: var(--text-dim); }
.pos-stat-val { text-align: right; }
.pos-stat-val .br { font-weight: 600; }
.br-good     { color: var(--good); }
.br-zorg     { color: var(--zorg); }
.br-kritiek  { color: var(--kritiek); }
.br-normaal  { color: var(--text-dim); }

/* ── R-ladder (verticaal, chart-georienteerd) ── */
.r-ladder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
  margin: 12px 0;
}
.r-ladder-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.r-ladder-title {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.08em;
  font-weight: 600;
}
.r-ladder-r {
  font-size: 12px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.r-ladder-mark {
  font-size: 11px; color: var(--text-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.r-ladder-body {
  display: flex; flex-direction: column;
  gap: 4px;
}

.r-row {
  position: relative;
  display: grid;
  grid-template-columns: 4px 1fr 36px;
  align-items: stretch;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  min-height: 48px;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.r-rail {
  background: var(--rail-color, var(--border));
}
.r-main {
  display: flex; flex-direction: column; justify-content: center;
  padding: 6px 10px;
  gap: 2px;
}
.r-top {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}
.r-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--rail-color, var(--text));
  min-width: 46px;
}
.r-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px dashed var(--border);
}
.r-tag-plan { font-style: italic; }

/* LIVE order chip — sterk contrast tov plan-tag */
.r-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.r-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
  animation: chipPulse 2s ease-in-out infinite;
  flex: none;
}
.r-chip-live {
  font-size: 9px;
  background: rgba(0,0,0,0.35);
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.08em;
}
.r-chip-kind { opacity: 0.95; }
.r-chip-qty { opacity: 0.85; font-weight: 600; }
.r-chip-at  { opacity: 0.85; font-weight: 500; }

.r-chip-stop { background: #ef4444; color: #fff; border-color: #f87171; }
.r-chip-tp   { background: #16a34a; color: #fff; border-color: #22c55e; }
.r-chip-warn { background: #d97706; color: #fff; border-color: #f59e0b; }
.r-chip-other{ background: #475569; color: #fff; border-color: #64748b; }

@keyframes chipPulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(255,255,255,0.10); }
  50%     { box-shadow: 0 0 0 5px rgba(255,255,255,0.02); }
}

/* Legenda */
.r-ladder-legend {
  display: flex; gap: 14px; align-items: center;
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 0 0 8px 2px;
}
.leg-item { display: inline-flex; align-items: center; gap: 6px; }
.leg-swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
}
.leg-plan { background: rgba(255,255,255,0.04); border: 1px dashed var(--border); }
.leg-live { background: #16a34a; box-shadow: inset 0 0 0 1px #22c55e; }

.r-extra {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.r-extra-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 6px;
}
.r-extra-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.r-bot {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
}
.r-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.r-dist {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}
.r-row.r-active .r-dist { visibility: hidden; }
.r-copy {
  background: transparent; border: 0; border-left: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.r-copy:active { background: var(--blue); color: white; }
.r-copy.copied { background: var(--green); color: var(--bg); }

/* Zone-kleuren */
.r-sl  { --rail-color: #ef4444; }
.r-sl  .r-label { color: #ef4444; }
.r-be  { --rail-color: #f59e0b; }
.r-be  .r-label { color: #f59e0b; }
.r-tp1 { --rail-color: #4ade80; }
.r-tp1 .r-label { color: #4ade80; }
.r-tp2 { --rail-color: #22c55e; }
.r-tp2 .r-label { color: #22c55e; }
.r-tp3 { --rail-color: #16a34a; }
.r-tp3 .r-label { color: #16a34a; }

/* Actieve rij = mark zit hier dichtbij */
.r-row.r-active {
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: inset 0 0 0 1px var(--rail-color, var(--border));
}
.r-row.r-active::after {
  content: '◀ mark';
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--rail-color, var(--text));
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Mobile compactness */
@media (max-width: 480px) {
  .r-row { min-height: 44px; }
  .r-price { font-size: 14px; }
  .r-row.r-active::after { right: 40px; font-size: 9px; padding: 1px 5px; }
}

/* ── Positie-buis (SVG-based premium tube) ── */
.pos-tube-card {
  background: linear-gradient(180deg, #161616 0%, #131313 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 14px;
  margin: 12px 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
}
.tube-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.tube-title {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.08em;
  font-weight: 600;
}
.tube-r {
  font-size: 12px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.tube-mark {
  font-size: 11px; color: var(--text-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.pos-tube-wrap {
  display: flex; gap: 14px;
  align-items: stretch;
}
.pos-tube {
  position: relative;
  flex: 0 0 220px;
  width: 220px;
  /* viewBox is 320 wide x 380 tall → aspect-ratio handhaaft cards op juiste hoogte */
  aspect-ratio: 320 / 380;
}
.pos-tube-svg {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Drijvende prijs-cards */
.tube-card {
  position: absolute;
  transform: translateY(-50%);
  background: rgba(15,15,15,0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
  min-width: 78px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 2;
}
.tube-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.1;
}
.tube-card-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.tube-card-left {
  right: calc(50% + 22px);
  text-align: right;
  max-width: 92px;
}
.tube-card-right {
  left: calc(50% + 22px);
  text-align: left;
  max-width: 92px;
}
.tube-card-entry { border-color: #60a5fa; box-shadow: 0 0 0 1px rgba(96,165,250,0.25), 0 2px 8px rgba(0,0,0,0.4); }
.tube-card-entry .tube-card-label { color: #60a5fa; }
.tube-card-mark  { border-color: #22d3ee; box-shadow: 0 0 0 1px rgba(34,211,238,0.35), 0 2px 10px rgba(34,211,238,0.15); }
.tube-card-mark  .tube-card-label { color: #22d3ee; }
.tube-card-mark  .tube-card-val   { color: #67e8f9; }
.tube-card-live-stop { border-color: #f59e0b; box-shadow: 0 0 0 1px rgba(245,158,11,0.3), 0 2px 8px rgba(0,0,0,0.4); }
.tube-card-live-stop .tube-card-label { color: #f59e0b; }
.tube-card-live-tp   { border-color: #22c55e; box-shadow: 0 0 0 1px rgba(34,197,94,0.3), 0 2px 8px rgba(0,0,0,0.4); }
.tube-card-live-tp   .tube-card-label { color: #22c55e; }
.tube-card-live-pyramiding { border-color: #ef4444; box-shadow: 0 0 0 1px rgba(239,68,68,0.4), 0 2px 8px rgba(0,0,0,0.4); }
.tube-card-live-pyramiding .tube-card-label { color: #ef4444; }
.tube-card-live-reentry { border-color: #a78bfa; box-shadow: 0 0 0 1px rgba(167,139,250,0.3), 0 2px 8px rgba(0,0,0,0.4); }
.tube-card-live-reentry .tube-card-label { color: #a78bfa; }

/* Mark-band ademende glow */
@keyframes markPulse {
  0%, 100% { opacity: 0.9; filter: drop-shadow(0 0 4px rgba(34,211,238,0.6)); }
  50%      { opacity: 1.0; filter: drop-shadow(0 0 10px rgba(34,211,238,0.95)); }
}
.mark-band-anim {
  animation: markPulse 1.8s ease-in-out infinite;
  transform-origin: center;
}

/* Plan-rail rechts: kopieerbare R-tickmarks */
.plan-rail {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.plan-rail-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 2px 2px;
}
.plan-tick {
  display: grid;
  grid-template-columns: 42px 52px 1fr auto 22px;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  min-height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.plan-tick:active { transform: scale(0.98); }
.plan-tick.copied { background: rgba(52,211,153,0.18); border-color: #34d399; }
.plan-tick-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--rail-color, var(--text));
}
.plan-tick-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.plan-tick-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.plan-tick-dist {
  font-size: 11px;
  color: var(--text-dim);
}
.plan-tick-icon {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}
.plan-tick.plan-tp { --rail-color: #22c55e; border-left-color: #22c55e; }
.plan-tick.plan-tp .plan-tick-label { color: #4ade80; }
.plan-tick.plan-be { --rail-color: #f59e0b; border-left-color: #f59e0b; }
.plan-tick.plan-be .plan-tick-label { color: #fbbf24; }
.plan-tick.plan-sl { --rail-color: #ef4444; border-left-color: #ef4444; }
.plan-tick.plan-sl .plan-tick-label { color: #f87171; }

/* Legenda onder de buis */
.tube-legend {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-top: 10px;
}
.tube-legend .leg { display: inline-flex; align-items: center; gap: 5px; }
.leg-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
}
.leg-dot.leg-liq     { background: #ec4899; }
.leg-dot.leg-verlies { background: linear-gradient(180deg, #f59e0b, #d97706); }
.leg-dot.leg-winst   { background: linear-gradient(180deg, #22c55e, #16a34a); }
.leg-dot.leg-tottp   { background: linear-gradient(180deg, #065f46, #064e3b); }

/* Mobile-first: stapel SVG en plan-rail verticaal op smalle schermen */
@media (max-width: 480px) {
  .pos-tube-wrap { flex-direction: row; gap: 8px; }
  .pos-tube { flex: 0 0 160px; width: 160px; }
  .tube-card { min-width: 64px; max-width: 70px; }
  .tube-card-label { font-size: 8px; }
  .tube-card-val { font-size: 12px; }
  .plan-tick { grid-template-columns: 38px 46px 1fr auto 20px; padding: 7px 8px; min-height: 40px; }
  .plan-tick-label { font-size: 11px; }
  .plan-tick-price { font-size: 12px; }
  .plan-tick-dist  { font-size: 10px; }
}

/* ── 30D portfolio chart ── */
.eq-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 14px 0 4px;
}
.eq-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.eq-title {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.08em;
  font-weight: 600;
}
.eq-now {
  font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.eq-svg {
  display: block;
  width: 100%;
  height: 80px;
}
.eq-stats {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  gap: 6px;
}
.eq-stat-label { color: var(--text-muted); }
.eq-delta { font-weight: 700; }
.eq-delta.eq-pos { color: var(--good); }
.eq-delta.eq-neg { color: var(--kritiek); }
.eq-range { color: var(--text-dim); }
.eq-placeholder {
  font-size: 12px; color: var(--text-muted);
  padding: 14px 6px; text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  line-height: 1.5;
}

/* ── IPS check ── */
.ips-check {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}
.ips-title {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.ips-line {
  font-size: 13px; font-variant-numeric: tabular-nums;
  display: flex; justify-content: space-between;
  padding: 3px 0;
}
.ips-line .key { color: var(--text-dim); }

/* ── Orders ── */
.orders-block {
  margin-top: 10px; font-size: 12px;
}
.order-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.order-row .side-BUY  { color: var(--green); }
.order-row .side-SELL { color: var(--red); }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* ── Footer meta ── */
#footer-meta {
  margin-top: 20px; font-size: 11px;
  color: var(--text-muted); text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Auth gate ── */
#auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; padding: 20px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
  max-width: 320px;
}
.auth-card h2 { margin: 0 0 8px; }
.auth-card code {
  background: var(--surface-2); padding: 2px 6px; border-radius: 4px;
  font-size: 12px;
}

/* ── Error banner ── */
#error-banner {
  position: fixed; bottom: 12px; left: 12px; right: 12px;
  background: rgba(248,113,113,0.95); color: var(--bg);
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  z-index: 100;
}
