/* ============================================================
   TRADEBOOK V2 — app.css
   One design system. Tokens → primitives → components → pages.
   Nothing in here is page-specific except layout composition.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
  color-scheme: light;

  /* Palette. Green is the product accent (Pro, positive, active).
     Red appears only for losses and destructive intent. */
  --paper: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeeea;
  --surface-3: #e6e5df;
  --line: #dcdad2;
  --line-soft: #e8e7e1;
  --ink: #101010;
  --ink-2: #5c5b56;
  --ink-3: #8d8c85;
  --ink-4: #b6b5ad;
  --green: #0f7b45;
  --green-soft: #e7f2ea;
  --green-line: #bcd9c7;
  --red: #b4342f;
  --red-soft: #fbeceb;
  --red-line: #e7c3c1;
  --amber: #9a6b12;
  --amber-soft: #fbf2df;

  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-disp: "Bebas Neue", "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --t-xs: 11px;
  --t-sm: 12.5px;
  --t-base: 14px;
  --t-md: 15px;
  --t-lg: 18px;
  --t-xl: 22px;

  /* Space — 4px base, used as a ladder not ad hoc */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 44px;
  --s9: 64px;

  --r-sm: 4px;
  --r: 7px;
  --r-lg: 12px;

  --rail: 232px;
  --topbar: 58px;
  --maxw: 1280px;

  --dur-1: 110ms;
  --dur-2: 190ms;
  --dur-3: 280ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0d0d;
  --surface: #161615;
  --surface-2: #1e1e1c;
  --surface-3: #292927;
  --line: #302f2c;
  --line-soft: #262624;
  --ink: #f2f1ec;
  --ink-2: #a3a29b;
  --ink-3: #78776f;
  --ink-4: #55544e;
  --green: #3fb06f;
  --green-soft: #14281d;
  --green-line: #235136;
  --red: #e0655e;
  --red-soft: #2a1614;
  --red-line: #562623;
  --amber: #d3a24a;
  --amber-soft: #2a2213;
  --ring: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}
p {
  margin: 0;
}
button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.hidden {
  display: none !important;
}
.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;
}

/* Numbers are data. They always get the mono face and tabular figures
   so columns of P&L line up and digits don't jitter as values change. */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}
.display {
  font-family: var(--font-disp);
  letter-spacing: 0.01em;
  font-weight: 400;
}
.pos {
  color: var(--green);
}
.neg {
  color: var(--red);
}

/* ---------- 2. PRIMITIVES ---------- */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 36px;
  padding: 0 var(--s4);
  border: 1px solid transparent;
  border-radius: var(--r);
  font-size: var(--t-sm);
  font-weight: 550;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    opacity var(--dur-1) var(--ease);
}
.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}
.btn--primary {
  background: var(--ink);
  color: var(--paper);
}
.btn--primary:hover:not(:disabled) {
  background: var(--ink-2);
}
.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--ink-4);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}
.btn--danger {
  background: var(--red);
  color: #fff;
}
.btn--danger:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn--accent {
  background: var(--green);
  color: #fff;
}
.btn--accent:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn--sm {
  height: 29px;
  padding: 0 var(--s3);
  font-size: var(--t-xs);
}
.btn--lg {
  height: 44px;
  padding: 0 var(--s6);
  font-size: var(--t-base);
}
.btn--block {
  width: 100%;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn[data-busy="true"] {
  cursor: progress;
}

/* Spinner used inside busy buttons and inline loaders */
.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  opacity: 0.8;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field__label {
  font-size: var(--t-sm);
  font-weight: 550;
  color: var(--ink);
}
.field__hint {
  font-size: var(--t-xs);
  color: var(--ink-3);
  line-height: 1.45;
}
.field__error {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: var(--t-xs);
  color: var(--red);
  font-weight: 500;
}
.field__error svg {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 1px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0 var(--s3);
  height: 38px;
  font-family: inherit;
  font-size: var(--t-base);
  transition:
    border-color var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease);
}
.input.num,
.input[type="number"] {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: var(--s3);
  resize: vertical;
  line-height: 1.55;
}
.select {
  appearance: none;
  padding-right: var(--s7);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d8c85' stroke-width='2.2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}
.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) {
  border-color: var(--ink-4);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--surface-3);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: not-allowed;
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--red);
  background: var(--red-soft);
}
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix > .input {
  padding-left: 26px;
}
.input-affix__sym {
  position: absolute;
  left: var(--s3);
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  color: var(--ink-3);
  pointer-events: none;
}

/* Segmented control — direction, ranges, tabs-in-forms */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 5px var(--s3);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 550;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.segmented button:hover {
  color: var(--ink);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.segmented--full {
  display: flex;
}
.segmented--full button {
  flex: 1;
}
.segmented button[data-tone="buy"][aria-pressed="true"] {
  background: var(--green);
  color: #fff;
}
.segmented button[data-tone="sell"][aria-pressed="true"] {
  background: var(--red);
  color: #fff;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--buy {
  background: var(--green-soft);
  color: var(--green);
  border-color: var(--green-line);
}
.badge--sell {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-line);
}
.badge--pro {
  background: var(--ink);
  color: var(--paper);
}
.badge--pro::before {
  content: "\1F451";
  font-size: 10px;
  line-height: 1;
}
.badge--muted {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
.badge--open {
  background: var(--amber-soft);
  color: var(--amber);
}

/* Cards / panels. Deliberately sparse: not every section is a card. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line-soft);
}
.panel__title {
  font-family: var(--font-disp);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.panel__sub {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin-top: 2px;
}
.panel__body {
  padding: var(--s5);
}
.panel__body--flush {
  padding: 0;
}

/* Section rhythm without card-in-card */
.section {
  margin-top: var(--s8);
}
.section:first-child {
  margin-top: 0;
}
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.section__title {
  font-family: var(--font-disp);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.section__meta {
  font-size: var(--t-sm);
  color: var(--ink-3);
}

/* Page header */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s5);
  flex-wrap: wrap;
  margin-bottom: var(--s7);
}
.page-head h1 {
  font-family: var(--font-disp);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0.015em;
}
.page-head__sub {
  color: var(--ink-2);
  font-size: var(--t-md);
  margin-top: 6px;
  max-width: 62ch;
}
.page-head__actions {
  display: flex;
  gap: var(--s2);
  align-items: center;
}

/* Stat — the core data primitive */
.stat-grid {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.stat {
  background: var(--surface);
  padding: var(--s4) var(--s5);
  min-width: 0;
  position: relative;
}
.stat__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 7px;
}
.stat__value {
  font-size: 23px;
  font-weight: 500;
  line-height: 1.1;
}
.stat__foot {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: 5px;
}
.stat--locked {
  background: var(--surface-2);
}
.stat--locked .stat__value {
  color: var(--ink-4);
  filter: blur(3.5px);
  user-select: none;
}
/* In normal flow, not an absolutely positioned corner — a fixed mobile
   FAB anchors to the same corner, and the two would otherwise collide
   the moment this card scrolls into the FAB's band. This also gives a
   locked card the same height as an unlocked one (label + value +
   this row), instead of running short by a foot line. */
.stat__unlock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 9px;
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.stat__unlock svg {
  width: 12px;
  height: 12px;
}
.stat__unlock:hover {
  text-decoration: underline;
}

/* Cards / panels. Deliberately sparse: not every section is a card. */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line-soft);
}

/* Section rhythm without card-in-card */
.stat--locked {
  background: var(--surface-2);
}
.stat--locked .stat__value {
  color: var(--ink-4);
  filter: blur(3.5px);
  user-select: none;
}
/* In normal flow, not an absolutely positioned corner — a fixed mobile
   FAB anchors to the same corner, and the two would otherwise collide
   the moment this card scrolls into the FAB's band. This also gives a
   locked card the same height as an unlocked one (label + value +
   this row), instead of running short by a foot line. */
.stat__unlock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 9px;
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.stat__unlock svg {
  width: 12px;
  height: 12px;
}
.stat__unlock:hover {
  text-decoration: underline;
}

/* Tooltips were replaced by the explain popover (see below): a bubble
   anchored inside a 150px stat cell is clipped by the grid's overflow
   and unreadable on mobile. */

/* ---------- 3. ASYNC STATES ---------- */

.skeleton {
  display: block;
  border-radius: var(--r-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
.skeleton--text {
  height: 11px;
  margin-bottom: 8px;
}
.skeleton--title {
  height: 19px;
  width: 42%;
  margin-bottom: 14px;
}
.skeleton--stat {
  height: 74px;
  border-radius: 0;
}
.skeleton--chart {
  height: 230px;
  border-radius: var(--r-lg);
}
.skeleton--row {
  height: 56px;
  margin-bottom: 1px;
  border-radius: 0;
}
.skeleton--w70 {
  width: 70%;
}
.skeleton--w50 {
  width: 50%;
}
.skeleton--w30 {
  width: 30%;
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s9) var(--s5);
  gap: var(--s3);
}
.state__icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-3);
  background: var(--surface-2);
  margin-bottom: var(--s1);
}
.state__icon svg {
  width: 19px;
  height: 19px;
}
.state__title {
  font-size: var(--t-md);
  font-weight: 600;
}
.state__body {
  font-size: var(--t-sm);
  color: var(--ink-2);
  max-width: 44ch;
  line-height: 1.55;
}
.state__actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s3);
  flex-wrap: wrap;
  justify-content: center;
}
.state--error .state__icon {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}
.state--compact {
  padding: var(--s7) var(--s4);
}

/* Inline alert — form-level and network errors */
.alert {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.alert svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}
.alert__title {
  font-weight: 600;
}
.alert__body {
  color: var(--ink-2);
  margin-top: 2px;
}
.alert__actions {
  margin-top: var(--s2);
  display: flex;
  gap: var(--s2);
}
.alert--error {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}
.alert--error .alert__body {
  color: var(--red);
  opacity: 0.88;
}
.alert--warn {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}
.alert--success {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green);
}

/* Offline banner */
.offline-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 88px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: var(--ink);
  color: var(--paper);
  padding: 9px var(--s4);
  border-radius: 100px;
  font-size: var(--t-sm);
  font-weight: 500;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
}
.offline-bar svg {
  width: 15px;
  height: 15px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  z-index: 400;
  bottom: var(--s5);
  right: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  pointer-events: auto;
  background: var(--ink);
  color: var(--paper);
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  font-size: var(--t-sm);
  line-height: 1.45;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
  animation: toast-in var(--dur-3) var(--ease-out);
}
.toast svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}
.toast--error svg {
  color: #ff8b84;
}
.toast--out {
  animation: toast-out var(--dur-2) var(--ease) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Pro gate — explains value, never a bare padlock */
.gate {
  border: 1px solid var(--green-line);
  border-radius: var(--r-lg);
  background: var(--green-soft);
  padding: var(--s5);
  position: relative;
  overflow: hidden;
}
.gate__head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.gate__title {
  font-size: var(--t-md);
  font-weight: 600;
}
.gate__what {
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.55;
}
.gate__why {
  font-size: var(--t-sm);
  color: var(--ink);
  margin-top: var(--s3);
  padding-left: var(--s3);
  border-left: 2px solid var(--green);
  line-height: 1.55;
}
.gate__preview {
  margin: var(--s4) 0;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--green-line);
  border-radius: var(--r);
}
.gate__preview-label {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-bottom: var(--s2);
}
.gate__actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s4);
  flex-wrap: wrap;
}
.gate__price {
  font-size: var(--t-sm);
  color: var(--ink-2);
}

/* ---------- 4. SHELL ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--paper);
  overflow-y: auto;
  padding: max(6vh, var(--s6)) var(--s5) var(--s6);
}
.boot__card {
  width: min(420px, 100%);
  margin: 0 auto;
}
.boot__brand {
  font-family: var(--font-disp);
  font-size: 34px;
  letter-spacing: 0.06em;
}
.boot__msg {
  color: var(--ink-2);
  font-size: var(--t-sm);
  margin: var(--s2) 0 var(--s6);
}

.shell {
  display: flex;
  min-height: 100vh;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  z-index: 50;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: var(--s5) var(--s3) var(--s4);
}
.rail__brand {
  font-family: var(--font-disp);
  font-size: 25px;
  letter-spacing: 0.07em;
  padding: 0 var(--s3) var(--s6);
}
.rail__nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rail__label {
  font-size: var(--t-xs);
  color: var(--ink-4);
  font-weight: 600;
  padding: var(--s5) var(--s3) var(--s2);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 8px var(--s3);
  border-radius: var(--r);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  color: var(--ink-2);
  font-size: var(--t-base);
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 550;
}
.nav-item__badge {
  margin-left: auto;
}
.rail__foot {
  margin-top: auto;
  padding-top: var(--s4);
}

.next-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  margin-bottom: var(--s6);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-lg);
}
.next-card__body {
  min-width: 0;
}
.next-card__label {
  display: block;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 4px;
}
.next-card__body p {
  font-size: var(--t-sm);
  line-height: 1.5;
  color: var(--paper);
  opacity: 0.92;
}
.next-card__actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}
.next-card .icon-btn {
  color: var(--paper);
  opacity: 0.7;
}
.next-card .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}
@media (max-width: 560px) {
  .next-card {
    flex-direction: column;
    align-items: stretch;
  }
  .next-card__actions {
    justify-content: space-between;
  }
}

.upsell {
  border: 1px solid var(--green-line);
  background: var(--green-soft);
  border-radius: var(--r);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
}
.upsell__title {
  font-size: var(--t-sm);
  font-weight: 600;
}
.upsell__body {
  font-size: var(--t-xs);
  color: var(--ink-2);
  margin: 4px 0 var(--s3);
  line-height: 1.45;
}

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--rail);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s6);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar__ctx {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--s3);
}
.topbar__title {
  font-size: var(--t-md);
  font-weight: 600;
}
.topbar__balance {
  font-size: var(--t-sm);
  color: var(--ink-2);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.topbar__spacer {
  flex: 1;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--t-xs);
  font-weight: 600;
  border: 1px solid var(--line);
  position: relative;
}
/* A quiet, constant status marker — visible on every page, not just
   inside the account menu. Ring + a small mark, not a loud badge. */
.avatar--pro {
  box-shadow:
    0 0 0 2px var(--paper),
    0 0 0 3.5px var(--green);
}
.avatar--pro::after {
  content: "★";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 8px;
  line-height: 14px;
  text-align: center;
  border: 1.5px solid var(--paper);
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 70;
  min-width: 216px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  animation: menu-in var(--dur-2) var(--ease-out);
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}
.menu__head {
  padding: var(--s3);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: var(--s2);
}
.menu__name {
  font-size: var(--t-sm);
  font-weight: 600;
}
.menu__mail {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: 2px;
  word-break: break-all;
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 7px var(--s3);
  border: 0;
  background: transparent;
  border-radius: var(--r);
  font-size: var(--t-sm);
  text-align: left;
  cursor: pointer;
  color: var(--ink-2);
}
.menu__item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.menu__item svg {
  width: 15px;
  height: 15px;
}
.menu__item--danger {
  color: var(--red);
}

.content {
  flex: 1;
  padding: var(--s7) var(--s6) var(--s9);
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
}

/* Mobile tab bar */
.tabbar {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px max(var(--s2), env(safe-area-inset-left))
    calc(6px + env(safe-area-inset-bottom));
}
.tabbar__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  border-radius: var(--r);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 550;
  cursor: pointer;
}
.tabbar__item svg {
  width: 19px;
  height: 19px;
}
.tabbar__item[aria-current="page"] {
  color: var(--ink);
}

.fab {
  display: none;
  position: fixed;
  z-index: 55;
  right: var(--s5);
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.26);
  align-items: center;
  justify-content: center;
}
.fab svg {
  width: 22px;
  height: 22px;
}

/* ---------- 5. MODALS / SHEETS ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(16, 16, 16, 0.42);
  display: grid;
  place-items: center;
  padding: var(--s5);
  animation: fade var(--dur-2) var(--ease);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 880px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  animation: modal-in var(--dur-3) var(--ease-out);
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}
.modal--sm {
  width: min(420px, 100%);
}
.modal--lg {
  width: min(760px, 100%);
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--line-soft);
}
.modal__title {
  font-family: var(--font-disp);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.015em;
}
.modal__sub {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin-top: 3px;
}
.modal__body {
  padding: var(--s5);
  overflow-y: auto;
  flex: 1;
}
.modal__foot {
  display: flex;
  align-items: center;
  gap: var(--s2);
  justify-content: flex-end;
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.modal__foot .btn {
  min-width: 104px;
}
.modal__foot-note {
  margin-right: auto;
  font-size: var(--t-xs);
  color: var(--ink-3);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}
.form-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}
.form-grid .span-2 {
  grid-column: span 2;
}
.form-grid--3 .span-3 {
  grid-column: span 3;
}

/* Live calculation preview inside trade forms */
.preview {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: var(--s4);
  margin-top: var(--s4);
}
.preview__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--s4);
}
.preview__k {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-bottom: 4px;
}
.preview__v {
  font-size: var(--t-md);
  font-weight: 500;
}
.preview__note {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: var(--s3);
  line-height: 1.5;
}

/* ---------- 6. DATA TABLE (responsive) ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: var(--t-xs);
  color: var(--ink-3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}
.table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}
.table th[data-sortable]:hover {
  color: var(--ink);
}
.table td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr {
  transition: background var(--dur-1) var(--ease);
}
.table tbody tr:hover {
  background: var(--surface-2);
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table .col-num {
  text-align: right;
}
.table td > svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.table__row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

/* Below 860px the table becomes a stack of records. Each cell keeps its
   header as a label, so nothing is lost and nothing scrolls sideways. */
@media (max-width: 860px) {
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }
  .table thead {
    display: none;
  }
  .table tr {
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--surface);
  }
  .table td {
    border: 0;
    padding: 5px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
  }
  .table td::before {
    content: attr(data-label);
    font-size: var(--t-xs);
    color: var(--ink-3);
    font-weight: 500;
  }
  .table td[data-label=""]::before {
    display: none;
  }
  .table .col-num {
    text-align: right;
  }
  .table__row-actions {
    justify-content: flex-start;
  }
}

/* Filter bar */
.filters {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--s3) 0 var(--s4);
}
.filters__search {
  flex: 1 1 200px;
  min-width: 160px;
}
.filters__count {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin-left: auto;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-sm);
  cursor: pointer;
  color: var(--ink-2);
}
.chip:hover {
  border-color: var(--ink-4);
  color: var(--ink);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ---------- 7. CHARTS ---------- */

.chart {
  position: relative;
  width: 100%;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart__grid line {
  stroke: var(--line-soft);
  stroke-width: 1;
}
.chart__axis {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--ink-4);
}
.chart__line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart__area {
  fill: var(--surface-2);
  opacity: 0.75;
}
.chart__zero {
  stroke: var(--ink-4);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.chart__dot {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 1.75;
}
.chart__bar {
  fill: var(--ink-4);
}
.chart__bar--pos {
  fill: var(--green);
}
.chart__bar--neg {
  fill: var(--red);
}
.chart__hover {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}
.chart-tip {
  position: absolute;
  z-index: 20;
  transform: translate(-50%, -110%);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r);
  padding: 6px 9px;
  font-size: var(--t-xs);
  pointer-events: none;
  white-space: nowrap;
}

/* Distribution / breakdown bars */
.bar-row {
  display: grid;
  grid-template-columns: 116px 1fr 92px;
  gap: var(--s4);
  align-items: center;
  padding: 9px 0;
}
.bar-row + .bar-row {
  border-top: 1px solid var(--line-soft);
}
.bar-row__label {
  font-size: var(--t-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row__track {
  position: relative;
  height: 7px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
}
.bar-row__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 100px;
  background: var(--ink);
}
.bar-row__fill--pos {
  background: var(--green);
}
.bar-row__fill--neg {
  background: var(--red);
}
.bar-row__value {
  font-size: var(--t-sm);
  text-align: right;
}
@media (max-width: 560px) {
  .bar-row {
    grid-template-columns: 94px 1fr 78px;
    gap: var(--s3);
  }
}

/* ---------- 8. CALENDAR ---------- */

.cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.cal__month {
  font-size: var(--t-md);
  font-weight: 600;
}
.cal__dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.cal__dow span {
  font-size: var(--t-xs);
  color: var(--ink-3);
  text-align: center;
  font-weight: 550;
}
.cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal__cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 5px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition:
    border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.cal__cell:hover {
  border-color: var(--ink-4);
}
.cal__cell[aria-pressed="true"] {
  border-color: var(--ink);
  border-width: 1.5px;
}
.cal__cell--empty {
  border: 0;
  background: transparent;
  cursor: default;
}
.cal__cell--today .cal__day {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cal__cell--win {
  background: var(--green-soft);
  border-color: var(--green-line);
}
.cal__cell--loss {
  background: var(--red-soft);
  border-color: var(--red-line);
}
.cal__day {
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.cal__pnl {
  font-size: 10.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 560px) {
  .cal__cell {
    padding: 3px;
  }
  .cal__pnl {
    font-size: 9px;
  }
}

/* ---------- 8b. ONBOARDING WIZARD ---------- */

.wizard__card {
  width: min(560px, 100%);
  margin: 0 auto;
  text-align: left;
}
.wizard__brand {
  font-family: var(--font-disp);
  font-size: 26px;
  letter-spacing: 0.06em;
  margin-bottom: var(--s5);
}
.wizard__dots {
  display: flex;
  gap: 6px;
  margin-bottom: var(--s5);
}
.wizard__dot {
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background var(--dur-2) var(--ease);
}
.wizard__dot.is-done {
  background: var(--ink-4);
}
.wizard__dot.is-active {
  background: var(--ink);
}
.wizard__title {
  font-family: var(--font-disp);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.wizard__sub {
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-top: 6px;
  line-height: 1.55;
  max-width: 46ch;
}
.wizard__body {
  margin-top: var(--s6);
}
.wizard__points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.wizard__points li {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  font-size: var(--t-base);
  color: var(--ink-2);
}
.wizard__points svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
  color: var(--green);
}
.wizard__divider {
  height: 1px;
  background: var(--line-soft);
  margin: var(--s6) 0;
}
.wizard__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: var(--s6);
  padding-top: var(--s5);
  border-top: 1px solid var(--line-soft);
}
.wizard__foot-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
}
.wizard__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wizard__back svg {
  width: 15px;
  height: 15px;
  transform: scaleX(-1);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.chip:hover {
  border-color: var(--ink-4);
  color: var(--ink);
}
.chip.is-selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line-soft);
}
.review-row:first-child {
  padding-top: 0;
}
.review-row:last-of-type {
  border-bottom: 0;
}
.review-row__text {
  min-width: 0;
}
.review-row__label {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.review-row__value {
  font-size: var(--t-base);
  color: var(--ink);
  margin-top: 3px;
  display: flex;
  align-items: center;
}

/* Full-screen dark Pro intro: local token overrides give it the same dark
   palette as the app's own dark theme regardless of the account's actual
   theme setting, so existing components (badges, checks) still read
   correctly without a parallel stylesheet. */
#onboard.boot--dark {
  background: #0d0d0d;
  padding: 0;
}
.pro-intro {
  --paper: #0d0d0d;
  --surface: #171715;
  --surface-2: #1f1f1c;
  --line: #303030;
  --line-soft: #262624;
  --ink: #f2f1ec;
  --ink-2: #a3a29b;
  --ink-3: #78776f;
  --ink-4: #55544e;
  --green: #46c07d;
  --green-soft: #14281d;
  --green-line: #235136;
  color-scheme: dark;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s7) var(--s5) calc(var(--s7) + env(safe-area-inset-bottom));
}
.pro-intro__brand {
  font-family: var(--font-disp);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}
.pro-intro__headline {
  font-family: var(--font-disp);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: 0.01em;
  margin: var(--s6) 0 var(--s2);
  max-width: 16ch;
}
.pro-intro__sub {
  font-size: var(--t-md);
  color: var(--ink-2);
  max-width: 42ch;
  line-height: 1.55;
}
.pro-intro__card {
  width: min(380px, 100%);
  margin-top: var(--s7);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s6);
}
.pro-intro__price {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 500;
}
.pro-intro__price span {
  font-family: var(--font-ui);
  font-size: var(--t-sm);
  font-weight: 400;
  color: var(--ink-3);
  margin-left: 4px;
}
.pro-intro__list {
  list-style: none;
  margin: var(--s5) 0 var(--s6);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pro-intro__list li {
  display: flex;
  gap: var(--s2);
  font-size: var(--t-sm);
  color: var(--ink-2);
  align-items: flex-start;
}
.pro-intro__list svg {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 3px;
  color: var(--green);
}
.pro-intro__free {
  margin-top: var(--s5);
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-size: var(--t-sm);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: var(--s2);
}
.pro-intro__free:hover {
  color: var(--ink);
}

@media (max-width: 560px) {
  .wizard__card {
    padding: 0 var(--s1);
  }
  .wizard__title {
    font-size: 22px;
  }
  .wizard__foot {
    flex-wrap: wrap;
  }
  .wizard__foot-right {
    width: 100%;
  }
  .wizard__foot-right .btn {
    flex: 1;
  }
  .wizard__back {
    order: 2;
  }
  .pro-intro__headline {
    font-size: 30px;
  }
  .pro-intro__card {
    padding: var(--s5);
  }
}

/* ---------- 9. SETTINGS ---------- */

/* Layout: a centred workspace (nav + content) that stops growing on wide
   screens, so the page never reads as one long stretched form. */
.settings-page {
  max-width: 1120px;
  margin: 0 auto;
}
.settings-page .page-head {
  margin-bottom: var(--s6);
}
.settings-page .page-head h1 {
  font-size: 30px;
}
.settings-page .page-head__sub {
  font-size: var(--t-base);
  margin-top: 4px;
}

.settings {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.settings__pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

/* Secondary navigation — grouped, quiet active state (the black active
   state belongs to the main rail only). */
.settings__nav {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  position: sticky;
  top: calc(var(--topbar) + var(--s5));
}
.settings__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings__group-label {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 var(--s3) var(--s2);
}
.settings__item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  text-align: left;
  padding: 9px var(--s3);
  border: 0;
  background: transparent;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: var(--t-base);
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.settings__item > svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.settings__item-label {
  flex: 1;
  min-width: 0;
}
.settings__item .badge {
  flex: none;
}
.settings__chev {
  display: grid;
  flex: none;
  opacity: 0;
  color: var(--ink-3);
}
.settings__chev svg {
  width: 14px;
  height: 14px;
}
.settings__item:hover {
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  color: var(--ink);
}
.settings__item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}
.settings__item[aria-current="page"] .settings__chev {
  opacity: 1;
}

/* Cards */
.scard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.scard__head {
  padding: var(--s5) var(--s6) var(--s4);
  border-bottom: 1px solid var(--line-soft);
}
.scard__title {
  font-family: var(--font-disp);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.scard__desc {
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-top: 4px;
  line-height: 1.5;
  max-width: 62ch;
}
.scard__body {
  padding: var(--s6);
}
.scard__body div:empty {
  display: none;
}
.scard__body--divided {
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}
.scard__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--line-soft);
  background: var(--paper);
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}
.scard__foot-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
}
.scard__status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-sm);
  color: var(--ink-3);
}
.scard__status:empty {
  display: none;
}
.scard__status[data-state="dirty"] {
  color: var(--ink-2);
}
.scard__status[data-state="dirty"]::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}
.scard__status[data-state="saved"] {
  color: var(--green);
}
.scard__inline {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.scard--danger {
  border-color: var(--red-line);
}
.scard--danger .scard__head {
  border-bottom-color: var(--red-line);
}
.scard--danger .scard__title {
  color: var(--red);
}

/* Inside a card: comfortable 44px fields, and list panels lose their own
   heavy border so there is never a card inside a card. */
.scard .input,
.scard .select {
  height: 44px;
}
.scard .btn:not(.btn--sm) {
  height: 40px;
}
.scard__inline .btn {
  height: 44px;
}
.scard .panel {
  border-color: var(--line-soft);
  border-radius: var(--r);
}
.scard .panel__body {
  padding: 0 var(--s4);
}
.input[readonly] {
  background: var(--surface-2);
  color: var(--ink-2);
}
.input[readonly]:hover {
  border-color: var(--line);
}
.input-affix--end > .input {
  padding-left: var(--s3);
  padding-right: 40px;
}
.input-affix__end {
  position: absolute;
  right: var(--s3);
  display: grid;
  color: var(--ink-3);
  pointer-events: none;
}
.input-affix__end svg {
  width: 16px;
  height: 16px;
}

/* Rows: first/last sit flush with the card padding */
.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s5);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line-soft);
}
.setting-row:last-child {
  border-bottom: 0;
}
.scard .setting-row:first-child {
  padding-top: 0;
}
.scard .setting-row:last-child {
  padding-bottom: 0;
}
.setting-row__text {
  min-width: 0;
}
.setting-row__title {
  font-size: var(--t-base);
  font-weight: 550;
}
.setting-row__desc {
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-top: 3px;
  max-width: 54ch;
  line-height: 1.5;
}
.setting-row__control {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* Tablet: tighter nav, same structure */
@media (max-width: 1024px) {
  .settings {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: var(--s6);
  }
}

/* Mobile: the nav becomes a horizontally scrolling tab list */
@media (max-width: 720px) {
  .settings-page .page-head {
    margin-bottom: var(--s4);
  }
  .settings-page .page-head h1 {
    font-size: 26px;
  }
  .settings {
    grid-template-columns: 1fr;
    gap: var(--s4);
  }
  .settings__nav {
    position: static;
    flex-direction: row;
    gap: var(--s2);
    overflow-x: auto;
    margin: 0 calc(var(--s4) * -1);
    padding: 0 var(--s4) var(--s2);
    scrollbar-width: none;
  }
  .settings__nav::-webkit-scrollbar {
    display: none;
  }
  .settings__group {
    display: contents;
  }
  .settings__group-label,
  .settings__chev {
    display: none;
  }
  .settings__item {
    width: auto;
    flex: none;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 100px;
    padding: 8px var(--s4) 8px var(--s3);
  }
  .settings__item[aria-current="page"] {
    background: var(--surface-2);
    border-color: var(--ink-4);
  }
  .scard__head {
    padding: var(--s4);
  }
  .scard__body {
    padding: var(--s4);
  }
  .scard__foot {
    padding: var(--s3) var(--s4);
  }
  .setting-row {
    flex-direction: column;
    gap: var(--s3);
  }
  .setting-row__control {
    width: 100%;
  }
  .setting-row__control .btn {
    flex: 1;
  }
}
@media (max-width: 480px) {
  .scard__foot {
    flex-direction: column;
    align-items: stretch;
  }
  .scard__foot-actions {
    margin-left: 0;
  }
  .scard__foot-actions .btn {
    flex: 1;
  }
  .scard__inline > .input {
    max-width: none !important;
    flex: 1 1 100%;
  }
}

/* Toggle */
.switch {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 23px;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background var(--dur-2) var(--ease);
  pointer-events: none;
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur-2) var(--ease);
  pointer-events: none;
}
.switch input:checked ~ .switch__track {
  background: var(--green);
  border-color: var(--green);
}
.switch input:checked ~ .switch__thumb {
  transform: translateX(17px);
}
.switch input:disabled ~ .switch__track {
  opacity: 0.5;
}
.switch input:focus-visible ~ .switch__track {
  box-shadow: var(--ring);
}

/* Plan comparison */
.plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s5);
}
.plan {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s6);
  background: var(--surface);
}
.plan__name {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-2);
}
.plan__price {
  font-size: 34px;
  font-weight: 500;
  margin: var(--s2) 0 var(--s1);
  line-height: 1;
}
.plan__per {
  font-size: var(--t-sm);
  color: var(--ink-3);
}
.plan__list {
  list-style: none;
  margin: var(--s5) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.plan__list li {
  display: flex;
  gap: var(--s2);
  font-size: var(--t-sm);
  color: var(--ink-2);
  align-items: flex-start;
}
.plan__list svg {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 3px;
  color: var(--green);
}
.plan__cta {
  margin-top: var(--s6);
}
@media (max-width: 720px) {
  .plans {
    grid-template-columns: 1fr;
  }
}

/* Billing history */
.hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--t-sm);
}
.hist-row:last-child {
  border-bottom: 0;
}
.hist-row__ref {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: 2px;
  word-break: break-all;
}

/* ---------- 10. RESPONSIVE SHELL ---------- */

@media (max-width: 1024px) {
  :root {
    --rail: 0px;
  }
  .rail {
    display: none;
  }
  .main {
    margin-left: 0;
  }
  .content {
    padding: var(--s5) var(--s4) calc(96px + env(safe-area-inset-bottom));
  }
  .topbar {
    padding: 0 var(--s4);
  }
  .tabbar {
    display: block;
  }
  .fab {
    display: flex;
  }
  .toast-stack {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: var(--s4);
    left: var(--s4);
    max-width: none;
  }
  .modal {
    width: 100%;
    max-height: 92vh;
  }
  .scrim {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    animation: sheet-in var(--dur-3) var(--ease-out);
  }
  .modal--sm {
    border-radius: var(--r-lg);
    margin: auto;
    max-width: calc(100% - 32px);
  }
  @keyframes sheet-in {
    from {
      transform: translateY(100%);
    }
  }
  .modal__foot {
    padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  }
  .modal__foot .btn {
    flex: 1;
  }
  .page-head h1 {
    font-size: 23px;
  }
}

@media (max-width: 560px) {
  .form-grid,
  .form-grid--3 {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2,
  .form-grid--3 .span-3 {
    grid-column: span 1;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .page-head {
    align-items: flex-start;
  }
  .page-head__actions {
    width: 100%;
  }
  .page-head__actions .btn {
    flex: 1;
  }
  .topbar__balance {
    display: none;
  }
}

/* ============================================================
   V2 FINISHER — added components
   ============================================================ */

/* ---------- Explain popover / sheet ----------
   Rendered into <body> rather than inside the card, because a stat cell
   is ~150px wide and clips anything longer than a few words. */
.explain-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 0;
  flex: none;
  border: 1px solid var(--ink-4);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.explain-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.explain {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  z-index: 500;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18);
}
.explain--pop {
  position: absolute;
  animation: menu-in var(--dur-2) var(--ease-out);
}
.explain__scrim {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(16, 16, 16, 0.42);
  display: flex;
  align-items: flex-end;
  animation: fade var(--dur-2) var(--ease);
}
.explain--sheet {
  width: 100%;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 0;
  padding: var(--s5) var(--s5) calc(var(--s6) + env(safe-area-inset-bottom));
  animation: sheet-in var(--dur-3) var(--ease-out);
}
.explain__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}
.explain__title {
  font-size: var(--t-md);
}
.explain__close {
  margin: -6px -6px 0 0;
}
.explain__what {
  font-size: var(--t-sm);
  color: var(--ink);
  line-height: 1.55;
  margin-top: var(--s2);
}
.explain__why {
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.55;
  margin-top: var(--s3);
  padding-left: var(--s3);
  border-left: 2px solid var(--green);
}

/* ---------- Six-metric grid ----------
   Explicit column counts, so the last cell is never orphaned into an
   empty box on a 2-up mobile layout. */
.stat-grid--six {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1100px) {
  .stat-grid--six {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 420px) {
  .stat-grid--six {
    grid-template-columns: 1fr;
  }
}

/* ---------- Equity panel ---------- */
.equity-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.equity-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s6);
  flex-wrap: wrap;
  padding: var(--s6) var(--s6) var(--s4);
  border-bottom: 1px solid var(--line-soft);
}
.equity-panel__eyebrow {
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-weight: 550;
}
.equity-panel__value {
  font-size: 40px;
  font-weight: 500;
  line-height: 1.05;
  margin-top: 6px;
  color: var(--ink);
}
.equity-panel__delta {
  font-size: var(--t-sm);
  margin-top: 6px;
}
.equity-panel__facts {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: var(--s6);
  margin: 4px 0 0;
  padding: 0;
}
.equity-panel__facts dt {
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.equity-panel__facts dd {
  margin: 4px 0 0;
  font-size: var(--t-md);
  font-weight: 500;
}
.equity-panel__chart {
  padding: var(--s5) var(--s4) var(--s2);
}
.equity-panel__hint {
  font-size: var(--t-xs);
  color: var(--ink-3);
  padding: 0 var(--s6) var(--s5);
  margin: 0;
}

.equity {
  position: relative;
}
.equity svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.equity__line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.equity__line--up {
  stroke: var(--green);
}
.equity__line--down {
  stroke: var(--red);
}
.equity__area {
  opacity: 0.1;
}
.equity__area--up {
  fill: var(--green);
}
.equity__area--down {
  fill: var(--red);
}
.equity__cap {
  fill: var(--surface);
  stroke: var(--ink-3);
  stroke-width: 1.75;
}
.equity__cap--end {
  stroke-width: 2.5;
}
.equity__cap--end.pos {
  stroke: var(--green);
}
.equity__cap--end.neg {
  stroke: var(--red);
}
.equity__peak {
  fill: var(--ink-3);
}
.chart__note {
  font-size: 9px;
  fill: var(--ink-4);
}
.equity__crosshair {
  stroke: var(--ink-4);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.equity__hit {
  fill: var(--ink);
  stroke: var(--surface);
  stroke-width: 2;
}
.equity__readout {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s2) var(--s3);
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.equity__readout-date {
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.equity__readout-value {
  font-size: var(--t-md);
  font-weight: 600;
}
.equity__readout-trade {
  font-size: var(--t-xs);
  color: var(--ink-2);
}

@media (max-width: 720px) {
  .equity-panel__head {
    padding: var(--s5) var(--s4) var(--s4);
    gap: var(--s4);
  }
  .equity-panel__value {
    font-size: 31px;
  }
  .equity-panel__facts {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s3) var(--s5);
    width: 100%;
  }
  .equity-panel__chart {
    padding: var(--s4) var(--s2) 0;
  }
  .equity-panel__hint {
    padding: var(--s3) var(--s4) var(--s4);
  }
  /* Anchored bottom-left on touch so a thumb dragging across the chart
     never covers the value it is reading. */
  .equity__readout {
    top: auto;
    bottom: 6px;
    left: 6px;
    right: auto;
  }
}

/* ---------- Symbol combobox ---------- */
.combo {
  position: relative;
}
.combo__panel {
  display: none;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
}
.combo__panel--open {
  display: block;
}
.combo__label {
  font-size: var(--t-xs);
  color: var(--ink-3);
  padding: var(--s2) var(--s3) 4px;
}
.combo__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  width: 100%;
  padding: 8px var(--s3);
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  min-height: 40px;
}
.combo__item:hover,
.combo__item[aria-selected="true"] {
  background: var(--surface-2);
}
.combo__pair {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  font-weight: 600;
}
.combo__uses {
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.combo__empty {
  padding: var(--s3);
  font-size: var(--t-xs);
  color: var(--ink-3);
  line-height: 1.5;
}

.datepick {
  position: relative;
}
.datepick__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  width: 100%;
  height: 38px;
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--t-base);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.datepick__trigger:hover {
  border-color: var(--ink-4);
}
.datepick__trigger svg {
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  flex: none;
}
.datepick__panel {
  display: none;
  margin-top: 8px;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.datepick__panel--open {
  display: block;
}
.datepick__quick {
  display: flex;
  gap: 6px;
  margin-bottom: var(--s3);
  flex-wrap: wrap;
}
.datepick__cell--selected {
  border-color: var(--ink) !important;
  border-width: 1.5px;
  background: var(--surface-2);
}
.datepick .cal__grid .cal__cell {
  cursor: pointer;
}
.datepick .cal__grid .cal__cell:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.datepick .cal__grid .cal__cell:disabled:hover {
  border-color: var(--line);
}

/* ---------- Avatar editor ---------- */
.avatar-crop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
}
.avatar-crop canvas {
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  background: var(--surface-2);
}
.avatar-crop canvas:active {
  cursor: grabbing;
}
.avatar-crop input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}
.avatar--lg {
  width: 80px;
  height: 80px;
  font-size: 26px;
  border-radius: 50%;
  overflow: hidden;
}
.avatar--lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-edit {
  display: flex;
  gap: var(--s4);
  align-items: center;
}
.avatar-edit__preview {
  position: relative;
  flex: none;
}
.avatar-edit__busy {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 16, 0.55);
  color: #fff;
}
.avatar-edit__body {
  min-width: 0;
  flex: 1;
}
.avatar-edit__name {
  font-size: var(--t-md);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.avatar-edit__role {
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin-top: 1px;
}
.avatar-edit__actions {
  display: flex;
  gap: var(--s2);
  flex: none;
  align-items: center;
}
@media (max-width: 560px) {
  .avatar-edit {
    flex-wrap: wrap;
  }
  .avatar-edit__actions {
    flex-basis: 100%;
  }
  .avatar-edit__actions .btn {
    flex: 1;
  }
}
@media (max-width: 480px) {
  .avatar--lg {
    width: 64px;
    height: 64px;
    font-size: 22px;
  }
}

/* ---------- Notifications ---------- */
.notif-btn {
  position: relative;
}
.notif-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 100px;
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  border: 1.5px solid var(--paper);
}
.menu--wide {
  min-width: min(316px, calc(100vw - 24px));
  max-width: min(360px, calc(100vw - 24px));
}
.notif-item {
  padding: var(--s3);
  border-radius: var(--r);
  margin-bottom: var(--s2);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.notif-item--warn {
  border-color: var(--amber);
  background: var(--amber-soft);
}
.notif-item--error {
  border-color: var(--red-line);
  background: var(--red-soft);
}
.notif-item__title {
  font-size: var(--t-sm);
  font-weight: 600;
}
.notif-item__body {
  font-size: var(--t-xs);
  color: var(--ink-2);
  line-height: 1.5;
  margin: 4px 0 var(--s2);
}
.notif-empty {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3);
  font-size: var(--t-sm);
  color: var(--ink-2);
  line-height: 1.5;
}
.notif-empty svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
  color: var(--green);
}

/* ---------- Account menu plan block ---------- */
.menu__plan {
  padding: var(--s3);
  margin-bottom: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.menu__plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.menu__plan-label {
  font-size: var(--t-sm);
  color: var(--ink-2);
}
.menu__plan-note {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-top: 6px;
}

/* ---------- Header rebalance ----------
   The old layout left a wide empty span between the title and the
   actions. Title and balance now sit together on the left, actions
   group on the right, with a brand mark filling the rail's absence on
   small screens. */
.topbar {
  gap: var(--s4);
}
.topbar__ctx {
  flex: 1;
  align-items: baseline;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  position: relative;
}
.topbar__notif {
  position: static;
}
.topbar__account {
  position: relative;
}
.icon-btn--avatar {
  width: 34px;
  height: 34px;
}
@media (max-width: 1024px) {
  .topbar__title {
    display: none;
  }
  .topbar__balance {
    display: flex;
  }
}
@media (max-width: 560px) {
  .topbar__balance span:first-child {
    display: none;
  }
  #newTradeBtn span,
  #newTradeBtn {
    font-size: var(--t-xs);
  }
}

/* ---------- Calendar: mobile ----------
   Below 620px the cells drop the currency figure (it cannot be read at
   that size) and carry a result bar instead; the amounts move into a
   tappable day list underneath, which also fixes the touch targets. */
.cal__mark {
  display: none;
  height: 3px;
  border-radius: 2px;
  background: var(--ink-4);
}
.cal__mark--win {
  background: var(--green);
}
.cal__mark--loss {
  background: var(--red);
}
.cal__dow-short {
  display: none;
}
.cal__list {
  display: none;
  list-style: none;
  margin: var(--s5) 0 0;
  padding: 0;
}
.cal__list-toggle {
  display: none;
  width: 100%;
  margin-top: var(--s3);
}
.cal__list-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--s3);
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  margin-bottom: 6px;
  cursor: pointer;
  text-align: left;
}
.cal__list-row[aria-pressed="true"] {
  border-color: var(--ink);
}
.cal__list-date {
  font-size: var(--t-sm);
  font-weight: 550;
}
.cal__list-count {
  font-size: var(--t-xs);
  color: var(--ink-3);
}

@media (max-width: 620px) {
  .cal__dow-long {
    display: none;
  }
  .cal__dow-short {
    display: inline;
  }
  .cal__grid,
  .cal__dow {
    gap: 3px;
  }
  .cal__cell {
    aspect-ratio: auto;
    min-height: 42px;
    padding: 4px 2px;
    align-items: center;
    justify-content: center;
    gap: 3px;
  }
  .cal__day {
    font-size: var(--t-sm);
    color: var(--ink);
  }
  .cal__pnl {
    display: none;
  }
  .cal__mark {
    display: block;
    width: 60%;
  }
  .cal__cell--win,
  .cal__cell--loss {
    background: var(--surface);
  }
  .cal__cell--win {
    border-color: var(--green-line);
  }
  .cal__cell--loss {
    border-color: var(--red-line);
  }
  .cal__list {
    display: block;
  }
  .cal__list-toggle {
    display: block;
  }
}

/* ---------- Review: mobile form ---------- */
@media (max-width: 720px) {
  .review-note,
  #rev_reflection {
    min-height: 150px;
    font-size: 16px;
  }
  /* 16px prevents iOS Safari zooming the viewport on focus, which is
     what makes a mobile form feel broken. */
  .input,
  .textarea,
  .select {
    font-size: 16px;
  }
  .field__label {
    font-size: var(--t-base);
  }
}

/* Touch targets: anything tappable clears 44px on coarse pointers. */
@media (pointer: coarse) {
  .btn {
    min-height: 42px;
  }
  .btn--sm {
    min-height: 36px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .chip {
    height: 34px;
    padding: 0 13px;
  }
  .segmented button {
    padding: 9px var(--s3);
  }
  .menu__item {
    padding: 11px var(--s3);
  }
  .explain-btn {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
}

/* Reduced motion already covered globally; charts additionally hold
   still rather than animating their cursor. */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--surface-2);
  }
}

.review-actions {
  display: flex;
  gap: var(--s3);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--s5);
}
@media (max-width: 560px) {
  .review-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .review-actions .btn {
    width: 100%;
  }
  .review-actions .field__hint {
    text-align: center;
  }
}
