/* ============================================================
   Pipnotic — Global Design System
   Dark-first. Space Grotesk (display) + Outfit (body).
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Palette */
  --ink:          #0c0c0c;
  --ink-2:        #1a1a1a;
  --ink-3:        #252525;
  --surface:      #141414;
  --surface-2:    #1c1c1c;
  --surface-3:    #242424;
  --border:       rgba(255,255,255,.07);
  --border-2:     rgba(255,255,255,.12);

  /* Text */
  --text-primary:   #f0ede8;
  --text-secondary: #9e9b96;
  --text-muted:     #5c5a57;

  /* Accent — electric teal */
  --accent:         #00e5c0;
  --accent-dim:     rgba(0,229,192,.12);
  --accent-hover:   #00ffcf;

  /* Status */
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --info:      #3b82f6;

  /* P&L / directional — softer shades used for numbers & bars
     (distinct from the brighter alert reds/greens above) */
  --profit:    #22c55e;
  --loss:      #f87171;

  /* Typography */
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Spacing scale */
  --s1: .25rem;
  --s2: .5rem;
  --s3: .75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;
  --s10: 6rem;

  /* Radius */
  --r1: 4px;
  --r2: 8px;
  --r3: 12px;
  --r4: 16px;
  --r-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(.16,1,.3,1);
  --dur: 220ms;

  /* Max widths */
  --container: 1200px;
  --container-sm: 720px;
  --container-xs: 480px;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
  font-family:      var(--font-body);
  font-size:        1rem;
  line-height:      1.6;
  
  color:            var(--text-primary);
  background-color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family:    var(--font-display);
  line-height:    1.15;
  font-weight:    700;
  color:          var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.9rem, 4.5vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }

p { color: var(--text-secondary); }

strong { color: var(--text-primary); font-weight: 500; }

/* ── Container ──────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--s6);
}
.container--sm  { max-width: var(--container-sm); }
.container--xs  { max-width: var(--container-xs); }

@media (max-width: 640px) {
  .container { padding-inline: var(--s4); }
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--s2);
  padding:         .7em 1.5em;
  border:          1.5px solid transparent;
  border-radius:   var(--r-full);
  font-family:     var(--font-display);
  font-weight:     600;
  font-size:       .9375rem;
  letter-spacing:  .01em;
  cursor:          pointer;
  transition:      background var(--dur) var(--ease),
                   color var(--dur) var(--ease),
                   border-color var(--dur) var(--ease),
                   transform var(--dur) var(--ease),
                   box-shadow var(--dur) var(--ease);
  white-space:     nowrap;
}
.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 24px rgba(0,229,192,.3);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-2);
}
.btn--ghost:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,.25);
}

.btn--danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.btn--danger:hover { filter: brightness(1.1); }

.btn--sm { font-size: .8125rem; padding: .5em 1.1em; }
.btn--lg { font-size: 1.0625rem; padding: .85em 2em; }
.btn--full { width: 100%; }

/* ── Navigation ─────────────────────────────────────────────── */
.nav {
  position:    sticky;
  top:         0;
  z-index:     100;
  background:  rgba(12,12,12,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition:  background var(--dur);
}
.nav__inner {
  max-width:   var(--container);
  margin:      auto;
  padding:     0 var(--s6);
  height:      64px;
  display:     flex;
  align-items: center;
  gap:         var(--s6);
}
.nav__logo { flex-shrink: 0; }
.nav__logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size:   1.25rem;
  color:       var(--text-primary);
  letter-spacing: -.02em;
}
.nav__links {
  display:     flex;
  gap:         var(--s5);
  margin-left: var(--s4);
}
.nav__link {
  font-size:   .9rem;
  color:       var(--text-secondary);
  transition:  color var(--dur);
}
.nav__link:hover { color: var(--text-primary); }
.nav__actions {
  margin-left: auto;
  display:     flex;
  gap:         var(--s2);
  align-items: center;
}
.nav__hamburger {
  display:         none;
  flex-direction:  column;
  gap:             5px;
  background:      none;
  border:          none;
  cursor:          pointer;
  margin-left:     auto;
  padding:         var(--s2);
}
.nav__hamburger span {
  display:    block;
  width:      22px;
  height:     2px;
  background: var(--text-primary);
  border-radius: var(--r-full);
  transition: transform var(--dur) var(--ease), opacity var(--dur);
}

/* Mobile menu - hidden on desktop always */
.nav__mobile {
  display: none;
}

@media (max-width: 768px) {
  .nav__links, .nav__actions { display: none; }
  .nav__hamburger { display: flex; }
  .nav__inner { padding: 0 var(--s4); }

  /* Show mobile menu only when JS removes hidden attr on mobile */
  .nav__mobile:not([hidden]) {
    display:        flex;
    flex-direction: column;
    padding:        var(--s4) var(--s4) var(--s5);
    gap:            var(--s3);
    border-top:     1px solid var(--border);
    background:     rgba(12,12,12,.97);
  }
  .nav__mobile-link {
    color: var(--text-secondary);
    font-size: .95rem;
    padding: var(--s2) 0;
    border-bottom: 1px solid var(--border);
  }
  .nav__mobile-link:hover { color: var(--text-primary); }
}

/* ── Flash messages ─────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 80px;
  right: var(--s5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: 380px;
}
.flash {
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  gap:           var(--s3);
  padding:       var(--s3) var(--s4);
  border-radius: var(--r3);
  font-size:     .9rem;
  border:        1px solid transparent;
  animation:     flash-in .3s var(--ease);
}
@keyframes flash-in { from { opacity:0; transform:translateX(12px); } }
.flash--success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); color: #4ade80; }
.flash--error   { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.3);  color: #f87171; }
.flash--info    { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); color: #60a5fa; }
.flash--warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fbbf24; }
.flash__close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .6; font-size: 1.1rem; line-height: 1;
  flex-shrink: 0;
}
.flash__close:hover { opacity: 1; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--s2); }
.form-group[hidden] { display: none; }
.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: .01em;
}
.form-input, .form-select, .form-textarea {
  background:   var(--surface-2);
  border:       1px solid var(--border-2);
  border-radius: var(--r2);
  color:        var(--text-primary);
  padding:      .65em 1em;
  font-size:    .9375rem;
  transition:   border-color var(--dur), box-shadow var(--dur);
  width:        100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline:      none;
  border-color: var(--accent);
  box-shadow:   0 0 0 3px var(--accent-dim);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: .8125rem; color: var(--text-muted); }
.form-error { font-size: .8125rem; color: var(--error); }
.form-stack { display: flex; flex-direction: column; gap: var(--s4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* form-grid: flexible multi-column form layout.
   Default is a 1-column stack; use a modifier for column count.
   - --2 / --3 / --4: explicit column count, collapse to 1 col on mobile
   - --autofit: auto-fit minmax(160px, 1fr) — flows responsively
   The `form-grid__full` modifier on a child spans all columns.
   The `form-grid__submit` modifier aligns a child to flex-end (for trailing submit buttons). */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
}
.form-grid--2 { grid-template-columns: 1fr 1fr; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid--4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid--autofit { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-grid > .form-grid__full   { grid-column: 1 / -1; }
.form-grid > .form-grid__submit { display: flex; align-items: flex-end; }
.form-grid .form-group { margin: 0; }
@media (max-width: 768px) {
  .form-grid--3, .form-grid--4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .form-grid--2, .form-grid--3, .form-grid--4 { grid-template-columns: 1fr; }
}

/* checkbox-label: row-style label wrapping a checkbox + text */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: .875rem;
  cursor: pointer;
  user-select: none;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background:   var(--surface);
  border:       1px solid var(--border);
  border-radius: var(--r3);
  padding:      var(--s6);
}
.card--hover {
  transition: border-color var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur);
}
.card--hover:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.card__label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s2);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th {
  text-align: left;
  padding: var(--s3) var(--s4);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-2);
}
.table td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tr:hover td { background: rgba(255,255,255,.02); }

/* ── Badges / Pills ─────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .65em;
  border-radius: var(--r-full);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.badge--active   { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge--inactive { background: rgba(239,68,68,.12);  color: #f87171; }
.badge--pending  { background: rgba(245,158,11,.12); color: #fbbf24; }
.badge--admin    { background: rgba(0,229,192,.12);  color: var(--accent); }
.badge--premium  { background: rgba(168,85,247,.12); color: #c084fc; }
.badge--free     { background: rgba(255,255,255,.07); color: var(--text-muted); }

/* ── Section helpers ────────────────────────────────────────── */
.section { padding-block: var(--s10); }
.section--sm { padding-block: var(--s7); }
.section-eyebrow {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s3);
}
.section-title { margin-bottom: var(--s4); }
.section-body { max-width: 56ch; color: var(--text-secondary); }

/* ── Auth layout ────────────────────────────────────────────── */
.layout--auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(0,229,192,.08) 0%, transparent 70%),
    var(--ink);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: var(--s7) var(--s7);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r4);
  margin: var(--s6) var(--s4);
}
.auth-card__logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--text-primary);
  letter-spacing: -.02em;
  margin-bottom: var(--s5);
  display: block;
}
.auth-card__title {
  font-size: 1.5rem;
  margin-bottom: var(--s2);
}
.auth-card__subtitle {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: var(--s6);
}
.auth-card__footer {
  margin-top: var(--s5);
  font-size: .875rem;
  color: var(--text-muted);
  text-align: center;
}
.auth-card__footer a { color: var(--accent); }
.auth-card__footer a:hover { text-decoration: underline; }
.auth-card__submit { margin-top: .5rem; }
.auth-card__forgot {
  float: right;
  font-weight: 400;
  color: var(--accent);
  font-size: .8rem;
  text-decoration: none;
}
.auth-card__forgot:hover { text-decoration: underline; }
/* Honeypot — visually hidden but still in DOM so bots fill it in */
.auth-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
/* Success-state inside an auth-card (e.g. after forgot-password) */
.auth-success { text-align: center; padding: var(--s4) 0; }
.auth-success__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0,229,192,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s4);
}
.auth-success__title { margin-bottom: var(--s3); }
.auth-success__copy  { margin-bottom: var(--s5); }
.auth-success__note  { font-size: .8rem; color: var(--text-muted); }

/* ── Dashboard layout ───────────────────────────────────────── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s6) 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.sidebar__section { padding: 0 var(--s4) var(--s5); }
.sidebar__label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 var(--s3) var(--s2);
}
.sidebar__link {
  display:      flex;
  align-items:  center;
  gap:          var(--s3);
  padding:      var(--s2) var(--s3);
  border-radius: var(--r2);
  font-size:    .9rem;
  color:        var(--text-secondary);
  transition:   background var(--dur), color var(--dur);
}
.sidebar__link:hover, .sidebar__link--active {
  background: rgba(255,255,255,.05);
  color: var(--text-primary);
}
.sidebar__link--active { color: var(--accent); }
.dashboard-content { padding: var(--s7) var(--s8); min-width: 0; }
.page-header { margin-bottom: var(--s6); }
.page-header h1 { font-size: clamp(1.5rem, 2.5vw, 2rem); }

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .dashboard-content { padding: var(--s5) var(--s4); }
}

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin-block: var(--s5);
}

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-top: var(--s8);
}
.footer__inner {
  max-width: var(--container);
  margin: auto;
  padding-inline: var(--s6);
  display: flex;
  gap: var(--s8);
  justify-content: space-between;
  flex-wrap: wrap;
  padding-bottom: var(--s7);
}
.footer__logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-primary);
}
.footer__tagline {
  margin-top: var(--s2);
  font-size: .875rem;
  color: var(--text-muted);
  max-width: 28ch;
}
.footer__nav {
  display: flex;
  gap: var(--s8);
  flex-wrap: wrap;
}
.footer__col {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.footer__col-title {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s2);
}
.footer__col a {
  font-size: .875rem;
  color: var(--text-muted);
  transition: color var(--dur);
}
.footer__col a:hover { color: var(--text-primary); }
.footer__bottom {
  max-width: var(--container);
  margin: auto;
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Error page ─────────────────────────────────────────────── */
.layout--error {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-page {
  text-align: center;
  padding: var(--s6);
}
.error-page__code {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 800;
  color: var(--surface-3);
  display: block;
  line-height: 1;
  margin-bottom: var(--s4);
}
.error-page__title { margin-bottom: var(--s3); }
.error-page__message { color: var(--text-muted); margin-bottom: var(--s6); }

/* ── Utilities ──────────────────────────────────────────────── */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-mono   { font-family: var(--font-mono); }
.mt-auto { margin-top: auto; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: var(--s2); }
.gap-4 { gap: var(--s4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Legal pages ────────────────────────────────────────────── */
.legal-page {}

.legal-page__hero {
  padding: var(--s10) 0 var(--s7);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.legal-page__hero--risk {
  background: linear-gradient(135deg, rgba(239,68,68,.04) 0%, var(--surface) 60%);
  border-bottom-color: rgba(239,68,68,.15);
}
.legal-page__title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: -1.5px;
  color: var(--text-primary);
  margin: 0.5rem 0 0.75rem;
  line-height: 1.05;
}
.legal-page__meta {
  font-size: .9rem;
  color: var(--text-muted);
}

.legal-page__body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s8);
  padding-top: var(--s8);
  padding-bottom: var(--s10);
  align-items: start;
}
.legal-page__body--single {
  grid-template-columns: 1fr;
  max-width: 760px;
}

/* TOC */
.legal-toc {
  position: sticky;
  top: 88px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: var(--s4);
}
.legal-toc__heading {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s3);
}
.legal-toc__link {
  display: block;
  font-size: .825rem;
  color: var(--text-secondary);
  padding: 5px 0;
  border-left: 2px solid transparent;
  padding-left: var(--s3);
  transition: color var(--dur), border-color var(--dur);
  text-decoration: none;
}
.legal-toc__link:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Content */
.legal-intro {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.75;
  padding: var(--s5);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r2) var(--r2) 0;
  margin-bottom: var(--s6);
}

.legal-content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--s7) 0 var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--border);
  letter-spacing: -.3px;
}
.legal-content h2:first-of-type { margin-top: 0; }
.legal-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--s5) 0 var(--s2);
}
.legal-content p {
  font-size: .925rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--s4);
}
.legal-content strong { color: var(--text-primary); }
.legal-content ul {
  margin: 0 0 var(--s4) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.legal-content ul li {
  font-size: .925rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.legal-risk-warning {
  background: rgba(245,158,11,.07);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: var(--r3);
  padding: var(--s4) var(--s5);
  font-size: .9rem;
  color: rgba(245,158,11,.9);
  line-height: 1.7;
  margin-top: var(--s6);
}
.legal-risk-warning strong { color: #f59e0b; }

.legal-risk-banner {
  display: flex;
  gap: var(--s4);
  align-items: flex-start;
  background: rgba(239,68,68,.05);
  border: 1px solid rgba(239,68,68,.15);
  border-radius: var(--r3);
  padding: var(--s4) var(--s5);
  margin-bottom: var(--s6);
}
.legal-risk-banner__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.legal-risk-banner p {
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

@media (max-width: 768px) {
  .legal-page__body { grid-template-columns: 1fr; }
  .legal-toc { position: static; }
}

/* =====================================================================
   COMPONENT LAYER — Phase 1
   Canonical components that replace per-module reinventions.
   Add classes to views; remove inline styles in Phase 2/3.
   ===================================================================== */

/* ── KPI tiles ─────────────────────────────────────────────────────────
   Replaces: .mt-tile, .adt-tile, .api-tile, .exp-tile, .ip-tile,
             .adm-kpi, .ac-stat, .drill-stat, and inline tile patterns.
   Usage:
     <div class="kpi-grid">
       <div class="kpi">
         <div class="kpi__label">Win Rate</div>
         <div class="kpi__value kpi__value--success">67%</div>
         <div class="kpi__sub">12 of 18 trades</div>
       </div>
       ...
     </div>
   ───────────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s3);
}
.kpi-grid--lg { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi-grid--sm { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: var(--s4);
  min-width: 0;
}
.kpi--linked {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color var(--dur), transform var(--dur) var(--ease);
}
.kpi--linked:hover {
  border-color: rgba(0,229,192,.35);
  transform: translateY(-2px);
}
.kpi__label {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi__value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-display);
  line-height: 1.1;
  margin-bottom: var(--s2);
  word-break: break-word;
  color: var(--text-primary);
}
.kpi__value--success  { color: var(--success); }
.kpi__value--danger   { color: var(--error); }
.kpi__value--warning  { color: var(--warning); }
.kpi__value--accent   { color: var(--accent); }
.kpi__value--muted    { color: var(--text-muted); }
.kpi__value--sm       { font-size: 1.2rem; }
.kpi__sub {
  font-size: .7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Optional progress bar inside a KPI (for things like ruin probability) */
.kpi__bar {
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  margin-top: var(--s2);
  overflow: hidden;
}
.kpi__bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s ease;
}

@media (max-width: 600px) {
  .kpi__value { font-size: 1.2rem; }
  .kpi-grid   { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid--sm { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .kpi-grid   { grid-template-columns: 1fr; }
}

/* ── Page header — enhanced ────────────────────────────────────────────
   Existing .page-header preserved; new pieces support the
   title+actions+filter pattern used on every dashboard page.
   ───────────────────────────────────────────────────────────────────── */
.page-header__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s3);
  flex-wrap: wrap;
}
.page-header__main {
  flex: 1 1 auto;
  min-width: 0;
}
.page-header__sub {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: var(--s2);
  line-height: 1.5;
}
.page-header__actions {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .page-header__row     { flex-direction: column; }
  .page-header__actions { width: 100%; }
}

/* ── Segments (period/time picker) ─────────────────────────────────────
   For 30D / 90D / YTD / 1Y / All button groups.
   Usage:
     <div class="segments">
       <a href="?period=30d" class="segments__btn segments__btn--active">30D</a>
       <a href="?period=90d" class="segments__btn">90D</a>
       ...
     </div>
   ───────────────────────────────────────────────────────────────────── */
.segments {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
}
.segments__btn {
  padding: .3em .9em;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-full);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--dur), background var(--dur);
  white-space: nowrap;
  text-decoration: none;
}
.segments__btn:hover { color: var(--text-primary); }
.segments__btn--active {
  background: var(--accent);
  color: var(--ink);
}
.segments__btn--active:hover { color: var(--ink); }

/* ── Filter bars ────────────────────────────────────────────────────────
   Replaces .sig-filter-*, .edge-filter-*, .ip-filter-* etc.
   Usage:
     <div class="filters">
       <div class="filters__head">
         <h3 class="filters__title">Filter signals</h3>
         <a href="?" class="btn btn--ghost btn--sm">↺ Reset</a>
       </div>
       <form class="filters__grid">
         <div class="filters__field" data-tip="Strategy backing the signal">
           <label class="filters__label">
             Strategy <span class="filters__hint">?</span>
           </label>
           <select class="form-select">...</select>
         </div>
         ...
       </form>
       <div class="filters__tip" aria-live="polite">
         💡 Hover any field for an explanation
       </div>
     </div>
   ───────────────────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  padding: var(--s5);
  margin-bottom: var(--s5);
}
.filters__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.filters__title {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
.filters__subtitle {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: var(--s1);
}
.filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
}
.filters__grid + .filters__grid { margin-top: var(--s3); }
.filters__field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}
.filters__label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
  white-space: nowrap;
}
.filters__hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: .6rem;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  transition: background var(--dur), color var(--dur);
}
.filters__field:hover .filters__hint { background: var(--accent); color: var(--ink); }

/* Inline row inside a filter field — e.g. text input + submit-arrow button */
.filters__field-row {
  display: flex;
  gap: var(--s2);
}
.filters__field-row > :first-child { flex: 1; min-width: 0; }
.filters__tip {
  margin-top: var(--s4);
  background: var(--surface-3);
  border-left: 3px solid var(--accent);
  border-radius: var(--r2);
  padding: var(--s3) var(--s4);
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.55;
  min-height: 1em;
  transition: opacity var(--dur);
}
.filters__tip--hidden { opacity: 0; }
.filters__actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s4);
  flex-wrap: wrap;
  align-items: center;
}

/* ── Split layouts ─────────────────────────────────────────────────────
   Standardised multi-column section layouts. Each collapses cleanly.
   Usage:
     <div class="split-2">
       <div class="card">Left panel</div>
       <div class="card">Right panel</div>
     </div>
   ───────────────────────────────────────────────────────────────────── */
.split-2,
.split-3,
.split-4 {
  display: grid;
  gap: var(--s4);
}
.split-2 { grid-template-columns: 1fr 1fr; }
.split-3 { grid-template-columns: 1fr 1fr 1fr; }
.split-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 1100px) {
  .split-4 { grid-template-columns: 1fr 1fr; }
  .split-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .split-4,
  .split-3,
  .split-2 { grid-template-columns: 1fr; }
}

/* Two-column "aside + main" pattern (e.g. legal pages) */
.split-aside {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s8);
  align-items: start;
}
@media (max-width: 900px) {
  .split-aside { grid-template-columns: 1fr; gap: var(--s5); }
}

/* ── Pills (direction / strategy / status) ─────────────────────────────
   Compact label badges with consistent typography.
   Usage:
     <span class="pill pill--buy">BUY</span>
     <span class="pill pill--strategy-asr">ASR</span>
     <span class="pill pill--open">OPEN</span>
   ───────────────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: .2em .55em;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-muted);
  line-height: 1.4;
  white-space: nowrap;
}
.pill--rounded { border-radius: var(--r-full); padding: .2em .65em; }
.pill--lg      { font-size: .75rem; padding: .25em .65em; }

/* Direction */
.pill--buy   { background: rgba(34,197,94,.13);  color: #22c55e; }
.pill--sell  { background: rgba(248,113,113,.13); color: #f87171; }

/* Strategy */
.pill--strategy-asr  { background: rgba(0,229,192,.13);  color: #00e5c0; }
.pill--strategy-basz { background: rgba(167,139,250,.13); color: #a78bfa; }
.pill--strategy-tbl  { background: rgba(251,191,36,.13);  color: #fbbf24; }
.pill--strategy-cso  { background: rgba(96,165,250,.13);  color: #60a5fa; }

/* Status */
.pill--open    { background: rgba(0,229,192,.13);  color: var(--accent); }
.pill--closed  { background: var(--surface-3);     color: var(--text-muted); }
.pill--filled  { background: rgba(34,197,94,.13);  color: #22c55e; }
.pill--expired { background: rgba(248,113,113,.13); color: #f87171; }
.pill--pending { background: rgba(251,191,36,.13); color: #fbbf24; }
.pill--live    { background: rgba(34,197,94,.13);  color: #22c55e; }
.pill--demo    { background: rgba(96,165,250,.13); color: #60a5fa; }
.pill--contest { background: rgba(251,191,36,.13); color: #fbbf24; }

/* Conviction / regime */
.pill--high     { background: rgba(34,197,94,.13);  color: #22c55e; }
.pill--medium   { background: rgba(251,191,36,.13); color: #fbbf24; }
.pill--low      { background: rgba(107,114,128,.18); color: #9ca3af; }
.pill--trend-up    { background: rgba(34,197,94,.13);  color: #22c55e; }
.pill--trend-down  { background: rgba(248,113,113,.13); color: #f87171; }
.pill--breakout    { background: rgba(0,229,192,.13);  color: #00e5c0; }
.pill--weak        { background: rgba(251,191,36,.13); color: #fbbf24; }
.pill--ranging     { background: rgba(107,114,128,.18); color: #9ca3af; }

/* Semantic alert/info */
.pill--accent      { background: rgba(0,229,192,.13);  color: var(--accent); }
.pill--warning     { background: rgba(251,191,36,.13); color: #fbbf24; border: 1px solid rgba(251,191,36,.3); }

/* ── Money / R-value displays ──────────────────────────────────────────
   Consistent typography for P&L and R-multiple values.
   Usage:
     <span class="money money--positive">+$432.50</span>
     <span class="r-value r-value--positive">+1.4R</span>
   ───────────────────────────────────────────────────────────────────── */
.money,
.r-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money--positive,
.r-value--positive { color: var(--success); }
.money--negative,
.r-value--negative { color: var(--error); }
.money--neutral,
.r-value--neutral  { color: var(--text-muted); }

.money--lg { font-size: 1.15rem; font-weight: 800; }
.money--sm { font-size: .82rem;  font-weight: 600; }

/* ── Tables — additions to existing .table ─────────────────────────────
   The base .table is already in app.css. These extensions standardise
   how tables behave inside cards and on mobile.
   ───────────────────────────────────────────────────────────────────── */
.table--compact th,
.table--compact td {
  padding: var(--s2) var(--s3);
  font-size: .82rem;
}
.table--bordered td { border-bottom: 1px solid var(--border); }
.table--zebra tr:nth-child(even) td { background: rgba(255,255,255,.015); }

/* Sortable table headers */
.table th.is-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color var(--dur);
}
.table th.is-sortable:hover { color: var(--text-primary); }
.table th.is-sortable::after {
  content: ' ↕';
  opacity: .4;
  font-size: .85em;
}
.table th.is-sortable.is-sort-asc::after  { content: ' ↑'; opacity: 1; color: var(--accent); }
.table th.is-sortable.is-sort-desc::after { content: ' ↓'; opacity: 1; color: var(--accent); }

/* Action bar above tables */
.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
  flex-wrap: wrap;
}
.table-actions__left  { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; min-width: 0; }
.table-actions__right { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

/* Table wrap with mobile scroll affordance — pure CSS, no JS */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.table-wrap--scrollable::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--surface));
  opacity: 0;
  transition: opacity var(--dur);
}
.table-wrap--scrollable.is-scrollable::after { opacity: 1; }

/* Column-hide utilities — replace ad-hoc media queries in views */
@media (max-width: 1100px) { .col-hide-lg { display: none !important; } }
@media (max-width: 900px)  { .col-hide-md { display: none !important; } }
@media (max-width: 700px)  { .col-hide-sm { display: none !important; } }
@media (max-width: 500px)  { .col-hide-xs { display: none !important; } }

/* ── Pagination ────────────────────────────────────────────────────────
   Standard pagination component used by pipTable.paginate().
   ───────────────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
}
.pager__info {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.pager__nums {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pager__num {
  min-width: 32px;
  padding: .35em .6em;
  font-size: .78rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--r2);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: background var(--dur), color var(--dur);
}
.pager__num:hover { color: var(--text-primary); background: rgba(255,255,255,.04); }
.pager__num--active {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}
.pager__num--active:hover { color: var(--ink); }
.pager__ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
  align-self: center;
}
.pager__nav {
  display: flex;
  gap: var(--s2);
  margin-left: auto;
  flex-wrap: wrap;
}
.pager__perpage {
  width: 110px;
  font-size: .8rem;
}
@media (max-width: 700px) {
  .pager__nums { display: none; }
  .pager       { justify-content: space-between; }
  .pager__nav  { margin-left: 0; }
}

/* ── Empty state ───────────────────────────────────────────────────────
   For "no trades yet" / "no data" panels inside cards.
   Usage:
     <div class="empty-state">
       <div class="empty-state__icon">📊</div>
       <h2 class="empty-state__title">No trades yet</h2>
       <p class="empty-state__body">...</p>
       <a href="..." class="btn btn--primary">Get started</a>
     </div>
   ───────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--s8) var(--s4);
}
.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--s4);
  opacity: .4;
}
.empty-state__title {
  margin: 0 0 var(--s3);
  font-size: 1.4rem;
}
.empty-state__body {
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto var(--s5);
  line-height: 1.6;
  font-size: .9rem;
}
.empty-state--inline {
  padding: var(--s5) 0;
}

/* ── Stat bars (horizontal performance bars) ───────────────────────────
   For "by strategy" rows and similar comparison bars.
   Usage:
     <div class="stat-bar">
       <div class="stat-bar__head">
         <span class="stat-bar__name">ASR</span>
         <span class="stat-bar__value money money--positive">+$1,240</span>
       </div>
       <div class="stat-bar__track">
         <div class="stat-bar__fill" style="width:60%"></div>
       </div>
       <div class="stat-bar__meta">
         <span>12 trades</span> <span>67% WR</span> <span>+0.6R</span>
       </div>
     </div>
   ───────────────────────────────────────────────────────────────────── */
.stat-bar { padding: var(--s2) 0; }
.stat-bar + .stat-bar { border-top: 1px solid var(--border); }
.stat-bar__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s3);
  margin-bottom: var(--s1);
}
.stat-bar__name {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-bar__value {
  font-size: .9rem;
  font-weight: 800;
}
.stat-bar__track {
  height: 5px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: var(--s1);
}
.stat-bar__fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s ease;
}
.stat-bar__fill--positive { background: var(--success); }
.stat-bar__fill--negative { background: var(--error); }
.stat-bar__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  font-size: .7rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ── Section label (card head with optional subtitle + action) ─────── */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.section-head__main { min-width: 0; }
.section-head__title {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-head__subtitle {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: var(--s1);
  line-height: 1.4;
}
.section-head__action {
  font-size: .75rem;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.section-head__action:hover { color: var(--accent-hover); }

/* ── Modal ────────────────────────────────────────────────────────────
   .modal: full-screen overlay with backdrop
   .modal__panel: the dialog box itself (default max-width: 720px, modifier --lg for 960px, --sm for 480px)
   .modal__head / .modal__title / .modal__close-x: header pieces
   .modal__footer: trailing action row (defaults to right-aligned)
   Usage:
       <div class="modal" id="my-modal" hidden>
           <div class="modal__panel">
               <div class="modal__head">
                   <div class="modal__title">Title</div>
                   <button class="modal__close-x" onclick="closeMyModal()">&times;</button>
               </div>
               ...content...
               <div class="modal__footer">...buttons...</div>
           </div>
       </div>
   Show with: el.hidden = false;
   Hide with: el.hidden = true; */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
}
.modal[hidden] { display: none; }
.modal__panel {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: var(--s6);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal__panel--lg { max-width: 960px; }
.modal__panel--sm { max-width: 480px; }
.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s4);
}
.modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal__close-x {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
  transition: color var(--dur);
}
.modal__close-x:hover { color: var(--text-primary); }
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: var(--s4);
}

/* ── Touch-friendly fixes ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .btn,
  .segments__btn,
  .pager__num { min-height: 36px; }
}
/* ── Sortable table headers ─────────────────────────────────────────────
   Shared by Signals (explore/admin/performance/edge) and Insider admin.
   Markup: <th class="pip-sort"><span class="sort-icon"></span></th>
   add .asc / .desc on the th to show direction.
   ───────────────────────────────────────────────────────────────────── */
.pip-sort { user-select: none; white-space: nowrap; cursor: pointer; }
.pip-sort:hover { color: var(--text-primary); }
.sort-icon { opacity: .4; font-size: .8em; }
.pip-sort.asc .sort-icon,
.pip-sort.desc .sort-icon { opacity: 1; }
.pip-sort.asc  .sort-icon::after { content: ' ↑'; color: var(--accent); }
.pip-sort.desc .sort-icon::after { content: ' ↓'; color: var(--accent); }

/* ── Filter label (small uppercase caption above a filter control) ──────
   Base shared rules; views may add display:flex/gap as a local override.
   ───────────────────────────────────────────────────────────────────── */
.filter-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
}

/* ── Leaderboard — shared bits (tier badges, opt-in toggle, identicon) ───
   Full leaderboard view styles live in /assets/css/leaderboard.css and are
   included only when on /leaderboard/* pages.  The pieces below are kept
   global because tier badges also appear on /api/settings and the future
   dashboard rank widget.                                                  */
.identicon {
    display: inline-block;
    vertical-align: middle;
    border-radius: 8px;
    flex-shrink: 0;
}
.lb-tier {
    display: inline-block;
    padding: 1px 8px;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
    border: 1px solid;
    line-height: 1.6;
    vertical-align: middle;
}
.lb-tier--bronze   { color: #c08552; border-color: #c08552; background: rgba(192,133,82,.08); }
.lb-tier--silver   { color: #c7c8cc; border-color: #c7c8cc; background: rgba(199,200,204,.08); }
.lb-tier--gold     { color: #e6b450; border-color: #e6b450; background: rgba(230,180,80,.10); }
.lb-tier--platinum { color: #b8d4e3; border-color: #b8d4e3; background: rgba(184,212,227,.10); }
.lb-tier--diamond  { color: #7dd3fc; border-color: #7dd3fc; background: rgba(125,211,252,.12); box-shadow: 0 0 12px rgba(125,211,252,.18); }

/* Opt-in toggle row on /api/settings */
.settings-leaderboard {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    margin-top: var(--s3);
}
.lb-acct-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s3);
    background: var(--surface-2);
    border-radius: var(--r2);
}
.lb-acct-row__id { min-width: 0; }
.lb-acct-row__handle {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text);
    font-size: .92rem;
}
.lb-acct-row__meta {
    font-size: .76rem;
    margin-top: 2px;
}
.lb-acct-row__toggle { flex-shrink: 0; }
@media (max-width: 540px) {
    .lb-acct-row { flex-direction: column; align-items: flex-start; }
    .lb-acct-row__toggle { width: 100%; }
    .lb-acct-row__toggle .btn { width: 100%; }
}

/* ── Text-color utilities (R-value displays, table cells, etc.) ──────── */
.text-success { color: var(--success); }
.text-loss    { color: var(--loss); }

/* ── Leaderboard rank widget — used on /dashboard and /trades ────────── */
.db-lb-widget {
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s4);
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
    border: 1px solid var(--surface-3);
    border-left: 3px solid var(--accent);
    border-radius: var(--r2);
    text-decoration: none;
    color: inherit;
    margin: var(--s4) 0;
    transition: border-color .15s ease, transform .15s ease;
}
.db-lb-widget:hover {
    border-left-color: var(--accent);
    transform: translateX(2px);
}
.db-lb-widget__icon { flex-shrink: 0; }
.db-lb-widget__body { flex: 1; min-width: 0; }
.db-lb-widget__label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}
.db-lb-widget__rank {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: var(--s2);
    flex-wrap: wrap;
}
.db-lb-widget__total {
    font-size: .82rem;
    font-weight: 400;
}
.db-lb-widget__handle {
    font-family: var(--font-mono);
    font-size: .82rem;
    margin-top: 2px;
    color: var(--text);
}
.db-lb-widget__cta {
    font-size: .82rem;
    color: var(--accent);
    font-weight: 500;
    flex-shrink: 0;
}
.db-lb-widget__rank-prompt {
    font-size: .95rem;
    font-weight: 500;
    color: var(--accent);
    margin-top: 4px;
}
.db-lb-widget--prompt { border-left-color: var(--surface-3); }
.db-lb-widget--prompt:hover { border-left-color: var(--accent); }
@media (max-width: 540px) {
    .db-lb-widget { flex-direction: column; align-items: flex-start; gap: var(--s2); }
    .db-lb-widget__cta { align-self: flex-end; }
}

/* ── Season ribbons (used on /admin/leaderboard and per-account v2) ──── */
.lb-ribbon {
    display: inline-block;
    padding: 2px 8px;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
}
.lb-ribbon--champion { background: rgba(251,191,36,.15); color: #fbbf24; border: 1px solid #fbbf24; }
.lb-ribbon--top10    { background: rgba(125,211,252,.12); color: #7dd3fc; border: 1px solid #7dd3fc; }
.lb-ribbon--promoted { background: rgba(167,139,250,.12); color: #a78bfa; border: 1px solid #a78bfa; }
