/* ==========================================================================
   Trading Stash — Monochrome iOS Frost (Dark) & Cool iOS Alabaster (Light)
   Zero-build static CSS · Strict CSP · WCAG AA/AAA · >= 13px · >= 48px targets
   ========================================================================== */

:root,
[data-theme="dark"] {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Radii Scale */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 22px;
  --r-xl: 26px;
  --r-pill: 9999px;

  /* Dark Palette (Monochrome iOS Frost) */
  --bg-canvas: #07080A;
  --bg-canvas-subtle: #0C0E12;
  --surface-glass: rgba(20, 22, 27, 0.84);
  --surface-glass-elevated: rgba(28, 31, 38, 0.94);
  --surface-glass-hover: #21252E;
  --surface-pill: #1A1D24;
  --surface-input: #0F1116;

  --border-hairline: rgba(255, 255, 255, 0.085);
  --border-specular: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text-primary: #F4F6F9;
  --text-secondary: #A6AEBC;
  --text-muted: #828B9B;

  --cta-bg: #F4F6F9;
  --cta-bg-hover: #E2E6ED;
  --cta-text: #090A0D;
  --nav-active-bg: rgba(244, 246, 249, 0.10);

  --gain: #32D583;
  --gain-text: #4ADE95;
  --gain-soft: rgba(50, 213, 131, 0.12);
  --gain-border: rgba(50, 213, 131, 0.28);

  --loss: #FF6442;
  --loss-text: #FF7A5C;
  --loss-soft: rgba(255, 100, 66, 0.13);
  --loss-border: rgba(255, 100, 66, 0.30);

  --accent-info: #5BA8FF;
  --accent-info-soft: rgba(91, 168, 255, 0.13);
  --accent-info-border: rgba(91, 168, 255, 0.28);

  --warning: #F5B041;
  --warning-soft: rgba(245, 176, 65, 0.13);
  --warning-border: rgba(245, 176, 65, 0.28);

  --focus-ring: #60A5FA;
  --scrim: rgba(4, 5, 7, 0.68);
  --bar-track: rgba(255, 255, 255, 0.06);
  --grid-line: rgba(255, 255, 255, 0.06);

  --gain-glow: radial-gradient(110% 100% at 88% 0%, rgba(50, 213, 131, 0.17) 0%, rgba(50, 213, 131, 0.04) 44%, transparent 74%);
  --loss-glow: radial-gradient(110% 100% at 88% 0%, rgba(255, 100, 66, 0.19) 0%, rgba(255, 100, 66, 0.04) 44%, transparent 74%);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 12px 32px rgba(0, 0, 0, 0.42);
  --shadow-elevated: 0 1px 0 rgba(255, 255, 255, 0.11) inset, 0 22px 54px rgba(0, 0, 0, 0.72);
}

[data-theme="light"] {
  --bg-canvas: #F2F4F7;
  --bg-canvas-subtle: #E9EDF2;
  --surface-glass: rgba(255, 255, 255, 0.88);
  --surface-glass-elevated: rgba(255, 255, 255, 0.98);
  --surface-glass-hover: #F7F9FC;
  --surface-pill: #E8ECF2;
  --surface-input: #F6F8FA;

  --border-hairline: rgba(15, 23, 42, 0.09);
  --border-specular: rgba(255, 255, 255, 0.92);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text-primary: #0F141C;
  --text-secondary: #475467;
  --text-muted: #5F6D7E;

  --cta-bg: #11161F;
  --cta-bg-hover: #1E2736;
  --cta-text: #FFFFFF;
  --nav-active-bg: rgba(15, 20, 28, 0.075);

  --gain: #12804A;
  --gain-text: #0E6E3F;
  --gain-soft: rgba(18, 128, 74, 0.10);
  --gain-border: rgba(18, 128, 74, 0.24);

  --loss: #C93B1D;
  --loss-text: #B53216;
  --loss-soft: rgba(201, 59, 29, 0.10);
  --loss-border: rgba(201, 59, 29, 0.24);

  --accent-info: #0B63CE;
  --accent-info-soft: rgba(11, 99, 206, 0.09);
  --accent-info-border: rgba(11, 99, 206, 0.24);

  --warning: #A15C07;
  --warning-soft: rgba(161, 92, 7, 0.10);
  --warning-border: rgba(161, 92, 7, 0.24);

  --focus-ring: #0B63CE;
  --scrim: rgba(15, 20, 28, 0.36);
  --bar-track: rgba(15, 23, 42, 0.065);
  --grid-line: rgba(15, 23, 42, 0.07);

  --gain-glow: radial-gradient(110% 100% at 88% 0%, rgba(18, 128, 74, 0.10) 0%, rgba(18, 128, 74, 0.02) 48%, transparent 76%);
  --loss-glow: radial-gradient(110% 100% at 88% 0%, rgba(201, 59, 29, 0.10) 0%, rgba(201, 59, 29, 0.02) 48%, transparent 76%);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.90) inset, 0 4px 16px rgba(15, 23, 42, 0.045), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-elevated: 0 1px 0 rgba(255, 255, 255, 0.95) inset, 0 18px 44px rgba(15, 23, 42, 0.14);
}

/* Base Reset & Floor */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: clip;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1, h2, h3, h4, p, ul, ol {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

/* Focus Visibility */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Accessibility Utility */
.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;
}

/* Typography Helpers */
.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

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

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.text-gain {
  color: var(--gain-text);
}

.text-loss {
  color: var(--loss-text);
}

/* Surfaces & Cards */
.card {
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-card);
}

.card-elevated {
  background: var(--surface-glass-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--shadow-elevated);
}

.hero-pnl-card {
  background-image: var(--gain-glow);
  background-color: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-xl);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-card);
}

.hero-pnl-card.is-loss {
  background-image: var(--loss-glow);
}

/* Brand Mark */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  min-height: 48px;
  min-width: 48px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-xs);
  background: var(--cta-bg);
  color: var(--cta-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark-lg {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

/* Non-interactive Status Pill Badges (>= 13px floor) */
.pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  white-space: nowrap;
}

.pill-gain {
  background: var(--gain-soft);
  border-color: var(--gain-border);
  color: var(--gain-text);
  font-weight: 600;
}

.pill-loss {
  background: var(--loss-soft);
  border-color: var(--loss-border);
  color: var(--loss-text);
  font-weight: 600;
}

.pill-info {
  background: var(--accent-info-soft);
  border-color: var(--accent-info-border);
  color: var(--accent-info);
  font-weight: 600;
}

.pill-warning {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
  font-weight: 600;
}

/* Interactive Controls — Strict >= 48x48px DOM Bounding Box */
.btn,
button,
input,
select,
.nav-item,
.tab-item,
.profile-trigger,
.disclosure-toggle {
  min-height: 48px;
  min-width: 48px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
  white-space: nowrap;
  text-align: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--cta-bg);
  color: var(--cta-text);
  border-color: var(--cta-bg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--cta-bg-hover);
  border-color: var(--cta-bg-hover);
}

.btn-secondary {
  background: var(--surface-pill);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-glass-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-hairline);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--loss-soft);
  color: var(--loss-text);
  border-color: var(--loss-border);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--loss);
}

.btn-full {
  width: 100%;
}

/* Recessed Form Inputs */
.input {
  width: 100%;
  min-width: 0;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 140ms ease;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.input:focus-visible {
  border-color: var(--focus-ring);
}

.input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Segmented Control */
.segmented {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  gap: 2px;
}

.segmented button {
  flex: 1 1 0;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.segmented button:hover:not([aria-pressed="true"]) {
  color: var(--text-primary);
}

.segmented button[aria-pressed="true"] {
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 600;
}

/* Error Banner (Rollback & Persistence Failures) */
.error-banner-slot {
  display: block;
}

.error-banner-slot:empty {
  display: none;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 16px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: var(--loss-soft);
  border: 1px solid var(--loss-border);
  color: var(--loss-text);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  min-height: 52px;
}

.error-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
}

.error-banner-dismiss {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--loss-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-banner-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Toast Notification */
.toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface-glass-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-elevated);
  font-size: 14px;
  font-weight: 500;
}

/* Accessible Confirm Modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   LANDING PAGE (index.html)
   ========================================================================== */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-header {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.landing-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.landing-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.landing-main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 40px;
  align-items: center;
}

.landing-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
}

.landing-h1 {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: var(--text-primary);
}

.landing-subtitle {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 520px;
}

.landing-ctas {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.landing-features {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.feature-subcard {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-subcard-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.feature-subcard-desc {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Landing Hero Preview Card */
.landing-preview {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.preview-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.preview-kpi {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-top: 6px;
}

.preview-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.preview-meta strong {
  color: var(--text-primary);
}

.preview-chart-wrap {
  width: 100%;
  padding: 8px 0 4px;
}

.preview-sparkline {
  width: 100%;
  height: auto;
  overflow: visible;
}

.preview-habits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.habit-mini {
  padding: 14px 16px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.habit-mini-gain {
  background: var(--gain-soft);
  border: 1px solid var(--gain-border);
}

.habit-mini-loss {
  background: var(--loss-soft);
  border: 1px solid var(--loss-border);
}

.habit-mini-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.habit-mini-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.habit-mini-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.landing-footer {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.landing-mobile-credit {
  display: none;
}

/* ==========================================================================
   LOGIN PAGE (login.html)
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-header {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 32px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 32px 28px;
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.login-callout {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--accent-info-soft);
  border: 1px solid var(--accent-info-border);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.login-callout strong {
  color: var(--accent-info);
}

.login-callout.is-highlighted {
  border-color: var(--accent-info);
  box-shadow: 0 0 0 2px var(--accent-info-soft);
}

.login-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 4px 0;
}

.login-security-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-footer {
  text-align: center;
  padding: 16px 16px 24px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   APP SHELL (app.html) — 820px Left Sidebar <-> Floating Bottom Tab Bar
   ========================================================================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg-canvas);
}

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--bg-canvas-subtle);
  border-right: 1px solid var(--border-hairline);
  padding: 18px 14px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
}

.sidebar-brand {
  padding: 0 6px 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--surface-glass-hover);
}

.nav-item.is-active,
.nav-item[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--text-primary);
  border-color: var(--border-hairline);
  font-weight: 600;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.sidebar-theme-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 0 16px;
}

.sidebar-credit {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 6px;
}

/* Main Content Column */
.app-content {
  flex: 1;
  min-width: 0;
  margin-left: 224px;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-heading {
  min-width: 0;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  max-width: 240px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.profile-trigger:hover {
  background: var(--surface-glass-hover);
  border-color: var(--border-strong);
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--surface-pill);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-circle-lg {
  width: 52px;
  height: 52px;
  font-size: 16px;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main-wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 24px 32px;
  flex: 1;
}

/* Mobile Floating Bottom Tab Bar (< 820px) */
.bottom-tabs {
  display: none;
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  padding: 6px;
  border-radius: var(--r-lg);
  background: var(--surface-glass-elevated);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: var(--shadow-elevated);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px 2px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background-color 140ms ease, color 140ms ease;
}

.tab-item.is-active,
.tab-item[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--text-primary);
  font-weight: 600;
}

/* ==========================================================================
   SETTINGS VIEW (#/settings)
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.settings-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.settings-card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-input-wrap {
  flex: 1 1 140px;
  min-width: 0;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.appearance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.appearance-row .segmented {
  min-width: 240px;
}

.security-inner {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.security-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.security-copy strong {
  font-size: 14px;
  font-weight: 600;
}

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.balance-input-wrap {
  width: 170px;
  max-width: 100%;
}

.data-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Exchange Cards */
.exchange-block {
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.exchange-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.exchange-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exchange-name {
  font-size: 15px;
  font-weight: 700;
}

.exchange-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.guide-details {
  border-radius: var(--r-sm);
  background: var(--surface-glass);
  border: 1px solid var(--border-hairline);
  overflow: hidden;
}

.guide-details summary {
  list-style: none;
  cursor: pointer;
  padding: 0 14px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.guide-details summary::-webkit-details-marker {
  display: none;
}

.guide-chevron {
  transition: transform 160ms ease;
  flex-shrink: 0;
}

.guide-details[open] .guide-chevron {
  transform: rotate(180deg);
}

.guide-steps {
  padding: 0 16px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-steps strong {
  color: var(--text-primary);
}

/* ==========================================================================
   S1 PLACEHOLDER VIEWS (#/dashboard, #/trades, #/setup)
   ========================================================================== */
.placeholder-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.placeholder-hero {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.placeholder-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.placeholder-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.placeholder-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.placeholder-stat {
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.placeholder-stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.placeholder-stat-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}

.placeholder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   OFFLINE TEST HARNESS (tests.html)
   ========================================================================== */
.tests-body {
  padding: 24px 16px 48px;
}

.tests-shell {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tests-header {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tests-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tests-summary {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 700;
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
}

.tests-summary[data-status="pass"] {
  background: var(--gain-soft);
  border-color: var(--gain-border);
  color: var(--gain-text);
}

.tests-summary[data-status="fail"] {
  background: var(--loss-soft);
  border-color: var(--loss-border);
  color: var(--loss-text);
}

.tests-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tests-row {
  padding: 14px 16px;
  border-radius: var(--r-md);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.tests-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tests-row-title {
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

.tests-row-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  background: var(--surface-input);
  color: var(--loss-text);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (1060px / 820px / 640px / 400px)
   ========================================================================== */
@media (max-width: 1060px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .landing-main {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 16px;
  }

  .placeholder-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 819px) {
  .sidebar {
    display: none;
  }

  .app-content {
    margin-left: 0;
  }

  .bottom-tabs {
    display: grid;
  }

  .app-topbar {
    padding: 14px 14px 8px;
  }

  .app-main-wrap {
    padding: 8px 14px 96px;
  }

  .profile-trigger {
    padding: 4px;
    justify-content: center;
    width: 48px;
    height: 48px;
  }

  .profile-name {
    display: none;
  }

  .exchange-form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .landing-header {
    padding: 12px 16px;
  }

  .landing-desktop-credit,
  .landing-demo-top {
    display: none;
  }

  .landing-mobile-credit {
    display: inline-flex;
  }

  .landing-main {
    padding: 8px 16px 32px;
    gap: 20px;
  }

  .landing-h1 {
    font-size: 32px;
    line-height: 1.12;
  }

  .landing-ctas {
    width: 100%;
  }

  .landing-ctas .btn {
    flex: 1 1 140px;
  }

  .landing-features {
    grid-template-columns: 1fr;
  }

  .landing-preview {
    padding: 18px;
  }

  .preview-kpi {
    font-size: 30px;
  }

  .landing-footer {
    padding: 16px;
    justify-content: center;
    text-align: center;
  }

  .login-header {
    padding: 12px 16px;
  }

  .login-card {
    padding: 24px 20px;
  }

  .settings-card {
    padding: 16px;
  }

  .appearance-row .segmented {
    width: 100%;
    min-width: 0;
  }

  .balance-input-wrap {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .app-topbar {
    padding: 12px 10px 6px;
  }

  .app-main-wrap {
    padding: 6px 10px 92px;
  }

  .preview-habits {
    gap: 8px;
  }

  .habit-mini {
    padding: 12px;
  }

  .habit-mini-val {
    font-size: 18px;
  }

  .data-actions-grid {
    gap: 8px;
  }

  .data-actions-grid .btn {
    padding: 0 12px;
  }
}

/* ==========================================================================
   REUSABLE SHEET (Bottom Sheet < 820px <-> Right Slide-Over >= 820px)
   & VIEWPORT-CLAMPED ACTION MENU POPOVER (⋮)
   ========================================================================== */
.action-menu {
  position: fixed;
  z-index: 120;
  min-width: 164px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-menu-item {
  width: 100%;
  min-height: 48px;
  min-width: 148px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.action-menu-item:hover {
  background: var(--surface-glass-hover);
}

.action-menu-item.is-destructive {
  color: var(--loss-text);
}

.action-menu-item.is-destructive:hover {
  background: var(--loss-soft);
}

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--scrim);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  padding: 12px;
}

.sheet-panel {
  width: 100%;
  max-width: 470px;
  max-height: calc(100vh - 24px);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-grabber {
  display: none;
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  margin: 10px auto 2px;
  flex-shrink: 0;
}

.sheet-header {
  padding: 16px 16px 14px 20px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.sheet-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.sheet-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.sheet-close-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-hairline);
  background: var(--surface-pill);
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-close-btn:hover:not(:disabled) {
  background: var(--surface-glass-hover);
  border-color: var(--border-strong);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-error {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--loss-soft);
  border: 1px solid var(--loss-border);
  color: var(--loss-text);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.sheet-footer {
  padding: 14px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.textarea {
  width: 100%;
  min-width: 0;
  min-height: 104px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  transition: border-color 140ms ease;
}

.textarea::placeholder {
  color: var(--text-muted);
}

.textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.textarea:focus-visible {
  border-color: var(--focus-ring);
}

.select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

.select:hover:not(:disabled) {
  border-color: var(--border-strong);
}

/* ==========================================================================
   SET UP PLAYBOOK VIEW (#/setup)
   ========================================================================== */
.setup-root {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-mobile-bar {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.setup-mobile-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-mobile-top-row .segmented {
  flex: 1 1 0;
  min-width: 0;
}

.setup-mobile-top-row .segmented button {
  padding: 0 8px;
  font-size: 13px;
  white-space: nowrap;
}

.setup-mobile-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
}

.setup-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.setup-col-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.setup-col-heading {
  min-width: 0;
  flex: 1 1 220px;
}

.setup-col-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.setup-col-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.setup-col-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.archive-toggle-btn[aria-pressed="true"] {
  background: var(--nav-active-bg);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.setup-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.setup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.setup-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 140px;
}

.setup-card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.setup-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.setup-strategy-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.strategy-tile {
  padding: 14px 14px 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.strategy-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.strategy-name-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.strategy-name {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.strategy-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.strategy-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.strategy-template {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.confluence-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.confluence-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confluence-tile {
  padding: 10px 10px 10px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.confluence-tile-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.confluence-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.confluence-name {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.confluence-usage {
  font-size: 13px;
  color: var(--text-muted);
}

.confluence-footer-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  padding-top: 4px;
}

.icon-menu-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.icon-menu-btn:hover {
  background: var(--surface-glass-hover);
  color: var(--text-primary);
}

.icon-menu-btn-pill {
  background: var(--surface-pill);
  border-color: var(--border-hairline);
}

.icon-menu-btn-pill:hover {
  border-color: var(--border-strong);
}

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-toggle {
  min-height: 48px;
  min-width: 48px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.chip-toggle:hover:not([aria-pressed="true"]) {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chip-toggle[aria-pressed="true"] {
  background: var(--cta-bg);
  color: var(--cta-text);
  border-color: var(--cta-bg);
  font-weight: 600;
}

.inline-create-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-create-row .input {
  flex: 1 1 160px;
}

.setup-empty {
  padding: 18px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.is-archived {
  opacity: 0.72;
  border-style: dashed;
}

@media (max-width: 979px) {
  .setup-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 819px) {
  .sheet-scrim {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .sheet-panel {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 26px 26px 0 0;
  }

  .sheet-grabber {
    display: block;
  }

  .setup-mobile-bar {
    display: flex;
  }

  .setup-desktop-only {
    display: none;
  }

  .setup-col[data-mobile-hidden="true"] {
    display: none;
  }

  .setup-card {
    padding: 16px;
  }

  .confluence-card {
    padding: 16px;
  }
}

@media (max-width: 400px) {
  .setup-card {
    padding: 14px;
  }

  .strategy-tile {
    padding: 12px;
  }

  .confluence-card {
    padding: 14px;
  }

  .confluence-tile {
    padding: 8px 8px 8px 12px;
  }

  .sheet-body {
    padding: 14px 14px;
  }

  .sheet-header {
    padding: 12px 12px 12px 16px;
  }

  .sheet-footer {
    padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  }
}

/* ==========================================================================
   TRADES JOURNAL VIEW (#/trades)
   ========================================================================== */
.trades-root {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.trades-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.trades-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.filter-chip {
  min-height: 48px;
  min-width: 48px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-hairline);
  background: var(--surface-pill);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.filter-chip:hover:not([aria-pressed="true"]) {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.filter-chip[aria-pressed="true"] {
  background: var(--cta-bg);
  color: var(--cta-text);
  border-color: var(--cta-bg);
  font-weight: 600;
}

.trades-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.trades-date-input {
  width: 152px;
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
}

.switch-pill {
  min-height: 48px;
  min-width: 48px;
  padding: 0 12px 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-hairline);
  background: var(--surface-pill);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 140ms ease, color 140ms ease;
}

.switch-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.switch-pill[aria-checked="true"] {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.switch-track {
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  padding: 2px;
  display: inline-flex;
  align-items: center;
  transition: background-color 160ms ease;
  flex-shrink: 0;
}

.switch-thumb {
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--cta-bg);
  transition: transform 160ms ease;
}

.switch-pill[aria-checked="true"] .switch-track {
  background: var(--gain);
}

.switch-pill[aria-checked="true"] .switch-thumb {
  transform: translateX(16px);
  background: #FFFFFF;
}

.trades-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-p3-tag {
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

/* Desktop / Tablet 9-Column Table (>= 820px) */
.trades-table-card {
  padding: 4px 0;
  overflow: hidden;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.trades-table th {
  padding: 12px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}

.trades-table td {
  padding: 12px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}

.trades-table tbody tr:last-child td {
  border-bottom: 0;
}

.trades-table tbody tr:hover {
  background: var(--surface-glass-hover);
}

.trade-row-hidden {
  opacity: 0.68;
}

.trade-pair-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.trade-symbol {
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.trade-badge-compact {
  padding: 3px 8px;
  font-size: 13px;
}

.trade-pnl-val {
  font-weight: 700;
  white-space: nowrap;
}

.trade-roi-val {
  font-weight: 600;
  white-space: nowrap;
}

.trade-fee-val {
  color: var(--text-secondary);
  white-space: nowrap;
}

.trade-strat-pill {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.trade-remarks-cell {
  max-width: 190px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-action-col {
  width: 56px;
  text-align: right;
}

/* Mobile Stacked Cards (< 820px) */
.trades-card-list {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.trade-card {
  padding: 14px 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.trade-card-hidden {
  opacity: 0.72;
  border-style: dashed;
}

.trade-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trade-card-mid {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.trade-card-pnl-group {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.trade-card-pnl {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}

.trade-card-roi {
  font-size: 13px;
  font-weight: 600;
}

.trade-card-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.trade-card-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.trade-card-remarks {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 140px;
  min-width: 0;
}

.trades-empty {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

/* Edit & Manual Add Trade Sheet Components */
.trade-summary-box {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trade-summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.trade-summary-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.autofill-note {
  font-size: 13px;
  font-weight: 500;
  color: var(--gain-text);
}

.removable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.removable-chip {
  min-height: 48px;
  min-width: 48px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-pill);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.removable-chip:hover {
  border-color: var(--loss-border);
  background: var(--loss-soft);
  color: var(--loss-text);
}

.leverage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.leverage-chip {
  min-height: 48px;
  min-width: 48px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-hairline);
  background: var(--surface-pill);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.leverage-chip:hover:not([aria-pressed="true"]) {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.leverage-chip[aria-pressed="true"] {
  background: var(--cta-bg);
  color: var(--cta-text);
  border-color: var(--cta-bg);
}

.trade-form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.trade-form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.trade-pair-side-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 10px;
  align-items: end;
}

.trade-pair-side-row .segmented {
  width: 100%;
}

/* Switch 9-col table to spacious stacked cards below 1100px (includes 820px tablet next to sidebar) */
@media (max-width: 1099px) {
  .trades-table-card {
    display: none;
  }

  .trades-card-list {
    display: flex;
  }
}

@media (max-width: 819px) {
  .trades-date-range {
    width: 100%;
  }

  .trades-date-input {
    flex: 1 1 130px;
    width: auto;
  }
}

@media (max-width: 520px) {
  .trade-form-grid-2,
  .trade-pair-side-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .trade-form-grid-3 {
    grid-template-columns: 1fr;
  }

  .leverage-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ==========================================================================
   DASHBOARD & ANALYTICS VIEW (#/dashboard)
   ========================================================================== */
.dash-root {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-tier {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-tier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-tier-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dash-tier-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* Tier 1 — Headline KPI Grid */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.kpi-card.hero-pnl-card {
  border-radius: var(--r-lg);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.kpi-value-split {
  font-size: 22px;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* S5 Placeholder Strip (Equity Curve + PnL Calendar) */
.dash-s5-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dash-s5-card {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.dash-s5-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-s5-title {
  font-size: 15px;
  font-weight: 700;
}

/* Tier 2 & Tier 3 — 4-Col Desktop / 2-Col Tablet / 1-Col Mobile Grid */
.dash-analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.dash-widget {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.dash-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-widget-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.dash-rollup-seg {
  max-width: 100%;
}

.dash-rollup-seg button {
  padding: 0 10px;
  font-size: 13px;
}

/* Habit Split & Long/Short Cards */
.habit-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-box {
  padding: 12px 14px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.habit-box-gain {
  background: var(--gain-soft);
  border: 1px solid var(--gain-border);
}

.habit-box-loss {
  background: var(--loss-soft);
  border: 1px solid var(--loss-border);
}

.habit-box-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-box-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.habit-box-val {
  font-size: 15px;
  font-weight: 700;
}

.habit-box-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.side-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.side-mini {
  padding: 10px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.side-mini-head {
  font-size: 13px;
  color: var(--text-muted);
}

.side-mini-val {
  font-size: clamp(13px, 1.05vw, 15px);
  font-weight: 700;
  white-space: nowrap;
  overflow-wrap: normal;
}

.side-mini-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Ranked Horizontal Metric Bars */
.metric-bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.metric-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.metric-bar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.metric-bar-val {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.metric-bar-track {
  width: 100%;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--bar-track);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--text-secondary);
  min-width: 4px;
}

.metric-bar-fill.is-gain {
  background: var(--gain);
}

.metric-bar-fill.is-loss {
  background: var(--loss);
}

.metric-bar-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* Win/Loss Donut Widget */
.donut-layout {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.donut-svg {
  flex-shrink: 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1 1 90px;
}

.donut-legend-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.donut-legend-val {
  font-size: 14px;
  font-weight: 700;
}

.donut-footnote {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: auto;
}

/* Best & Worst Coins ($) */
.coin-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.coin-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.coin-col-losers {
  border-left: 1px solid var(--border-hairline);
  padding-left: 12px;
}

.coin-col-head {
  font-size: 13px;
  font-weight: 600;
}

.coin-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 13px;
}

.coin-name {
  font-weight: 700;
  color: var(--text-primary);
}

.coin-count {
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 500;
}

/* Hold Time Histogram */
.hold-summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.histogram-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-top: auto;
}

.dash-empty-note {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 0;
}

@media (max-width: 1219px) {
  .dash-analytics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1099px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 819px) {
  .dash-analytics-grid,
  .dash-s5-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 639px) {
  .dash-kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 30px;
  }
}

/* ==========================================================================
   S5: EQUITY CURVE, INTERACTIVE PNL CALENDAR & CALENDAR CLOSE-DAY BANNER
   ========================================================================== */
.dash-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.equity-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.equity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.equity-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.equity-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-top: auto;
}

.cal-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-nav-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.cal-month-label {
  font-size: 14px;
  font-weight: 700;
  min-width: 72px;
  text-align: center;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  text-align: center;
}

.cal-weekday {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-cell {
  min-height: 58px;
  min-width: 0;
  padding: 6px 6px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  text-align: left;
  overflow: hidden;
}

.cal-spacer {
  background: transparent;
}

.cal-empty {
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
}

.cal-day {
  min-height: 58px;
  min-width: 48px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 120ms ease, border-color 140ms ease, filter 140ms ease;
}

.cal-day:hover {
  filter: brightness(1.06);
}

.cal-gain {
  background: var(--gain-soft);
  border-color: var(--gain-border);
  color: var(--gain-text);
}

.cal-loss {
  background: var(--loss-soft);
  border-color: var(--loss-border);
  color: var(--loss-text);
}

.cal-cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  width: 100%;
  font-size: 13px;
  line-height: 1.15;
}

.cal-cell-day {
  color: var(--text-secondary);
  font-weight: 600;
}

.cal-empty .cal-cell-day {
  color: var(--text-muted);
  font-weight: 500;
}

.cal-cell-count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.cal-cell-pnl {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  letter-spacing: -0.03em;
}

.cal-cell-dash {
  font-size: 13px;
  color: var(--text-muted);
}

/* Calendar Close-Day Filter Banner on #/trades */
.trades-close-day-banner {
  padding: 8px 12px 8px 16px;
  border-radius: var(--r-md);
  border-color: var(--accent-info-border);
  background: var(--accent-info-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.trades-close-day-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-info);
}

@media (max-width: 979px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Exact 360px 7x48px Flush PnL Calendar Overflow Proof (UI/UX §5.3) */
@media (max-width: 400px) {
  .app-main-wrap {
    padding: 6px 8px 92px;
  }

  .cal-card {
    margin: 0 -5px;
    padding: 14px 0 0;
    overflow: hidden;
  }

  .cal-head {
    padding: 0 10px;
  }

  .cal-weekdays {
    padding: 0;
    gap: 0;
  }

  .cal-grid {
    grid-template-columns: repeat(7, minmax(48px, 1fr));
    gap: 0;
    border-top: 1px solid var(--border-hairline);
  }

  .cal-cell {
    min-width: 48px;
    min-height: 48px;
    padding: 4px 1px;
    border-radius: 0;
    border: 0;
    border-right: 1px solid var(--border-hairline);
    border-bottom: 1px solid var(--border-hairline);
    align-items: center;
    text-align: center;
  }

  .cal-cell:nth-child(7n) {
    border-right: 0;
  }

  .cal-cell-top {
    justify-content: center;
  }

  .cal-cell-count {
    display: none;
  }

  .cal-cell-pnl {
    font-size: 13px;
    letter-spacing: -0.04em;
  }
}


/* ==========================================================================
   PHASE 3: CLOUD AUTH GATES, 2FA ENROLLMENT & OPT-IN IMPORT BANNER
   ========================================================================== */
.auth-gate-shell {
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-gate-card {
  width: 100%;
  max-width: 440px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.auth-gate-heading-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.auth-gate-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.auth-gate-subtitle {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.auth-gate-email {
  max-width: 100%;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.auth-gate-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-gate-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-gate-error {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--loss-soft);
  border: 1px solid var(--loss-border);
  color: var(--loss-text);
  font-size: 13px;
  text-align: left;
  line-height: 1.45;
}

.otp-input {
  width: 100%;
  min-height: 52px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.qr-enroll-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.qr-frame {
  padding: 14px;
  border-radius: var(--r-md);
  background: #FFFFFF;
  border: 1px solid var(--border-hairline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  width: 184px;
  height: 184px;
  display: block;
}

.totp-secret-box {
  width: 100%;
  padding: 8px 10px 8px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.totp-secret-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  text-align: left;
}

.cloud-import-banner {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cloud-import-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 240px;
}

.cloud-import-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.cloud-import-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.cloud-import-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.security-email {
  font-size: 13px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.security-cloud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.login-callout.is-error {
  background: var(--loss-soft);
  border-color: var(--loss-border);
  color: var(--loss-text);
}


/* ==========================================================================
   STORY S7: LIVE EXCHANGE CONNECTION METADATA & ACTIONS
   ========================================================================== */
.exchange-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exchange-meta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  font-size: 13px;
  color: var(--text-secondary);
}

.exchange-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.exchange-key-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 3px 8px;
  border-radius: var(--r-xs);
  background: var(--surface-pill);
  border: 1px solid var(--border-hairline);
}

.exchange-status-msg {
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-input);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.exchange-status-msg.is-error {
  background: var(--loss-soft);
  border-color: var(--loss-border);
  color: var(--loss-text);
}

.exchange-status-msg.is-ok {
  background: var(--gain-soft);
  border-color: var(--gain-border);
  color: var(--gain-text);
}

/* Story S8: Accessible >= 48px Read-Only Confirmation Checkbox */
.exchange-readonly-check {
  min-height: 48px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
  transition: border-color 140ms ease, color 140ms ease;
}

.exchange-readonly-check:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.exchange-readonly-check:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.exchange-readonly-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--gain);
  cursor: pointer;
}
