/* public/member/member.css
   Shared styles for the member area.
   Uses the same palette as /app and /admin.
   ────────────────────────────────────────────────────────────── */

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

:root {
  --bg: #0b0e14;
  --bg-soft: #10151f;
  --card: #161b22;
  --card-hover: #1c212c;
  --border: #30363d;
  --border-soft: #232a36;
  --text: #e6edf3;
  --text-strong: #ffffff;
  --muted: #8b949e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --buy: #26a69a;
  --sell: #ef5350;
  --warn: #f59e0b;
  --sidebar-width: 220px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ═══ Layout ═══ */
/* Member pages now use the shared drawer nav (/shared/nav.js).
   The persistent sidebar is gone, so the layout is single-column. */
.member-layout {
  display: block;
  min-height: 100vh;
}

/* ═══ Sidebar ═══ */
.member-sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 900px) {
  .member-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    height: 100vh;
  }
  .member-sidebar.open {
    transform: translateX(0);
  }
}

.member-sidebar-header {
  padding: 8px 20px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.member-sidebar-header .logo { font-size: 22px; }
.member-sidebar-header .brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.member-sidebar-header .brand .top {
  font-size: 9px;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.member-sidebar-header .brand .name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-nav-section {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.member-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}
/* Sidebar links: no hover or active styling (removed per design). */
.member-nav-link .icon { font-size: 15px; line-height: 1; width: 18px; text-align: center; }
.member-nav-link .badge {
  margin-left: auto;
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 100px;
  font-family: ui-monospace, monospace;
}

.member-sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border-soft);
}

/* ═══ Main ═══ */
.member-main { min-width: 0; }

.member-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
@media (min-width: 901px) {
  .member-topbar .mobile-menu-btn { display: none; }
}
.member-topbar .mobile-menu-btn {
  background: var(--card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.member-topbar h1 {
  font-size: 15px;
  font-weight: 700;
}
.member-topbar .topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.member-topbar .btn {
  background: var(--card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.member-topbar .btn:hover { background: var(--border); }
.member-topbar .btn.icon { padding: 6px 10px; font-size: 14px; }
.member-topbar .btn.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.member-topbar .btn.danger:hover { background: rgba(239, 68, 68, 0.2); }

.member-content {
  padding: 24px 20px 60px;
  max-width: 1100px;
  margin: 0 auto;
}
@media (min-width: 901px) {
  .member-content { padding: 32px 40px 80px; }
}

/* ═══ Typography ═══ */
.member-page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.member-page-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ═══ Cards ═══ */
.member-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

/* ═══ Tile Grid ═══ */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.member-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-height: 130px;
}
.member-tile:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--card-hover);
  transform: translateY(-2px);
}
.member-tile.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.member-tile.disabled:hover { transform: none; border-color: var(--border); }

.member-tile .tile-icon { font-size: 26px; line-height: 1; }
.member-tile .tile-title { font-size: 15px; font-weight: 700; }
.member-tile .tile-desc { font-size: 12px; color: var(--muted); line-height: 1.5; flex: 1; }
.member-tile .tile-meta {
  font-size: 11px;
  font-weight: 600;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.member-tile .tile-meta.ok { color: var(--buy); }
.member-tile .tile-meta.warn { color: var(--warn); }
.member-tile .tile-meta.muted { color: var(--muted); }

.member-tile .tile-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.member-tile .tile-badge.live {
  background: rgba(38, 166, 154, 0.15);
  color: var(--buy);
  border: 1px solid rgba(38, 166, 154, 0.3);
}
.member-tile .tile-badge.soon {
  background: rgba(139, 148, 158, 0.1);
  color: var(--muted);
  border: 1px solid rgba(139, 148, 158, 0.2);
}
.member-tile .tile-badge.action {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

/* ═══ Overlay for mobile drawer ═══ */
.member-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.member-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 901px) {
  .member-overlay { display: none !important; }
}

/* ═══ Loading / Error screens ═══ */
.member-splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.member-splash.hidden { display: none; }
.member-splash .spinner {
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.member-splash p { color: var(--muted); font-size: 14px; }

/* ═══ Toasts ═══ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 320px;
  pointer-events: auto;
}
.toast.success { background: #065f46; }
.toast.error   { background: #7f1d1d; }
.toast.info    { background: #1e40af; }

/* ═══ Buttons ═══ */
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-hover);
  color: var(--text);
  transition: all 0.15s;
  text-decoration: none;
  gap: 6px;
}
.btn-small:hover { background: var(--border); }
.btn-small.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-small.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-small.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ═══ Account blocks (accounts page, plans page) ═══ */
.account-block {
  margin-bottom: 14px;
  padding: 18px 20px;
}
.account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.account-primary {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.account-secondary {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

/* ═══════════════════════════════════════════════════════════
   Plans page — Your Plans + Available Plans
   ═══════════════════════════════════════════════════════════ */

.plans-section { margin-bottom: 36px; }
.plans-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 8px; flex-wrap: wrap;
}
.plans-section-header h2 {
  font-size: 14px; font-weight: 800; letter-spacing: 0.02em;
}
.plans-section-header .count {
  font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--card-hover); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 100px;
}
.plans-section-desc {
  font-size: 12px; color: var(--muted); margin-bottom: 16px;
  max-width: 640px; line-height: 1.6;
}
.plans-empty {
  font-size: 13px; color: var(--muted);
  padding: 28px; text-align: center;
  background: var(--card); border: 1px dashed var(--border);
  border-radius: 12px;
}
.plans-empty a { color: var(--accent); font-weight: 600; }
.plans-empty .icon { font-size: 32px; display: block; margin-bottom: 8px; opacity: 0.5; }

/* ─── Your Plans — summary card per app ─── */
.sub-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 14px;
}
.sub-card:last-child { margin-bottom: 0; }
.sub-card .header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.sub-card .header .app-title {
  font-size: 15px; font-weight: 700; margin-bottom: 2px;
}
.sub-card .header .app-desc {
  font-size: 12px; color: var(--muted);
}

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; padding: 3px 10px;
  border-radius: 100px; text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.status-badge.active {
  background: rgba(38, 166, 154, 0.15); color: var(--buy);
  border: 1px solid rgba(38, 166, 154, 0.3);
}
.status-badge.trialing {
  background: rgba(37, 99, 235, 0.15); color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
}
.status-badge.sold {
  background: rgba(245, 158, 11, 0.15); color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.credit-stats {
  display: flex; gap: 20px; padding: 12px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  margin: 12px 0;
}
.credit-stats .stat { flex: 1; text-align: center; }
.credit-stats .stat-value {
  font-size: 20px; font-weight: 800;
  font-family: ui-monospace, monospace;
}
.credit-stats .stat-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px;
}
.credit-stats .stat.ok .stat-value { color: var(--buy); }
.credit-stats .stat.muted .stat-value { color: var(--muted); }

.expiry-line {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); padding: 6px 0;
}
.expiry-value { color: var(--text); font-weight: 600; }

.warning-box {
  font-size: 12px; font-weight: 600;
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 12px;
  display: flex; gap: 8px; align-items: flex-start;
  line-height: 1.5;
}
.warning-box.warn {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}
.warning-box.danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.warning-box.info {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
.warning-box a { color: inherit; text-decoration: underline; font-weight: 700; }

.actions-row {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}

/* ─── Available Plans — grid card ─── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.plan-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.plan-card .app-title { font-size: 15px; font-weight: 700; }
.plan-card .app-desc { font-size: 12px; color: var(--muted); flex: 1; line-height: 1.5; }
.plan-card .price-grid {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 0; border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft); margin: 12px 0;
}
.price-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px;
}
.price-row .tier { color: var(--muted); }
.price-row .amount { font-weight: 700; font-family: ui-monospace, monospace; }
.price-row .unit { color: var(--muted); font-size: 11px; }
.card-footnote {
  font-size: 11px; color: var(--muted);
  margin-bottom: 12px; line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   Accounts page — Section B (Credit Assignment)
   ═══════════════════════════════════════════════════════════ */

.assignment-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 14px;
}
.assignment-card:last-child { margin-bottom: 0; }
.assignment-card .header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 14px;
}
.assignment-card .header .app-title {
  font-size: 15px; font-weight: 700; margin-bottom: 2px;
}
.assignment-card .header .app-desc {
  font-size: 12px; color: var(--muted);
}

.assigned-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.assigned-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  font-size: 13px;
}
.assigned-row .check { font-size: 14px; }
.assigned-row .info { flex: 1; min-width: 0; }
.assigned-row .info .broker { font-weight: 600; }
.assigned-row .info .mode {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin-left: 6px;
}
.assigned-row .info .expires {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

.assignment-empty {
  font-size: 12px; color: var(--muted);
  padding: 12px 14px; border-radius: 8px;
  background: var(--bg-soft); border: 1px dashed var(--border);
  margin-bottom: 12px;
  text-align: center;
}

.assign-control {
  display: flex; gap: 8px; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--border-soft);
}
.assign-control select {
  flex: 1; padding: 9px 12px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
}
.assign-empty-note {
  font-size: 12px; color: var(--muted);
  padding: 12px; text-align: center;
  background: var(--bg-soft); border: 1px dashed var(--border);
  border-radius: 8px;
  margin-top: 12px;
}
.assign-empty-note a { color: var(--accent); font-weight: 600; }

@media (max-width: 640px) {
  .assign-control { flex-direction: column; align-items: stretch; }
  .assign-control button { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   Subscribe modal (Phase 3 — plan tier + quantity)
   ═══════════════════════════════════════════════════════════ */

#subscribe-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#subscribe-modal-backdrop.show { opacity: 1; pointer-events: auto; }

.subscribe-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.subscribe-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 15px;
  font-weight: 700;
}
.subscribe-modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.subscribe-modal-close:hover { color: var(--text); }

.subscribe-modal-body { padding: 20px 22px 22px; }

.subscribe-app-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.subscribe-app-header .app-icon { font-size: 28px; line-height: 1; }
.subscribe-app-header .app-info { min-width: 0; flex: 1; }
.subscribe-app-header .app-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.subscribe-app-header .app-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.subscribe-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.subscribe-plan-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.subscribe-plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}
.subscribe-plan-row:hover { background: var(--card-hover); }
.subscribe-plan-row input {
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.subscribe-plan-row .plan-label { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.subscribe-plan-row .plan-name { font-weight: 600; }
.subscribe-plan-row .plan-hint { font-size: 11px; color: var(--muted); }
.subscribe-plan-row .plan-price { font-weight: 700; font-family: ui-monospace, monospace; font-size: 13px; }
.subscribe-plan-row .plan-price .unit { font-weight: 500; font-size: 11px; color: var(--muted); }

.quantity-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
  margin-bottom: 10px;
}
.qty-btn {
  background: var(--card-hover);
  border: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 18px;
  transition: background 0.15s;
  line-height: 1;
}
.qty-btn:hover { background: var(--border); }
.quantity-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  padding: 12px 0;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.quantity-row input::-webkit-outer-spin-button,
.quantity-row input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quantity-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.quantity-hint a { color: var(--accent); font-weight: 600; }

.subscribe-summary {
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin: 16px 0;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
}
.summary-label { color: var(--muted); }
.summary-total {
  font-size: 18px;
  font-weight: 800;
  font-family: ui-monospace, monospace;
  color: var(--text);
}
.summary-subline {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.subscribe-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ═══════════════════════════════════════════════════════════
   Light theme overrides
   ═══════════════════════════════════════════════════════════ */
html[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-soft: #eef2f7;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-soft: #eef2f7;
  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --buy: #059669;
  --sell: #dc2626;
  --warn: #d97706;
}

/* Fix hardcoded dark colors in child rules */
html[data-theme="light"] .member-sidebar-header .brand .top {
  color: var(--accent);
}
html[data-theme="light"] .member-nav-link.active {
  background: rgba(37, 99, 235, 0.08);
}
html[data-theme="light"] .member-nav-link .badge {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
}
html[data-theme="light"] .member-topbar .btn.danger {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.2);
}
html[data-theme="light"] .toast {
  background: #1e293b;
  color: #fff;
}
html[data-theme="light"] .warning-box.warn {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.25);
  color: #92400e;
}
html[data-theme="light"] .warning-box.danger {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
  color: #991b1b;
}
html[data-theme="light"] .warning-box.info {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
  color: #1e40af;
}
html[data-theme="light"] .btn-small.btn-primary {
  color: #fff;
}
html[data-theme="light"] .tile-badge.action,
html[data-theme="light"] .status-badge.trialing {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
}
html[data-theme="light"] .status-badge.sold {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.3);
}

/* ─── Tier grouping (plans + accounts) ─── */
.tier-groups { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }

.tier-group {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}
.tier-group:first-child { border-top: none; padding-top: 0; }

.tier-group-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.tier-group-header .tier-name {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tier-group-header .tier-count {
  font-size: 10px; font-weight: 700;
  color: var(--muted);
  background: var(--card-hover);
  border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 100px;
}

.credit-list { display: flex; flex-direction: column; gap: 6px; }

.credit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  font-size: 12px;
}
.credit-row .credit-status { font-size: 12px; flex-shrink: 0; }
.credit-row .credit-bound { flex: 1; min-width: 0; }
.credit-row .credit-bound .broker { font-weight: 600; }
.credit-row .credit-bound .mode {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin-left: 6px;
}
.credit-row .credit-expiry {
  font-size: 11px; color: var(--muted);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}

.assigned-row.unassigned {
  border-style: dashed;
  opacity: 0.85;
}

/* ── cTrader Accounts summary (mirrors Risk Dash's stat grid) ── */
.account-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-soft);
}
.account-summary-tile {
  background: var(--card);
  padding: 14px 16px;
  text-align: center;
}
.account-summary-tile .label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 4px;
}
.account-summary-tile .value {
  font-size: 20px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-strong);
}
.account-summary-list {
  border-top: 1px solid var(--border-soft);
}
.account-summary-row {
  display: grid;
  grid-template-columns: 1fr 130px 80px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.account-summary-row:last-child { border-bottom: none; }
.account-summary-row .col-broker {
  min-width: 0;
}
.account-summary-row .col-broker .broker {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.account-summary-row .col-num {
  font-size: 12px;
  color: var(--muted);
}
.account-summary-row .col-mode {
  display: flex;
  align-items: center;
}
.account-summary-row .col-action {
  text-align: right;
}
.account-summary-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding-top: 8px;
  padding-bottom: 8px;
  background: var(--bg-soft);
}
@media (max-width: 640px) {
  /* Narrow screens: hide broker, compress columns so each row stays 1 line. */
  .account-summary-row {
    grid-template-columns: 1fr 70px 90px;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .account-summary-row .col-broker { display: none; }
  .account-summary-row .col-num { font-size: 11px; }
  .account-summary-row .status-badge { font-size: 9px; padding: 1px 6px; }
  .account-summary-row .col-action .btn-small {
    padding: 4px 8px;
    font-size: 11px;
  }
  /* Header still shows — but without the broker column */
  .account-summary-head { grid-template-columns: 1fr 70px 90px; }
  .account-summary-head .col-broker { display: none; }
}

/* ── Credit assignment table (per-app summary card) ── */
.assign-table { display: flex; flex-direction: column; }
.assign-row {
  display: grid;
  grid-template-columns: 90px 130px 1fr 100px;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.assign-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding-top: 8px;
  padding-bottom: 8px;
  background: var(--bg-soft);
}
.assign-row .col-exp { color: var(--muted); font-size: 12px; }
.assign-row .col-acc { min-width: 0; }
.assign-row .acc-name { font-weight: 600; }
.assign-row .acc-mode {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-left: 4px;
}
.assign-row .acc-missing { color: var(--muted); font-style: italic; font-size: 12px; }
.assign-row .col-act { text-align: right; }
.assign-row .assign-select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.assign-row .assign-select:focus { border-color: var(--accent); }
.assign-row.pair { align-items: start; }
.assign-row.pair .col-type,
.assign-row.pair .col-exp { padding-top: 18px; }
.assign-row.pair .col-act { padding-top: 16px; }
.assign-pair {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.assign-pair-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.assign-pair-label,
.assign-link-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.assign-intent {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}
.assign-intent-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 600;
}
.assign-intent-option:hover { border-color: var(--accent); }
.assign-intent-option input { accent-color: var(--accent); margin: 2px 0 0; }
.assign-intent-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}
.assign-intent-heading {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.assign-link { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.assign-link-role { margin-right: 6px; }
.assign-row-error {
  grid-column: 1 / -1;
  color: var(--sell);
  font-size: 12px;
  line-height: 1.4;
}
.assign-select option:disabled { color: var(--muted); }
.assign-dashboard-link { padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.col-empty { padding: 12px 0; text-align: center; color: var(--muted); }

@media (max-width: 720px) {
  /* Narrow screens: one line per row, smaller font, keep headers visible.
     Grid columns collapse to: type | expiry | account | action (compact). */
  .assign-row {
    grid-template-columns: 62px 78px 1fr auto;
    gap: 8px;
    padding: 8px 12px;
    font-size: 11px;
  }
  .assign-head {
    font-size: 9px;
    padding: 6px 12px;
  }
  .assign-row .col-exp { font-size: 11px; }
  .assign-row .acc-mode { font-size: 8px; margin-left: 3px; }
  .assign-row .btn-small { padding: 4px 8px; font-size: 11px; }
  .assign-row .assign-select { padding: 4px 6px; font-size: 11px; }
  /* Hide broker name when the account cell gets tight */
  .assign-row .acc-broker { display: none; }
}

/* ── /home blocks ── */
.home-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.home-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.home-block-head h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}
.home-block-summary {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

/* ── Subscription rows ── */
.sub-row {
  display: grid;
  grid-template-columns: 32px 1fr 100px 140px auto;
  gap: 14px;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--border-soft);
}
.sub-row:first-child { border-top: none; }
.sub-row-icon { display: flex; align-items: center; justify-content: center; }
.sub-row-icon img { display: block; }
.sub-row-name { font-weight: 700; font-size: 14px; }
.sub-row-plan { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sub-row-count { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.sub-row-action { text-align: right; }
.sub-row-inactive .sub-row-name { color: var(--muted); }
.sub-row-empty { display: block; text-align: center; padding: 20px; color: var(--muted); border: none; }

/* ── Upsell block ── */
.upsell-block {
  background: linear-gradient(135deg, rgba(37,99,235,0.10), rgba(37,99,235,0.04));
  border-color: rgba(37,99,235,0.25);
}
.upsell-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.upsell-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.upsell-sub { font-size: 12px; color: var(--muted); }
.social-links {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.social-links a {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.social-links a:hover { color: var(--text); }

@media (max-width: 720px) {
  .sub-row {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas:
      "icon name action"
      "icon plan count";
    gap: 8px 12px;
  }
  .sub-row-icon { grid-area: icon; }
  .sub-row-name { grid-area: name; }
  .sub-row-plan { grid-area: plan; }
  .sub-row-count { grid-area: count; text-align: right; }
  .sub-row-action { grid-area: action; }
}

/* ── /member/plans wizard ── */
.wizard-loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.wizard-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.wizard-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.wz-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}
.wz-section h4 {
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 14px 0;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wz-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.wz-optional { color: var(--muted); font-weight: 500; font-size: 11px; }

.wz-radios { display: flex; flex-wrap: wrap; gap: 10px; }
.wz-radios-col { flex-direction: column; gap: 8px; }
.wz-radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}
.wz-radio:hover { border-color: var(--accent); }
.wz-radio input { accent-color: var(--accent); margin: 0; }
.wz-radio input:checked + .wz-radio-label { color: var(--text-strong); font-weight: 700; }
.wz-radio:has(input:checked) { border-color: var(--accent); background: rgba(37,99,235,0.06); }

.wz-radio-wide { justify-content: space-between; flex: 1; }
.wz-radio-label { font-weight: 600; }

.wz-soon { margin-top: 12px; }
.wz-soon-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
}
.wz-soon-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wz-soon-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-soft);
  cursor: default;
}
.wz-soon-note { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.wz-radio-price { font-family: ui-monospace, monospace; font-size: 13px; font-weight: 700; display: inline-flex; align-items: baseline; gap: 6px; }
.wz-strike { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.wz-price { color: var(--text-strong); }
.wz-unit { color: var(--muted); font-weight: 500; font-size: 11px; }

.wz-qty { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); overflow: hidden; }
.wz-qty button {
  width: 40px; height: 40px;
  border: none; background: transparent;
  color: var(--text);
  font-size: 18px; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.wz-qty button:hover { background: var(--border); }
.wz-qty input {
  width: 60px;
  text-align: center;
  border: none; background: transparent;
  color: var(--text-strong);
  font-family: ui-monospace, monospace;
  font-size: 15px; font-weight: 700;
  outline: none;
}
.wz-qty input::-webkit-outer-spin-button,
.wz-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wz-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }

.wz-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  outline: none;
}
.wz-input:focus { border-color: var(--accent); }

.wz-trial {
  font-size: 12px;
  color: #4ade80;
  font-weight: 600;
  padding: 10px 14px;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 10px;
}

/* ── Right column ── */
.wizard-aside { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 90px; }
.wz-included {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.wz-included-app { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.wz-included-app img { width: 32px; height: 32px; display: block; flex-shrink: 0; }
.wz-included-name { font-weight: 800; font-size: 14px; margin-bottom: 2px; }
.wz-included-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.wz-included-head { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
.wz-included-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.wz-included-list li {
  font-size: 12px;
  padding-left: 20px;
  position: relative;
  line-height: 1.4;
}
.wz-included-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #4ade80;
  font-weight: 800;
}
.wz-accounts-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* ── Sticky footer ── */
.wizard-footer {
  position: sticky;
  bottom: 12px;
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 5;
}
.wz-total { display: flex; flex-direction: column; }
.wz-total-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 800; }
.wz-total-amount { font-size: 22px; font-weight: 800; font-family: ui-monospace, monospace; }

@media (max-width: 900px) {
  .wizard-layout { grid-template-columns: 1fr; }
  .wizard-aside { position: static; order: -1; }
}

.wizard-footer .wz-submit-btn {
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
}

/* ── Subscription controls card on /member/billing ── */
.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.sc-label { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.sc-hint { font-size: 12px; color: var(--muted); }
.sc-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  font-size: 12px;
  color: #fcd34d;
  line-height: 1.5;
}

/* ── Per-row auto-renew toggle ── */
.renew-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  vertical-align: middle;
}
.renew-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.renew-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 100px;
  transition: background 0.15s;
}
.renew-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.renew-toggle input:checked + .renew-slider { background: #10b981; }
.renew-toggle input:checked + .renew-slider::before { transform: translateX(16px); }
.renew-toggle input:disabled + .renew-slider { opacity: 0.5; cursor: wait; }
