.portal-page.active {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.topbar .brand-portal-wordmark {
  display: none;
}

body:has(#portalPage.active) {
  --topbar-height: 56px;
}

body:has(#portalPage.active) .topbar {
  background: var(--brand-color);
}

body:has(#portalPage.active) .topbar-inner {
  justify-content: center;
}

body:has(#portalPage.active) .topbar-brand {
  display: flex;
}

body:has(#portalPage.active) .topbar-end,
body:has(#portalPage.active) .topbar .brand-name,
body:has(#portalPage.active) .topbar::after {
  display: none;
}

body:has(#portalPage.active) .topbar .brand-portal-wordmark {
  display: inline-flex;
}

body:has(#portalPage.active) .topbar .brand {
  gap: 6px;
  font-size: 18px;
}

body:has(#portalPage.active) .topbar .brand-logo {
  width: 34px;
  height: 34px;
}

body:has(#portalPage.active) .topbar .brand,
body:has(#portalPage.active) .topbar .brand-wordmark {
  color: #fff;
}

body:has(#portalPage.active) .topbar .brand-symbol {
  filter: brightness(0) invert(1);
}

body:has(#portalPage.active) .topbar .brand:focus-visible {
  outline-color: var(--dm-line, #fff);
}

@media (max-width: 1024px) {
  body:has(#portalPage.active) {
    --topbar-height: 44px;
  }

  body:has(#portalPage.active) .topbar .brand {
    font-size: 15px;
  }

  body:has(#portalPage.active) .topbar .brand-logo {
    width: 28px;
    height: 28px;
  }
}

/* Hide the window scroll indicator while the portal is active: some
   panels overflow the viewport and some do not, so a classic (non
   overlay) scrollbar appearing and disappearing shifts the layout
   between panels. The page remains scrollable. */
html:has(#portalPage.active) {
  scrollbar-width: none;
}

html:has(#portalPage.active)::-webkit-scrollbar {
  display: none;
  width: 0;
}

@media (max-width: 1024px) and (pointer: coarse) {
  html:has(#portalPage.active),
  body:has(#portalPage.active) {
    overscroll-behavior-y: none;
  }
}

.portal-portal {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: calc(100vh - var(--topbar-height, 64px));
  min-height: calc(100dvh - var(--topbar-height, 64px));
  align-items: stretch;
  align-content: start;
  background: var(--portal-sidebar);
}

.portal-portal-nav {
  display: flex;
  position: sticky;
  top: var(--topbar-height, 64px);
  z-index: 15;
  height: calc(100vh - var(--topbar-height, 64px));
  align-self: start;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 16px 12px 0;
  border-right: 0.5px solid var(--line);
  background: var(--portal-sidebar);
  /* Promote to its own compositor layer so the sticky sidebar tracks
     sub-pixel trackpad scrolling without jittering. */
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

.portal-tab-list {
  display: flex;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
  gap: 4px;
}

.portal-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 0;
  color: var(--portal-ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.portal-tab svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.portal-tab.active {
  background: var(--portal-sidebar-hover);
  color: var(--portal-ink);
}

@media (hover: hover) {
  .portal-tab:hover { background: var(--portal-sidebar-hover); color: var(--portal-ink); }
}

.portal-tab:active {
  background: var(--portal-sidebar-press);
}

.portal-portal-main {
  min-width: 0;
  max-width: 100%;
  padding: 0 0 40px;
  background: var(--bg);
}

.portal-page-body {
  width: 100%;
  min-width: 0;
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 28px 0;
  overflow-x: hidden;
  overflow-x: clip;
}

.portal-panel,
.portal-section {
  min-width: 0;
  max-width: 100%;
}

.portal-page-heading {
  margin-bottom: 40px;
}

.portal-page-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.portal-page-icon {
  display: inline-flex;
  position: relative;
  top: 1px;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-left: -10px;
  border-radius: 0;
  color: var(--ink-soft);
}

.portal-page-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.portal-page-heading h1 {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.portal-page-title-row .portal-status-dot {
  margin-left: 4px;
}

.portal-portal-header {
  display: flex;
  position: sticky;
  top: var(--topbar-height, 64px);
  z-index: 20;
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 0.5px solid var(--line);
  background: var(--bg);
}

.portal-crumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  color: var(--portal-ink);
  font-size: 14px;
  font-weight: 500;
}

.portal-crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 0;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .portal-crumb:hover {
    background: var(--hover);
  }
}

.portal-crumb svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.portal-crumb.current {
  overflow: hidden;
  padding: 4px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-crumb-sep {
  color: var(--muted);
  font-weight: 400;
}

.portal-portal-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-panel {
  padding: 0;
}

.portal-panel[hidden],
.portal-section[hidden] {
  display: none !important;
}

.portal-funding-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; max-width: 1200px; }
.portal-funding-action {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 16px;
  min-width: 0;
  min-height: 164px;
  padding: 26px 22px;
  border: 1px solid var(--dm-line, #d6dee9);
  border-radius: 0;
  background: var(--card);
  color: var(--brand-ink);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transform: none;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.portal-funding-icon { display: grid; place-items: center; width: 48px; height: 48px; background: var(--dm-surface-soft, #edf2f8); }
.portal-funding-icon svg { width: 27px; height: 27px; }
.portal-funding-copy { display: grid; gap: 9px; min-width: 0; }
.portal-funding-label { font-family: var(--font-display); font-size: 30px; font-weight: 300; line-height: 1.1; letter-spacing: -.02em; }
.portal-funding-description { max-width: 230px; color: var(--dm-muted, #68758a); font-size: 13px; font-weight: 400; line-height: 1.55; }
.portal-funding-arrow { width: 20px; height: 20px; opacity: .7; }
.portal-funding-action svg { stroke-linecap: round; stroke-linejoin: round; }
.portal-funding-action--primary { border-color: var(--brand-color); background: var(--brand-color); color: #fff; }
.portal-funding-action--primary .portal-funding-icon { background: rgb(255 255 255 / 8%); }
.portal-funding-action--primary .portal-funding-description { color: var(--dm-muted, #e0e7f1); }
.portal-funding-action:focus-visible { outline: 1px solid var(--focus); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
  .portal-funding-action:hover { background: var(--portal-sidebar-hover); transform: none; }
  .portal-funding-action--primary:hover { border-color: var(--dm-accent-line, #294e82); background: var(--dm-accent-fill, #294e82); }
}
.portal-funding-action:active { background: var(--portal-sidebar-press); transform: none; }
.portal-funding-action--primary:active { border-color: var(--dm-accent-line, #142a4b); background: var(--dm-accent-fill, #142a4b); }
.portal-withdrawal-schedule { max-width: 1000px; margin-top: 48px; }
.portal-withdrawal-schedule header { margin-bottom: 24px; }
.portal-withdrawal-schedule h2 { margin: 0 0 8px; color: var(--brand-ink); font-family: var(--font-display); font-size: 26px; font-weight: 300; line-height: 1.2; letter-spacing: -.02em; }
.portal-withdrawal-schedule header p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.portal-withdrawal-schedule table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; font-size: 14px; line-height: 1.5; }
.withdrawal-quarter-column { width: 28%; }
.withdrawal-window-column, .withdrawal-date-column { width: 36%; }
.portal-withdrawal-schedule th, .portal-withdrawal-schedule td { padding: 19px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.portal-withdrawal-schedule tr > :first-child { padding-left: 0; }
.portal-withdrawal-schedule tr > :last-child { padding-right: 0; }
.portal-withdrawal-schedule thead th { padding-top: 0; padding-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.portal-withdrawal-schedule tbody th { color: var(--brand-ink); font-size: 13px; font-weight: 500; letter-spacing: .03em; }
.portal-withdrawal-schedule td { color: var(--ink-soft); }
.portal-withdrawal-schedule strong { color: var(--brand-ink); font-weight: 500; }
@media (max-width: 1180px) {
  .portal-funding-action { grid-template-columns: minmax(0, 1fr); padding: 24px; gap: 18px; }
  .portal-funding-arrow { display: none; }
}
@media (max-width: 760px) {
  .portal-funding-actions { gap: 10px; }
  .portal-funding-action { min-height: 124px; padding: 18px 8px; gap: 12px; justify-items: center; text-align: center; }
  .portal-funding-icon { width: 36px; height: 36px; }
  .portal-funding-icon svg { width: 23px; height: 23px; }
  .portal-funding-label { font-size: 22px; }
  .portal-funding-description { display: none; }
  .portal-withdrawal-schedule { margin-top: 36px; }
  .portal-withdrawal-schedule h2 { font-size: 24px; }
  .portal-withdrawal-schedule header { margin-bottom: 22px; }
  .portal-withdrawal-schedule table { font-size: 13px; }
  .portal-withdrawal-schedule th, .portal-withdrawal-schedule td { padding: 17px 8px; }
  .portal-withdrawal-schedule thead th { font-size: 11px; }
  .withdrawal-quarter-column { width: 18%; }
  .withdrawal-window-column { width: 46%; }
  .withdrawal-date-column { width: 36%; }
}
@media (max-width: 360px) {
  .portal-funding-actions { gap: 8px; }
  .portal-funding-action { padding-inline: 5px; }
  .portal-funding-label { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-funding-action { transition: none; }
}

/* Receiving instructions: a focused page within the funding tab. */
.withdrawal-page { max-width: 1000px; scroll-margin-top: 28px; }
.funding-history { max-width: 1200px; }
.funding-history-intro { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.funding-history-state { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 32px 24px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 14px; }
.funding-history-table-wrap { border: 1px solid var(--line); background: var(--card); }
.funding-history-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; line-height: 1.5; }
.funding-history-table th { color: var(--muted); font-size: 12px; font-weight: 400; background: var(--portal-sidebar-bg); }
.funding-history-table :is(th, td) { padding: 18px 16px; border-bottom: 1px solid var(--line); }
.funding-history-table tr:last-child td { border-bottom: 0; }
.funding-history-table td:nth-child(4) { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--brand-ink); white-space: nowrap; }
.funding-history-table td:last-child { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.funding-history-status { display: inline-block; padding: 4px 8px; color: var(--ink-soft); background: var(--portal-sidebar-hover); font-size: 11px; white-space: nowrap; }
.funding-history-status[data-status="pending"] { color: var(--dm-warning-ink, #92400e); background: var(--dm-warning-soft, #fffbeb); }
.funding-history-status[data-status="approved"] { color: var(--dm-success-ink, #286247); background: var(--dm-success-soft, #edf7f0); }
.funding-history-status[data-status="rejected"] { color: var(--dm-danger-ink, #9b3434); background: var(--dm-danger-soft, #fcf0f0); }
@media (max-width: 1100px) {
  .funding-history-table-wrap { border: 0; background: transparent; }
  .funding-history-table, .funding-history-table tbody { display: block; }
  .funding-history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .funding-history-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; padding: 20px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--card); }
  .funding-history-table td { display: block; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  .funding-history-table td::before { content: attr(data-label); display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
  .funding-history-table td:nth-child(4) { white-space: normal; }
  .funding-history-table tr:last-child { margin-bottom: 0; }
}
.withdrawal-back { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 30px; color: var(--muted); font-size: 13px; text-decoration: none; }
.withdrawal-intro { margin-bottom: 32px; }
.withdrawal-intro h2 { margin: 0 0 10px; font-family: var(--font-display); font-size: 32px; font-weight: 300; color: var(--brand-ink); }
.withdrawal-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.withdrawal-page fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.withdrawal-page legend { margin-bottom: 12px; padding: 0; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.withdrawal-methods > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.withdrawal-methods label, .withdrawal-options label { position: relative; display: block; min-width: 0; cursor: pointer; }
.withdrawal-methods input, .withdrawal-options input { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; opacity: 0; }
.withdrawal-method-card { position: relative; display: grid; gap: 9px; height: 100%; box-sizing: border-box; padding: 22px; border: 1px solid var(--dm-line, #d8dfe8); background: var(--dm-surface, white); transition: background-color 140ms ease, border-color 140ms ease; }
.withdrawal-method-number { margin-bottom: 8px; color: var(--dm-muted, #8a96a8); font-size: 11px; letter-spacing: .07em; }
.withdrawal-method-card strong { color: var(--brand-ink); font-size: 17px; font-weight: 500; }
.withdrawal-method-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.withdrawal-method-card svg { position: absolute; top: 20px; right: 20px; width: 18px; height: 18px; fill: none; stroke: var(--brand-color); stroke-width: 1.5; opacity: 0; }
.withdrawal-methods input:checked + span { border-color: var(--brand-color); background: var(--dm-surface-soft, #edf2f8); }
.withdrawal-methods input:checked + span svg { opacity: 1; }
.withdrawal-methods input:focus-visible + span, .withdrawal-options input:focus-visible + span { outline: 1px solid var(--focus); outline-offset: 2px; }
.withdrawal-details { margin-top: 28px; padding: 32px; border: 1px solid var(--line); background: var(--dm-surface, white); animation: withdrawal-reveal 180ms ease-out; }
.withdrawal-section + .withdrawal-section { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 28px; }
.withdrawal-section h3 { margin: 0 0 22px; font-size: 17px; color: var(--brand-ink); font-weight: 500; }
.withdrawal-section-hint { margin: -12px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.withdrawal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.withdrawal-field { min-width: 0; }
.withdrawal-field--wide { grid-column: 1 / -1; min-width: 0; }
.withdrawal-field label { display: block; margin-bottom: 9px; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.withdrawal-field label span { color: var(--muted); font-weight: 400; font-size: 12px; }
.withdrawal-field input { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; height: 44px; padding: 10px 12px; border: 1px solid var(--dm-line, #d8dfe8); border-radius: 0; background: var(--dm-surface, white); color: var(--ink); font: inherit; font-size: 14px; }
.withdrawal-field input[readonly] { background: var(--dm-surface-soft, #f7f8fa); color: var(--dm-muted, #68758a); }
.withdrawal-field input[aria-invalid="true"] { border-color: var(--dm-danger-line, #b54343); }
.withdrawal-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.withdrawal-error, .withdrawal-error-summary { margin: 8px 0 0; color: var(--dm-danger-ink, #a02e2e); font-size: 12px; line-height: 1.5; }
.withdrawal-error-summary { margin-top: 24px; }
.withdrawal-options { display: flex; flex-wrap: wrap; gap: 8px; }
.withdrawal-options label span { display: block; padding: 11px 18px; border: 1px solid var(--dm-line, #d8dfe8); font-size: 13px; color: var(--ink-soft); transition: background-color 140ms ease; }
.withdrawal-options input:checked + span { background: var(--portal-sidebar-press); border-color: var(--dm-line-strong, #bbbfc5); color: var(--ink); }
.withdrawal-details > .withdrawal-choices { margin-bottom: 32px; }
.withdrawal-intermediary { display: flex; align-items: flex-start; gap: 10px; margin: 30px 0 24px; color: var(--ink-soft); font-size: 13px; cursor: pointer; }
.withdrawal-intermediary input { flex: 0 0 auto; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--brand-color); }
.withdrawal-reference { margin-top: 26px; }
.withdrawal-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.withdrawal-form-footer p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.withdrawal-button { display: inline-flex; align-items: center; justify-content: center; gap: 22px; min-height: 42px; flex-shrink: 0; padding: 10px 18px; border: 1px solid var(--line); border-radius: 0; background: var(--dm-surface, white); color: var(--ink-soft); font-family: var(--font-sans); font-size: 13px; font-weight: 400; cursor: pointer; transition: background-color 140ms ease; transform: none; }
.withdrawal-button--primary { border-color: var(--brand-color); background: var(--brand-color); color: white; }
.withdrawal-review { padding: 32px; border: 1px solid var(--line); background: var(--dm-surface, white); }
.withdrawal-review h3 { margin: 0 0 14px; color: var(--brand-ink); font-family: var(--font-display); font-weight: 300; font-size: 28px; outline: none; }
.withdrawal-review-note { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.withdrawal-review dl { margin: 0 0 28px; }
.withdrawal-review dl > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 24px; padding: 15px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.withdrawal-review dt { color: var(--muted); }
.withdrawal-review dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; }
@media (hover: hover) and (pointer: fine) {
  .withdrawal-back:hover { color: var(--brand-ink); }
  .withdrawal-methods label:hover .withdrawal-method-card, .withdrawal-options label:hover span, .withdrawal-button:hover { background: var(--portal-sidebar-hover); transform: none; }
  .withdrawal-button--primary:hover { background: var(--dm-accent-fill, #294e82); }
}
.withdrawal-methods label:active .withdrawal-method-card, .withdrawal-options label:active span, .withdrawal-button:active { background: var(--portal-sidebar-press); transform: none; }
.withdrawal-button--primary:active { background: var(--dm-accent-fill, #142a4b); }
@keyframes withdrawal-reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 760px) {
  .withdrawal-back { margin-bottom: 24px; font-size: 12px; }
  .withdrawal-intro { margin-bottom: 24px; }
  .withdrawal-intro h2 { font-size: 28px; }
  .withdrawal-intro p { font-size: 13px; }
  .withdrawal-methods > div { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .withdrawal-method-card { grid-template-columns: 20px minmax(0, 1fr); column-gap: 14px; row-gap: 5px; padding: 16px; }
  .withdrawal-method-number { grid-row: 1 / 3; margin: 3px 0 0; }
  .withdrawal-method-card strong { font-size: 15px; padding-right: 24px; }
  .withdrawal-method-hint { grid-column: 2; font-size: 11px; }
  .withdrawal-method-card svg { top: 17px; right: 16px; }
  .withdrawal-details, .withdrawal-review { padding: 22px 18px; margin-top: 22px; }
  .withdrawal-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .withdrawal-field input { font-size: 16px; }
  .withdrawal-section h3 { font-size: 16px; }
  .withdrawal-options label span { padding: 10px 14px; font-size: 12px; }
  .withdrawal-form-footer { align-items: stretch; flex-direction: column; gap: 18px; }
  .withdrawal-form-footer .withdrawal-button { align-self: flex-start; }
  .withdrawal-review dl > div { grid-template-columns: minmax(0, 1fr); gap: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .withdrawal-details { animation: none; }
  .withdrawal-method-card, .withdrawal-options label span, .withdrawal-button { transition: none; }
}

/* Deposit uses the same funding method selector, with read-only receiving details. */
.deposit-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.deposit-currency { flex-shrink: 0; padding: 8px 12px; border: 1px solid var(--dm-line, #d8dfe8); color: var(--brand-ink); font-size: 12px; line-height: 1.5; }
.deposit-details-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.deposit-details-heading h3 { margin: 0; font-size: 17px; font-weight: 500; color: var(--brand-ink); }
.deposit-detail-list { margin: 0; }
.deposit-detail-list > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 24px; padding: 17px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
.deposit-detail-list > div:last-child { padding-bottom: 0; border-bottom: 0; }
.deposit-detail-list dt { color: var(--muted); font-size: 13px; }
.deposit-detail-list dd { margin: 0; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.deposit-detail-list .deposit-number { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.deposit-legal { margin-bottom: 30px !important; }
.deposit-legal legend { margin-bottom: 16px; font-size: 16px; line-height: 1.5; color: var(--brand-ink); }
.deposit-legal-message { padding: 18px 20px; border: 1px solid var(--dm-warning-line, #fde68a); background: var(--dm-warning-soft, #fffbeb); color: var(--dm-warning-ink, #92400e); font-size: 14px; line-height: 1.7; }
#depositFlow { animation: withdrawal-reveal 180ms ease-out; }
#depositFlow [hidden] { display: none !important; }
.deposit-amount { margin-top: 28px; }
.deposit-amount > label { display: block; margin-bottom: 10px; color: var(--ink-soft); font-size: 13px; }
.deposit-amount-input { display: flex; align-items: center; max-width: 360px; gap: 0; }
.deposit-amount-input > span { display: grid; place-items: center; align-self: stretch; padding: 0 14px; border: 1px solid var(--dm-line, #d8dfe8); border-right: 0; background: var(--dm-surface-soft, #f1f3f6); color: var(--brand-ink); font-size: 13px; }
.deposit-amount-input input { box-sizing: border-box; width: 100%; min-width: 0; height: 46px; border: 1px solid var(--dm-line, #d8dfe8); border-radius: 0; padding: 10px 12px; color: var(--ink); background: var(--dm-surface, white); font: inherit; font-size: 16px; }
.deposit-amount-input input[aria-invalid="true"] { border-color: var(--dm-danger-line, #a02e2e); }
.deposit-submit-row { display: flex; justify-content: flex-end; margin-top: 24px; }
.security-dialog.deposit-confirm-dialog { width: min(620px, calc(100% - 32px)); }
.deposit-confirm-dialog .deposit-detail-list > div { padding: 10px 0; font-size: 13px; }
.deposit-receipt { padding: 32px; border: 1px solid var(--line); background: var(--dm-surface, white); }
.deposit-receipt h2 { margin: 0 0 12px; color: var(--brand-ink); font: 300 30px var(--font-display); outline: none; }
.deposit-receipt > p { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.deposit-receipt > button { margin-top: 28px; }
.deposit-page input:disabled, .deposit-page button:disabled { cursor: default; opacity: .5; }
@media (max-width: 760px) {
  .deposit-intro { flex-direction: column; gap: 14px; }
  .deposit-details-heading h3 { font-size: 16px; }
  .deposit-detail-list > div { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 16px 0; }
  .deposit-detail-list dt { font-size: 12px; }
  .deposit-legal legend { font-size: 15px; }
  .deposit-submit-row .withdrawal-button { width: 100%; }
  .deposit-receipt { padding: 24px 18px; }
  .deposit-confirm-dialog .security-dialog-footer { flex-wrap: wrap; }
  .deposit-confirm-dialog .security-dialog-footer button { flex: 1 1 auto; }
  .deposit-confirm-dialog .deposit-detail-list > div { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
}
@media (prefers-reduced-motion: reduce) { #depositFlow { animation: none; } }

/* Research and Market share the Portal shell and keep their own page state. */
#portalPage:is([data-tab="research"], [data-tab="market"]) :is(#portalBanner, .portal-portal-tools) {
  display: none;
}

.portal-research-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 32px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.portal-research-tabs > :is(a, span) {
  flex: 0 0 auto;
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.portal-research-tabs > .active {
  color: var(--ink);
  background: var(--portal-sidebar-hover);
}

.portal-research-tabs > [aria-disabled="true"] {
  opacity: .38;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .portal-research-tabs > a:hover { background: var(--portal-sidebar-hover); }
}

.portal-research-tabs > a:active { background: var(--portal-sidebar-press); }

#portalResearchContent > .page,
#portalMarketContent > .page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-top: 0;
}

#portalMarketContent #marketTitle { display: none; }
#portalMarketContent .strategy-intro { max-width: none; text-align: left; }
#portalResearchContent .doc-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  grid-template-areas: "intro toc" "doc toc";
  column-gap: 32px;
}
#portalResearchContent .doc-toc-rail { margin-top: 0; }
#portalResearchContent .doc-toc {
  top: calc(var(--topbar-height, 56px) + 80px);
  width: 100%;
  height: auto;
  max-height: calc(100dvh - var(--topbar-height, 56px) - 100px);
  margin-left: 0;
  align-items: flex-start;
}
#portalResearchContent .doc-toc-card { max-height: inherit; }
#portalResearchContent .doc-toc-text { white-space: normal; overflow-wrap: anywhere; }
#portalResearchContent .strategy-intro h1 { font-size: clamp(30px, 3vw, 42px); }

@media (max-width: 1100px) {
  #portalResearchContent .doc-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "toc" "doc";
    gap: 20px;
  }
  #portalResearchContent .doc-toc { position: static; max-height: none; }
}

.portal-panel[data-portal-panel="preference"],
.portal-panel[data-portal-panel="preference"] .portal-section {
  overflow: visible;
}

.portal-panel .portal-section:first-child,
.portal-panel > .portal-section[hidden] + .portal-section {
  margin-top: 0;
}

.portal-section[data-portal-section] > .portal-section-heading {
  margin-bottom: 16px;
}

.portal-panel-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.portal-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.portal-privacy-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0.8px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  transition: background-color 150ms ease, color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .portal-privacy-toggle:hover {
    background: var(--hover);
    color: var(--ink);
  }
}

.portal-privacy-toggle[aria-pressed="true"] {
  background: var(--hover);
  color: var(--ink);
}

.portal-eye-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 19px;
  height: 19px;
  transform: translate(-50%, -50%);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.portal-eye-closed,
.portal-privacy-toggle[aria-pressed="true"] .portal-eye-open {
  display: none;
}

.portal-privacy-toggle[aria-pressed="true"] .portal-eye-closed {
  display: block;
}

.portal-toolbar,
.portal-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-toolbar {
  margin: 24px 0 12px;
}

.portal-toolbar button.small {
  font-weight: 400;
}

.portal-refresh-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
  .portal-refresh-button:hover {
    color: var(--muted);
  }
}

.portal-refresh-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.portal-refresh-button.refreshing svg {
  animation: portal-refresh-spin 450ms linear infinite;
}

@keyframes portal-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.portal-meta,
.portal-source,
.portal-count,
.portal-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.portal-meta,
.portal-empty {
  margin: 0;
}

.portal-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-soft);
}

.portal-skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.34) 48%,
    transparent 76%
  );
  content: '';
  transform: translateX(-100%);
  animation: portal-skeleton-shimmer 1.35s ease-in-out infinite;
}

.portal-skeleton-chart {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(25% - 1px),
      var(--line) 25%
    ),
    var(--surface-soft);
}

.portal-skeleton-metric {
  min-height: 78px;
}

.portal-skeleton-table {
  height: 190px;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--surface-soft) 0,
      var(--surface-soft) 36px,
      var(--line) 37px
    );
}

.portal-skeleton-table.compact {
  height: 116px;
}

.portal-skeleton-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 142px;
  height: 142px;
  border: 20px solid var(--surface-soft);
  border-radius: 0;
  background: transparent;
  transform: translate(-50%, -50%);
}

.portal-skeleton-ring ~ .portal-margin-center {
  visibility: hidden;
}

.portal-skeleton-status {
  min-height: 72px;
  border-right: 0.8px solid var(--line);
  border-bottom: 0.8px solid var(--line);
}

@keyframes portal-skeleton-shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-skeleton::after {
    animation: none;
  }
}

.portal-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 0.8px solid var(--warning-border);
  border-radius: 0;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 14px;
}

.portal-banner.error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.portal-connection-notice {
  margin: 12px 0;
  padding: 11px 14px;
  border: 0.8px solid var(--success-border);
  border-radius: 0;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 13px;
}

.portal-connection-notice.error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.portal-section {
  margin-top: 16px;
  padding: 22px;
  border-radius: 0;
}

.portal-section-heading:not(:has(h2)) {
  justify-content: flex-start;
}

.portal-section-heading h2,
.portal-subheading {
  margin: 0;
  color: var(--ink);
}

.portal-section-heading h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.portal-subheading {
  margin: 20px 0 10px;
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portal-section > .portal-subheading:first-child {
  margin-top: 0;
}

/* Overview keeps account values visible above the two supporting charts. */
.portal-page[data-tab="overview"] #portalBanner.disconnected { display: none; }
.portal-overview { display: grid; gap: 24px; }
.portal-overview [hidden] { display: none !important; }
.portal-overview-card { min-width: 0; padding: 28px; border: 1px solid var(--line); background: var(--card); }
.portal-overview-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.portal-overview-card-heading h2 { margin: 0; color: var(--ink); font-family: var(--font-sans); font-size: 17px; font-weight: 500; line-height: 1.4; letter-spacing: -.015em; }
.portal-overview-card-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.portal-overview-connection { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; background: var(--dm-surface-soft, #f1f3f5); color: var(--dm-ink-soft, #67717e); font-size: 11px; line-height: 1.4; }
.portal-overview-connection > span:first-child { width: 5px; height: 5px; flex-shrink: 0; background: var(--dm-pressed, #98a2b0); }
.portal-overview-connection[data-connected="true"] { background: var(--dm-success-soft, #edf7f0); color: var(--dm-success-ink, #286247); }
.portal-overview-connection[data-connected="true"] > span:first-child { background: var(--dm-success-fill, #39815b); }
.portal-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
.portal-metric { min-width: 0; }
.portal-metric-label { min-height: 18px; margin-bottom: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.portal-metric-value { color: var(--ink); font-size: clamp(20px, 1.75vw, 26px); font-weight: 400; line-height: 1.4; font-variant-numeric: tabular-nums; letter-spacing: -.025em; overflow-wrap: anywhere; }
.portal-metric:first-child .portal-metric-value { color: var(--brand-ink); }
.portal-overview-note { margin: 22px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.portal-overview-analysis { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(280px, 1fr); align-items: stretch; gap: 24px; }
.portal-overview-equity { display: flex; flex-direction: column; }
.portal-overview-period { color: var(--muted); font-size: 11px; white-space: nowrap; }
.portal-equity-chart { position: relative; min-width: 0; height: 320px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.portal-equity-chart.is-inspecting { touch-action: none; }
@media (hover: hover) and (pointer: fine) { .portal-equity-chart:has(.portal-overview-chart-empty[hidden]) { cursor: crosshair; } }
.portal-equity-chart canvas { display: block; width: 100%; height: 100%; }
.portal-overview-chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 28px; }
.portal-overview-chart-empty svg { width: 34px; height: 34px; margin-bottom: 18px; fill: none; stroke: var(--dm-muted, #98a2b0); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.portal-overview-chart-empty h3 { margin: 0 0 9px; color: var(--ink-soft); font-family: var(--font-sans); font-size: 14px; font-weight: 500; }
.portal-overview-chart-empty p { max-width: 300px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.portal-equity-tooltip, .portal-margin-tooltip { position: absolute; z-index: 2; padding: 8px 10px; border: 1px solid var(--line); background: var(--overlay); color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.portal-overview-chart-key { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 24px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.portal-overview-chart-key > span { display: flex; align-items: center; gap: 8px; }
.portal-overview-line-key { width: 16px; height: 2px; background: var(--brand-color); }
.portal-overview-bar-key { width: 7px; height: 9px; background: var(--dm-pressed, #8c9bab); }
.portal-margin-panel { display: flex; flex-direction: column; }
.portal-margin-chart { position: relative; width: 220px; height: 220px; max-width: 100%; margin: 0 auto 14px; }
.portal-margin-chart canvas { display: block; width: 220px; height: 220px; max-width: 100%; }
.portal-margin-center { position: absolute; inset: 50% auto auto 50%; display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translate(-50%, -50%); pointer-events: none; }
.portal-margin-center strong { color: var(--brand-ink); font-size: 28px; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.portal-margin-center span { color: var(--muted); font-size: 11px; }
.portal-margin-tooltip { max-width: 240px; }
.portal-overview-margin-note { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }
.portal-overview-allocation { display: grid; gap: 13px; margin: auto 0 0; padding: 10px 0 0; list-style: none; }
.portal-overview-allocation li { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.portal-overview-allocation-swatch { width: 6px; height: 6px; }
.portal-overview-allocation-value { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
@media (max-width: 1180px) {
  .portal-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; }
  .portal-overview-analysis { grid-template-columns: minmax(0, 1fr); }
  .portal-margin-panel { display: grid; grid-template-columns: 220px minmax(0, 1fr); column-gap: 32px; }
  .portal-margin-panel .portal-overview-card-heading { grid-column: 1 / -1; margin-bottom: 18px; }
  .portal-margin-chart { margin: 0; }
  .portal-overview-margin-note, .portal-overview-allocation { align-self: center; margin: 0; }
}
@media (max-width: 620px) {
  .portal-overview, .portal-overview-analysis { gap: 18px; }
  .portal-overview-card { padding: 20px; }
  .portal-overview-card-heading { align-items: flex-start; gap: 12px; margin-bottom: 24px; }
  .portal-overview-card-heading h2 { font-size: 15px; }
  .portal-overview-summary .portal-overview-card-heading { flex-wrap: wrap; }
  .portal-overview-connection { padding: 5px 7px; font-size: 10px; }
  .portal-metrics { gap: 22px 20px; }
  .portal-metric-label { min-height: 33px; margin-bottom: 5px; font-size: 11px; }
  .portal-metric-value { font-size: 20px; }
  .portal-overview-note { font-size: 11px; margin-top: 20px; }
  .portal-equity-chart { height: 290px; }
  .portal-overview-chart-empty { padding: 12px; }
  .portal-overview-chart-key { gap: 18px; }
  .portal-margin-panel { display: flex; }
  .portal-margin-chart { margin: 0 auto 14px; }
  .portal-overview-allocation { width: 100%; padding: 12px 0 0; }
}
@media (max-width: 360px) {
  .portal-overview-card { padding: 18px; }
  .portal-metrics { gap: 20px 12px; }
  .portal-metric-value { font-size: 17px; }
}

.portal-table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.portal-signal-expired td {
  color: var(--muted);
}

.portal-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.portal-pager[hidden] {
  display: none;
}

.portal-pager button.small {
  font-weight: 400;
}

.portal-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.portal-table th,
.portal-table td {
  padding: 11px 10px;
  border-bottom: 0.8px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.portal-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.portal-table th:first-child,
.portal-table td:first-child {
  padding-left: 0;
  text-align: center;
}

.portal-table th:last-child,
.portal-table td:last-child {
  padding-right: 0;
}

.portal-symbol,
.portal-number {
  font-family: var(--font-mono);
}

.portal-positive {
  color: var(--success-text);
}

.portal-negative {
  color: var(--error-text);
}

.portal-flash-up {
  animation: portal-flash-up 1100ms ease-out;
}

.portal-flash-down {
  animation: portal-flash-down 1100ms ease-out;
}

@keyframes portal-flash-up {
  from {
    background-color: rgba(34, 160, 107, 0.16);
  }
  to {
    background-color: transparent;
  }
}

@keyframes portal-flash-down {
  from {
    background-color: rgba(209, 67, 67, 0.14);
  }
  to {
    background-color: transparent;
  }
}

.portal-warning {
  color: var(--warning-text);
}

.portal-table .portal-log-message {
  min-width: 280px;
  max-width: 520px;
  text-align: center;
  white-space: normal;
}

/* Positions and orders share a compact table system, with readable mobile rows. */
.portal-page[data-tab="trading-desk"] #portalBanner.disconnected { padding: 0; margin-bottom: 24px; border: 0; background: none; color: var(--muted); font-size: 12px; line-height: 1.7; }
.portal-trades { display: grid; gap: 24px; }
.portal-trades [hidden] { display: none !important; }
.trade-card { min-width: 0; padding: 28px; border: 1px solid var(--line); background: var(--card); }
.trade-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.trade-card-heading h2 { margin: 0; color: var(--ink); font-family: var(--font-sans); font-size: 17px; font-weight: 500; line-height: 1.4; letter-spacing: -.015em; }
.trade-card-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.trade-count { flex-shrink: 0; padding: 5px 8px; color: var(--muted); background: var(--dm-surface-soft, #f3f4f6); font-size: 11px; line-height: 1.4; }
.trade-tabs { display: flex; align-items: stretch; gap: 6px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.trade-tabs button { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 0; color: var(--ink-soft); background: transparent; font: 400 12px/1.4 var(--font-sans); cursor: pointer; transform: none; transition: background-color 120ms ease; }
.trade-tabs button[aria-selected="true"] { background: var(--portal-sidebar-hover); color: var(--portal-ink); }
.trade-tab-count { min-width: 15px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; text-align: center; }
@media (hover: hover) and (pointer: fine) {
  .trade-tabs button:hover, .trade-pager button:not(:disabled):hover { background: var(--portal-sidebar-hover); }
}
.trade-tabs button:active, .trade-pager button:not(:disabled):active { background: var(--portal-sidebar-press); transform: none; }
.portal-trades [role="tabpanel"]:focus { outline: none; }
.portal-trades [role="tabpanel"]:focus-visible { outline: 1px solid var(--focus); outline-offset: 5px; }
.trade-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 200px; padding: 28px 20px; text-align: center; }
.trade-empty svg { width: 30px; height: 30px; margin-bottom: 17px; fill: none; stroke: var(--dm-muted, #98a2b0); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.trade-empty h3 { margin: 0 0 8px; color: var(--ink-soft); font-family: var(--font-sans); font-size: 14px; font-weight: 500; }
.trade-empty p { max-width: 350px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.trade-empty[data-state="error"] p { color: var(--error-text); }
.trade-table .portal-table { width: 100%; min-width: 840px; font-size: 12px; }
.trade-table .portal-table :is(th, td) { padding: 15px 12px; border-bottom: 1px solid var(--line); border-left: 0; border-right: 0; vertical-align: middle; text-align: left; }
.trade-table .portal-table th { background: var(--dm-surface-soft, #f7f8fa); color: var(--muted); font-size: 10px; font-weight: 400; letter-spacing: .025em; text-transform: none; }
.trade-table .portal-table tr:last-child td { border-bottom: 0; }
.trade-table :is(.portal-number, .portal-symbol) { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.trade-table .portal-symbol { max-width: 240px; color: var(--brand-ink); font-weight: 500; overflow-wrap: anywhere; white-space: normal; }
.trade-positions .portal-table :is(th, td):nth-child(n+2):nth-child(-n+8),
.trade-orders .portal-table :is(th, td):is(:nth-child(3), :nth-child(6)) { text-align: right; }
.trade-positions .portal-table td:last-child, .trade-orders .portal-table td:nth-child(7) { color: var(--muted); font-size: 11px; }
.trade-orders .portal-table td:is(:nth-child(2), :nth-child(5)) { max-width: 150px; white-space: normal; }
.trade-orders .portal-table td:last-child { color: var(--muted); font-size: 11px; white-space: normal; min-width: 140px; }
.trade-status { display: inline-block; padding: 5px 7px; color: var(--dm-ink-soft, #67717e); background: var(--dm-surface-soft, #f1f3f5); font-size: 10px; line-height: 1.4; white-space: nowrap; }
.trade-status[data-tone="active"] { color: var(--brand-ink); background: var(--dm-surface-soft, #edf2f9); }
.trade-status[data-tone="complete"] { color: var(--dm-success-ink, #286247); background: var(--dm-success-soft, #edf7f0); }
.trade-status[data-tone="pending"] { color: var(--dm-warning-ink, #92400e); background: var(--dm-warning-soft, #fffbeb); }
.trade-status[data-tone="error"] { color: var(--dm-danger-ink, #9b3434); background: var(--dm-danger-soft, #fcf0f0); }
.trade-pager { padding-top: 18px; margin-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.trade-pager button.small { min-height: 34px; padding: 7px 11px; color: var(--ink-soft); background: transparent; font: 400 12px/1.4 var(--font-sans); transform: none; }
.trade-pager button:disabled { opacity: .45; cursor: default; }
@media (max-width: 620px) {
  .portal-trades { gap: 18px; }
  .trade-card { padding: 20px; }
  .trade-card-heading { gap: 14px; margin-bottom: 22px; }
  .trade-card-heading h2 { font-size: 15px; }
  .trade-card-heading p { font-size: 11px; }
  .trade-tabs button { min-height: 40px; }
  .trade-empty { min-height: 180px; padding: 24px 0; }
  .trade-empty h3 { font-size: 13px; }
  .trade-empty p { font-size: 11px; }
  .trade-table .portal-table, .trade-table tbody { display: block; min-width: 0; }
  .trade-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .trade-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 20px; padding: 22px 0; border-bottom: 1px solid var(--line); }
  .trade-table tr:first-child { padding-top: 10px; }
  .trade-table tr:last-child { border-bottom: 0; padding-bottom: 4px; }
  .trade-table .portal-table td:nth-child(n) { display: block; min-width: 0; max-width: none; padding: 0; border: 0; font-size: 12px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .trade-positions .portal-table td:nth-child(n+2):nth-child(-n+8) { text-align: left; }
  .trade-table td::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 400; content: attr(data-label); }
  .trade-table .portal-table td:first-child { grid-column: 1; grid-row: 1; align-self: center; font-size: 14px; }
  .trade-table td:first-child::before, .trade-positions td:last-child::before, .trade-orders td:nth-child(4)::before { display: none; }
  .trade-positions .portal-table td:last-child, .trade-orders .portal-table td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: center; text-align: right; }
  .trade-positions .portal-table td:last-child { font-size: 11px; }
  .trade-orders .portal-table td:last-child { grid-column: 1 / -1; font-size: 11px; }
  .trade-status { max-width: 100%; white-space: normal; }
  .trade-pager { gap: 8px; justify-content: space-between; }
  .trade-pager button.small { min-height: 40px; }
}



/* Signal monitoring and strategy schedules complete the Trading Desk. */
.trade-signals { display: grid; min-width: 0; gap: 24px; }
.trade-signal-table .portal-table { min-width: 980px; }
.trade-signal-table .portal-table :is(th, td):is(:nth-child(3), :nth-child(4), :nth-child(5), :nth-child(7), :nth-child(8)) { text-align: right; }
.trade-signal-table .portal-table td:nth-child(2) { font-size: 11px; color: var(--muted); }
.trade-signal-table .portal-table .trade-signal-reason { min-width: 160px; max-width: 230px; white-space: normal; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.7; }
.trade-signal-table .portal-signal-expired .portal-symbol { color: var(--muted); }
.trade-schedule-table .portal-table { min-width: 800px; }
.trade-schedule-table .portal-table td:first-child { color: var(--muted); font-size: 11px; }
.trade-schedule-table .portal-table td:nth-child(5) { min-width: 160px; max-width: 300px; white-space: normal; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.7; }
@media (max-width: 620px) {
  .trade-signals { gap: 18px; }
  .trade-signal-table .portal-table, .trade-schedule-table .portal-table { min-width: 0; }
  .trade-signal-table .portal-table td:nth-child(n) { text-align: left; }
  .trade-signal-table .portal-table td:nth-child(6) { grid-column: 2; grid-row: 1; align-self: center; text-align: right; }
  .trade-signal-table td:nth-child(6)::before { display: none; }
  .trade-signal-table .portal-table .trade-signal-reason { grid-column: 1 / -1; min-width: 0; max-width: none; }
  .trade-schedule-table .portal-table td:first-child { grid-column: 1 / -1; grid-row: 2; font-size: 11px; }
  .trade-schedule-table td:first-child::before { display: block; }
  .trade-schedule-table .portal-table td:nth-child(2) { grid-column: 1; grid-row: 1; align-self: center; font-size: 14px; }
  .trade-schedule-table td:nth-child(2)::before, .trade-schedule-table td:last-child::before { display: none; }
  .trade-schedule-table .portal-table td:last-child { grid-column: 2; grid-row: 1; align-self: center; text-align: right; }
  .trade-schedule-table .portal-table td:nth-child(5) { grid-column: 1 / -1; min-width: 0; max-width: none; }
}

.portal-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 0;
  background: var(--dm-pressed, #9ca3af);
}

.portal-status-dot.ok {
  background: var(--dm-success-fill, #22a06b);
}

.portal-status-dot.warn {
  background: var(--dm-warning-fill, #d99a00);
}

.portal-status-dot.error {
  background: var(--dm-danger-fill, #d14343);
}

.portal-header-leading { display: flex; min-width: 0; align-items: center; gap: 8px; }
.portal-header-leading .portal-sidebar-toggle { display: none; }
.portal-header-leading .portal-sidebar-toggle.is-pointer-focus:focus { outline: none; }
html:has(#portalNavigationDrawer[open]) { overflow: hidden; }
/* Hide on entry; restore as closing starts so the drawer naturally uncovers it. */
#portalNavToggle[aria-expanded="true"] svg { visibility: hidden; }
.portal-nav-drawer {
  position: fixed;
  inset: var(--topbar-height, 44px) auto 0 0;
  width: min(288px, calc(100vw - 48px));
  max-width: none;
  height: calc(100vh - var(--topbar-height, 44px));
  height: calc(100dvh - var(--topbar-height, 44px));
  max-height: calc(100dvh - var(--topbar-height, 44px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--portal-sidebar);
  color: var(--portal-ink);
  transform: translateX(-100%);
  transition: transform 200ms cubic-bezier(.4, 0, .2, 1);
}
.portal-nav-drawer[open] { display: flex; flex-direction: column; }
.portal-nav-drawer:focus { outline: none; }
.portal-nav-drawer.is-visible { transform: translateX(0); }
.portal-nav-drawer::backdrop { inset: var(--topbar-height, 44px) 0 0; background: rgb(12 26 45 / 24%); opacity: 0; transition: opacity 200ms ease; }
.portal-nav-drawer.is-visible::backdrop { opacity: 1; }
.portal-drawer-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; min-height: 56px; padding: max(8px, env(safe-area-inset-top)) 12px 8px 24px; border-bottom: 1px solid var(--line); }
/* Reveal once the whole X clears the screen edge, finishing with the 200ms slide. */
#portalNavClose { opacity: 0; transition: opacity 80ms ease, background-color 150ms ease; }
.portal-nav-drawer.is-visible #portalNavClose { opacity: 1; transition: opacity 150ms ease 50ms, background-color 150ms ease; }
@media (prefers-reduced-motion: reduce) {
  .portal-nav-drawer, .portal-nav-drawer::backdrop, #portalNavClose, .portal-nav-drawer.is-visible #portalNavClose { transition: none; }
}

@media (max-width: 820px) {
  body:has(#portalPage.active) {
    --topbar-height: 34px;
  }

  body:has(#portalPage.active) .topbar-brand {
    margin-top: -5px;
    margin-bottom: 5px;
  }

  .portal-portal {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: calc(100dvh - var(--topbar-height, 44px));
  }

  /* Hide navigation until its existing DOM is moved into the drawer. */
  .portal-portal > .portal-portal-nav { display: none; }
  .portal-header-leading .portal-sidebar-toggle { display: grid; }
  .portal-portal-nav {
    position: static;
    top: auto;
    z-index: auto;
    flex: 1;
    align-self: stretch;
    width: 100%;
    height: auto;
    min-height: 0;
    min-width: 0;
    transform: none;
    will-change: auto;
    padding: 12px 12px 0;
    border: 0;
  }

  .portal-tab-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .portal-tab {
    flex-shrink: 0;
    min-height: 40px;
    padding: 9px 12px;
    gap: 12px;
    font-size: 14px;
    white-space: nowrap;
  }

  .portal-portal-header {
    position: sticky;
    top: var(--topbar-height, 44px);
    transform: none;
    will-change: auto;
    flex-wrap: nowrap;
    min-width: 0;
    height: 56px;
    gap: 8px;
    padding: 6px 12px;
  }
  .portal-header-leading { flex: 1; gap: 4px; }
  .portal-crumb:not(.current), .portal-crumb-sep, .portal-meta { display: none; }

  .portal-crumbs {
    flex: 1 1 0;
    min-width: 0;
  }

  .portal-crumb.current {
    min-width: 0;
  }

  /* Keep the full hierarchy available on narrow screens without widening the page. */
  .portal-crumbs.has-parent { overflow-x: auto; scrollbar-width: none; font-size: 12px; }
  .portal-crumbs.has-parent::-webkit-scrollbar { display: none; }
  .portal-crumbs.has-parent .portal-crumb { display: inline-flex; flex-shrink: 0; padding-inline: 4px; }
  .portal-crumbs.has-parent .portal-crumb-sep { display: block; flex-shrink: 0; }
  .portal-crumbs.has-parent .portal-crumb span { display: inline; }

  .portal-portal-tools {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .portal-meta {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .portal-page-body {
    padding: 20px 16px 0;
  }

  .portal-page-heading {
    margin-bottom: 24px;
  }

  .portal-page-heading h1 {
    font-size: 24px;
  }

  .portal-pager {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
  }


}

@media (max-width: 760px) {
  .portal-section-heading {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 620px) {
  .portal-crumb:not(.current) span {
    display: none;
  }

  .portal-meta {
    display: none;
  }

  .portal-page-icon {
    width: 36px;
    height: 36px;
    margin-left: -8px;
  }

  .portal-page-heading h1 {
    font-size: 22px;
  }

}

@media (max-width: 480px) {
  .portal-section {
    padding: 16px;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Daily Report sits within Overview, using the same quiet section hierarchy. */
.portal-report { min-width: 0; }
.portal-report-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.portal-report-header { align-items: flex-start; }
.portal-report-toolbar { display: flex; align-items: stretch; gap: 4px; flex-shrink: 0; }
.portal-report-toolbar button { display: inline-flex; align-items: center; justify-content: center; width: 36px; min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; transform: none; transition: background-color 120ms ease; }
.portal-report-toolbar button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.portal-report-toolbar button:disabled { color: var(--dm-muted, #b2b8c1); cursor: default; }
@media (hover: hover) and (pointer: fine) { .portal-report-toolbar button:not(:disabled):hover { background: var(--portal-sidebar-hover); } }
.portal-report-toolbar button:not(:disabled):active { background: var(--portal-sidebar-press); transform: none; }
.portal-report-date { display: flex; min-width: 0; }
.portal-report-date input { box-sizing: border-box; width: 150px; min-width: 0; max-width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 0; background: var(--card); color: var(--ink-soft); font: 400 12px/1.4 var(--font-sans); font-variant-numeric: tabular-nums; }
.portal-report-date input::-webkit-date-and-time-value { min-width: 0; text-align: center; }
.portal-report-stamp { padding: 4px 7px; color: var(--muted); background: var(--dm-surface-soft, #f3f4f6); font-size: 10px; line-height: 1.4; }
.portal-report-stamp.is-live { background: var(--dm-success-soft, #edf7f0); color: var(--dm-success-ink, #286247); }
.portal-report-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 40px; }
.portal-report-body > .portal-skeleton { grid-column: 1 / -1; min-height: 210px; }
.portal-report-section { min-width: 0; }
.portal-report-section h3 { margin: 0 0 12px; color: var(--brand-ink); font: 500 13px/1.5 var(--font-sans); }
.portal-report-section p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.portal-report-section p + p { margin-top: 8px; }
.portal-report-summary { grid-column: 1 / -1; padding: 24px; background: var(--dm-surface-soft, #f7f8fa); }
.portal-report-summary h3 { color: var(--muted); font-size: 11px; font-weight: 400; margin-bottom: 10px; }
.portal-report-result { display: flex; align-items: baseline; flex-wrap: wrap; gap: 16px; margin-bottom: 9px; font-variant-numeric: tabular-nums; }
.portal-report-amount { color: var(--ink); font: 400 30px/1.2 var(--font-sans); letter-spacing: -.03em; }
.portal-report-change { color: var(--muted); font-size: 13px; }
.portal-report-result .portal-positive { color: var(--success-text); }
.portal-report-result .portal-negative { color: var(--error-text); }
.portal-report-summary p { font-size: 11px; }
.portal-report-slots { grid-column: 1 / -1; padding: 18px 0; border-block: 1px solid var(--line); }
.portal-report-slots h3 { margin-bottom: 6px; }
.portal-report-list { margin: 12px 0 0; padding-left: 17px; color: var(--ink-soft); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.portal-report-list li + li { margin-top: 8px; }
.portal-report-list li::marker { color: var(--dm-muted, #aeb9c9); }
.portal-report-mark { color: var(--ink-soft); font-weight: 500; }
.portal-report-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 210px; padding: 24px 0; text-align: center; }
.portal-report-empty svg { width: 30px; height: 30px; margin-bottom: 17px; fill: none; stroke: var(--dm-muted, #98a2b0); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.portal-report-empty h3 { margin: 0 0 9px; color: var(--ink-soft); font: 500 14px/1.5 var(--font-sans); }
.portal-report-empty p { max-width: 360px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.portal-report-empty[data-state="error"] p { color: var(--error-text); }
@media (max-width: 620px) {
  .portal-report-header { flex-wrap: wrap; gap: 18px; }
  .portal-report-toolbar { width: 100%; justify-content: space-between; }
  .portal-report-toolbar button { width: 40px; min-height: 40px; }
  .portal-report-date { flex: 1; max-width: 210px; }
  .portal-report-date input { width: 100%; min-height: 40px; font-size: 16px; }
  .portal-report-body { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .portal-report-summary { padding: 20px; }
  .portal-report-amount { font-size: 27px; }
  .portal-report-result { gap: 12px; }
  .portal-report-section h3 { font-size: 12px; }
  .portal-report-section p, .portal-report-list { font-size: 11px; }
  .portal-report-summary h3 { font-size: 10px; }
  .portal-report-empty h3 { font-size: 13px; }
  .portal-report-empty p { font-size: 11px; }
}

.portal-banner.disconnected { color: var(--ink-soft); background: var(--hover); border-color: var(--line); }
/* Server Control follows signals at the bottom of Trading Desk. */
.server-section-title { margin: 8px 0 0; color: var(--ink); font: 400 24px/1.3 var(--font-display); letter-spacing: -.02em; }
.server-control { display: grid; gap: 24px; }
.server-service-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 24px; }
.server-control [hidden] { display: none !important; }
.server-card { min-width: 0; padding: 28px; border: 1px solid var(--line); background: var(--card); }
.server-runtime, .server-broker { display: flex; flex-direction: column; }
.server-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.server-card-heading h2 { margin: 0; font-family: var(--font-sans); font-size: 17px; line-height: 1.4; font-weight: 500; color: var(--ink); letter-spacing: -.015em; }
.server-eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 10px; line-height: 1.4; font-weight: 500; letter-spacing: .11em; text-transform: uppercase; }
.server-state { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 6px 9px; background: var(--dm-surface-soft, #f1f3f5); color: var(--dm-ink-soft, #67717e); font-size: 11px; line-height: 1.3; }
.server-state .portal-status-dot { width: 5px; height: 5px; }
.server-state[data-tone="ok"] { color: var(--dm-success-ink, #286247); background: var(--dm-success-soft, #edf7f0); }
.server-state[data-tone="warn"] { color: var(--dm-warning-ink, #92400e); background: var(--dm-warning-soft, #fffbeb); }
.server-state[data-tone="error"] { color: var(--dm-danger-ink, #9b3434); background: var(--dm-danger-soft, #fcf0f0); }
.server-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; margin: 3px 0 36px; }
.server-metric { min-width: 0; }
.server-metric dt { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 400; }
.server-metric dd { margin: 0; color: var(--brand-ink); font-size: 20px; line-height: 1.35; font-weight: 400; overflow-wrap: anywhere; }
.server-card-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-top: auto; padding-top: 22px; border-top: 1px solid var(--line); }
.server-card-footer p { margin: 0; flex: 1 1 170px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.server-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.server-control .server-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; width: auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 0; background: var(--dm-surface, #fff); color: var(--ink-soft); font-family: var(--font-sans); font-size: 12px; line-height: 1.4; font-weight: 400; cursor: pointer; transform: none; transition: background-color 120ms ease; }
.server-control .server-button:disabled { opacity: 1; background: var(--dm-surface-soft, #f7f8fa); color: var(--dm-muted, #8993a1); cursor: not-allowed; }
.server-button svg { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) { .server-control .server-button:hover:not(:disabled) { background: var(--portal-sidebar-hover); } }
.server-control .server-button:active:not(:disabled) { background: var(--portal-sidebar-press); transform: none; }
.server-broker-state { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--muted); }
.server-broker-state svg { width: 22px; height: 22px; flex: 0 0 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.server-broker-state p { margin: 0; color: var(--brand-ink); font-size: 16px; line-height: 1.5; font-weight: 400; }
.server-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.server-broker > .server-description { margin-bottom: 26px; max-width: 330px; }
.server-broker .server-card-footer { justify-content: flex-end; }
.server-broker[data-connected="true"] .server-broker-state svg { color: var(--dm-success-ink, #286247); }
.server-logs .server-card-heading { margin-bottom: 22px; }
.server-logs .server-description { margin-top: 6px; }
.server-count { padding: 5px 8px; background: var(--dm-surface-soft, #f3f4f6); color: var(--muted); font-size: 11px; white-space: nowrap; }
.server-log-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 190px; padding: 24px; border-top: 1px solid var(--line); text-align: center; }
.server-log-empty svg { width: 30px; height: 30px; margin-bottom: 16px; fill: none; stroke: var(--dm-muted, #98a2b0); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.server-log-empty h3 { margin: 0 0 7px; color: var(--ink-soft); font-family: var(--font-sans); font-size: 14px; font-weight: 500; }
.server-log-empty p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.server-log-empty.is-error h3 { display: none; }
.server-log-empty.is-error p { color: var(--error-text); }
.server-log-table .portal-table { width: 100%; min-width: 680px; border: 0; font-size: 12px; }
.server-log-table .portal-table :is(th, td) { padding: 14px 12px; border-right: 0; border-left: 0; text-align: left; vertical-align: top; }
.server-log-table .portal-table th { background: var(--dm-surface-soft, #f7f8fa); color: var(--muted); font-size: 11px; font-weight: 400; }
.server-log-table .portal-table td { font-weight: 400; }
.server-log-table .portal-symbol { font-family: var(--font-sans); }
.server-log-table .portal-table .portal-log-message { min-width: 230px; line-height: 1.65; }
.server-logs .portal-pager { margin-top: 20px; font-size: 12px; }
.server-logs .portal-pager .small { font-size: 12px; font-weight: 400; }
@media (max-width: 1180px) {
  .server-service-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .server-broker > .server-description { max-width: none; }
}
@media (max-width: 620px) {
  .server-control { gap: 18px; }
  .server-card { padding: 20px; }
  .server-card-heading { margin-bottom: 24px; gap: 14px; }
  .server-card-heading h2 { font-size: 15px; }
  .server-metrics { gap: 16px; margin-bottom: 28px; }
  .server-metric dt { font-size: 11px; }
  .server-metric dd { font-size: 16px; }
  .server-card-footer { padding-top: 18px; }
  .server-card-footer p { flex-basis: 100%; }
  .server-actions { width: 100%; }
  .server-actions .server-button { flex: 1; }
  .server-control .server-button { min-height: 40px; }
  .server-log-empty { padding: 22px 0; min-height: 180px; }
  .server-log-table .portal-table, .server-log-table tbody { display: block; min-width: 0; }
  .server-log-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .server-log-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 18px 0; border-top: 1px solid var(--line); }
  .server-log-table .portal-table td { display: block; min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .server-log-table td:first-child { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 11px; }
  .server-log-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 3; color: var(--muted); font-size: 11px; }
  .server-log-table td:nth-child(2)::before { content: attr(data-label) ' · '; }
  .server-log-table .portal-table td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; padding-top: 4px; font-size: 13px; font-weight: 500; }
  .server-log-table td:nth-child(4) { grid-column: 2; grid-row: 1; font-size: 11px; text-align: right; }
  .server-log-table .portal-table td:last-child { grid-column: 1 / -1; grid-row: 4; padding-top: 3px; }
}
@media (max-width: 480px) {
  .server-metrics { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .server-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
  .server-metric dt { margin: 0; }
  .server-metric dd { text-align: right; }
}
.portal-button {
  display: inline-flex;
  min-width: 112px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 6px 24px;
  border: 0;
  border-radius: 0;
  background: var(--accent-button);
  color: #fff;
  appearance: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .portal-button:hover {
    background: var(--accent-button-hover);
  }
}

.portal-button.active {
  box-shadow: none;
}

.owner-invitations { padding: 28px; grid-column: 1 / -1; }
.owner-invitations[hidden] { display: none; }
.owner-invitations-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.owner-invitations h2 { margin: 0; font-size: 20px; font-weight: 500; }
.owner-invitations > p, .owner-invitation-result p { font-size: 13px; color: var(--dm-muted, #647084); line-height: 1.7; }
.owner-invitation-form { display: grid; grid-template-columns: minmax(160px, 2fr) 1fr 1fr; gap: 20px; margin: 28px 0; }
.owner-invitation-form > button { grid-column: 1 / -1; justify-self: start; }
.owner-invitations select, .owner-invitation-result input { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--dm-line, #d8dfe8); padding: 10px; background: var(--dm-surface, white); color: var(--dm-ink, #172133); font: inherit; border-radius: 0; }
.owner-invitation-result { background: var(--dm-surface-soft, #f4f6f9); padding: 20px; }
.owner-invitation-result > div { display: flex; gap: 12px; margin-top: 10px; }
.owner-invitation-result input { font-family: monospace; }
.owner-invitation-list { list-style: none; margin: 28px 0 0; padding: 0; }
.owner-invitation-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--dm-line, #e0e4e9); padding: 18px 0; }
.owner-invitation-list li > div { min-width: 0; }
.owner-invitation-list strong { display: block; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.owner-invitation-list span { display: block; font-size: 12px; color: var(--dm-muted, #647084); margin-top: 6px; line-height: 1.5; }
@media (max-width: 620px) { .owner-invitations { padding: 20px; } .owner-invitation-form { grid-template-columns: 1fr; } }

.owner-invitations .auth-primary { background: var(--dm-accent-fill, #203f70); color: white; }

/* Account controls remain at the foot of the desktop sidebar. */
.portal-sidebar-account {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin: auto -12px 0;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
}
.portal-sidebar-profile {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--portal-ink);
  text-decoration: none;
}
.portal-sidebar-avatar {
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  background: var(--dm-surface-soft, #e5ebf3);
  color: var(--dm-accent-ink, #203f70);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
}
.portal-sidebar-identity { display: grid; min-width: 0; gap: 4px; }
#portalSidebarName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
#portalSidebarRole { color: var(--muted); font-size: 11px; }
.portal-settings-button {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}
.portal-settings-button svg { display: block; width: 22px; height: 22px; }
@media (hover: hover) and (pointer: fine) {
  .portal-settings-button:hover { background: var(--portal-sidebar-hover); color: var(--dm-accent-ink, #203f70); }
}
.portal-settings-button:focus-visible, .portal-sidebar-profile:focus-visible { outline: 2px solid var(--dm-accent-line, #203f70); outline-offset: 3px; }
html:has(#portalPreferencesDialog[open]) { overflow: hidden; }
.portal-preferences-dialog {
  width: min(920px, calc(100% - 48px));
  max-width: none;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(12 31 55 / 18%);
}
.portal-preferences-dialog[open] { display: flex; flex-direction: column; animation: portal-preferences-open 160ms ease-out both; }
.portal-preferences-dialog::backdrop { background: rgb(12 26 45 / 32%); animation: portal-preferences-backdrop 160ms ease-out both; }
/* Match ArxivStone's centered 95% scale/fade and 200ms easing. Keep this
   scoped to Preferences; account-management dialogs have their own flow. */
#portalPreferencesDialog {
  --preferences-gutter: 28px;
  opacity: 0;
  transform: scale(0.95);
  transform-origin: center;
  animation: none;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1), transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
#portalPreferencesDialog.is-visible { opacity: 1; transform: scale(1); }
#portalPreferencesDialog::backdrop {
  background: rgb(0 0 0 / 20%);
  opacity: 0;
  animation: none;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
#portalPreferencesDialog.is-visible::backdrop { opacity: 1; }
.portal-preferences-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.portal-preferences-header h2 { margin: 0; font-family: var(--font-sans); font-size: 22px; font-weight: 400; line-height: 1.4; outline: none; }
.portal-preferences-body { min-height: 0; padding: 4px 28px 28px; overflow-y: auto; overscroll-behavior: contain; }
.portal-preferences-body .account-preference { gap: 0; }
.portal-preferences-body .account-preference > .portal-section { padding: 24px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; box-shadow: none; }
.portal-preferences-body .account-preference > .portal-section:last-child { border-bottom: 0; padding-bottom: 0; }
#portalPreferencesDialog > .portal-preferences-body { padding-inline: 0; }
#portalPreferencesDialog .account-preference > .portal-section { padding-inline: var(--preferences-gutter); }
#portalPreferencesDialog :is(.account-settings-row, .passkey-row, .owner-invitation-list li) { border-block: 0; }
.security-dialog-footer > .auth-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  color: #fff;
  background: var(--brand-color);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}
.portal-preferences-body .portal-section-heading h2 { font-family: var(--font-sans); font-size: 16px; font-weight: 500; }
.portal-preferences-body .account-settings-copy strong { font-weight: 500; }
.portal-preferences-body .account-settings-value { overflow-wrap: anywhere; }
#accountSecurityEmail { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 24px; }
#accountSecurityEmail .account-settings-value { justify-self: end; text-align: right; }
#accountEmail { overflow-wrap: anywhere; }
.portal-preferences-body .auth-form input { min-height: 40px; }
.account-identity-form { padding-bottom: 22px; }
.account-identity-editor { display: flex; align-items: center; gap: 24px; }
.account-avatar-button { position: relative; flex: 0 0 80px; width: 80px; height: 80px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--dm-surface-soft, #e5ebf3); color: var(--dm-accent-ink, #203f70); cursor: pointer; }
.account-avatar-image { position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; font-weight: 500; }
.account-avatar-image img, .portal-sidebar-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.account-avatar-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: white; background: rgb(32 63 112 / 65%); opacity: 0; transition: opacity 150ms ease; }
.account-avatar-overlay svg { width: 26px; height: 26px; }
.account-avatar-button:focus-visible .account-avatar-overlay { opacity: 1; }
@media (hover: hover) {
  .account-avatar-button:hover .account-avatar-overlay { opacity: 1; }
}
.account-avatar-button:focus-visible { outline: 2px solid var(--dm-accent-line, #203f70); outline-offset: 3px; }
.account-avatar-button:disabled { cursor: wait; opacity: .65; }
.account-preferred-name { flex: 0 1 404px; min-width: 0; }
.account-preferred-name label { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: 14px; }
.account-name-controls { display: flex; gap: 12px; }
#accountPreferredName { width: 100%; min-width: 0; height: 42px; padding: 9px 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 16px; }
#accountIdentitySave { flex: 0 0 auto; min-width: 72px; }
.account-preferred-name p, .account-avatar-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.account-avatar-hint { margin-top: 16px; }
.account-identity-form .auth-message { margin: 12px 0 0; }

/* Keep Security compact; sensitive forms live in their own dialogs. */
#portalPreferencesDialog :is(.account-settings-row--action, .account-settings-row--inline) {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}
#portalPreferencesDialog .account-settings-row--inline > :is(.account-menu, button) { justify-self: end; }
.account-settings-switch { position: relative; display: block; flex: 0 0 auto; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background-color 120ms ease; }
.account-settings-switch::before { content: ''; position: absolute; inset: 11px 2px; border: 1px solid var(--line); background: var(--surface-soft); transition: background-color 140ms ease, border-color 140ms ease; }
.account-settings-switch > span { position: absolute; top: 15px; left: 6px; width: 14px; height: 14px; background: var(--muted); transition: transform 140ms ease, background-color 140ms ease; }
.account-settings-switch[aria-checked="true"]::before { background: var(--brand-color); border-color: var(--brand-color); }
.account-settings-switch[aria-checked="true"] > span { transform: translateX(18px); background: #fff; }
.account-settings-switch:active { background: var(--portal-sidebar-press); }
@media (prefers-reduced-motion: reduce) { .account-settings-switch, .account-settings-switch::before, .account-settings-switch > span { transition: none; } }
#portalPreferencesDialog .account-security-action { justify-self: end; }
#portalPreferencesDialog .account-security-feedback { color: var(--dm-success-ink, #28704d); }
.security-dialog {
  width: min(480px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--dm-surface, #fff);
  color: var(--ink);
  box-shadow: 0 16px 64px rgb(12 31 55 / 16%);
  opacity: 0;
  transform: scale(.98);
  transition: opacity 160ms cubic-bezier(.4, 0, .2, 1), transform 160ms cubic-bezier(.4, 0, .2, 1);
}
.security-dialog[open] { display: flex; flex-direction: column; }
.security-dialog.is-visible { opacity: 1; transform: scale(1); }
.security-dialog::backdrop { background: rgb(0 0 0 / 12%); opacity: 0; transition: opacity 160ms ease; }
.security-dialog.is-visible::backdrop { opacity: 1; }
.security-dialog-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: 18px 18px 12px 24px; gap: 16px; }
.security-dialog-header h2 { margin: 0; font-family: var(--font-sans); font-size: 18px; font-weight: 500; letter-spacing: 0; outline: none; }
.security-dialog .security-dialog-form { display: flex; flex-direction: column; min-height: 0; gap: 0; }
.security-dialog-body { display: grid; gap: 18px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 24px 24px; }
.security-dialog-description { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.security-dialog .auth-form label { min-width: 0; font-size: 13px; font-weight: 500; }
.security-dialog .auth-form input { min-width: 0; min-height: 42px; font-size: 14px; }
.security-dialog .auth-message { margin: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.security-dialog-footer { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
.security-dialog .auth-secondary { min-height: 36px; font-size: 13px; font-weight: 500; }
.security-dialog-footer .auth-secondary { min-height: 44px; }
.security-dialog button, #portalPreferencesDialog .account-security-action { transition: background-color 120ms ease, border-color 120ms ease; }
.security-dialog button:active, #portalPreferencesDialog .account-security-action:active { transform: none; }
.security-dialog button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.security-dialog button:disabled { opacity: .45; cursor: default; }
.security-passkey-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 4px; }
.security-passkey-heading h3 { margin: 0; font-family: var(--font-sans); font-size: 13px; font-weight: 500; }
.security-dialog .passkey-list { gap: 16px; }
.security-dialog .passkey-row { padding: 0; border: 0; }
.security-dialog .passkey-row > div { min-width: 0; overflow-wrap: anywhere; }
.security-dialog .passkey-row strong { font-weight: 500; }
.security-dialog .passkey-row .auth-secondary { flex: 0 0 auto; }
.security-passkey-name { margin-top: 8px; }
@media (hover: hover) {
  .security-dialog .auth-primary:hover:not(:disabled) { background: var(--dm-accent-fill, #19335d); opacity: 1; }
}
@media (max-width: 480px) {
  .security-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  .security-dialog-header { padding-left: 20px; }
  .security-dialog-body { padding-inline: 20px; }
  .security-dialog-footer { padding-inline: 20px; }
  .security-dialog .auth-form input { font-size: 16px; }
  .security-dialog .auth-secondary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .security-dialog, .security-dialog::backdrop, .security-dialog button, #portalPreferencesDialog .account-security-action { transition: none; }
}

/* A compact photo chooser, with local preview before an explicit save. */
.avatar-picker {
  width: min(440px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--dm-surface, #fff);
  color: var(--ink);
  box-shadow: 0 16px 64px rgb(12 31 55 / 16%);
}
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) {
  opacity: 0;
  transform: scale(.98);
  transition: opacity 160ms cubic-bezier(.4, 0, .2, 1), transform 160ms cubic-bezier(.4, 0, .2, 1);
}
.avatar-picker[open] { display: flex; flex-direction: column; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog)[open] { animation: none; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog).is-visible { opacity: 1; transform: scale(1); }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog)::backdrop { background: rgb(0 0 0 / 12%); opacity: 0; animation: none; transition: opacity 160ms ease; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog).is-visible::backdrop { opacity: 1; }
.avatar-picker-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: 18px 18px 12px 24px; gap: 16px; }
.avatar-picker-header h2 { margin: 0; font-family: var(--font-sans); font-size: 18px; font-weight: 500; letter-spacing: 0; outline: none; }
.avatar-picker-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 24px 0; }
.avatar-picker-upload { display: flex; align-items: center; gap: 20px; }
.avatar-picker-upload > div { min-width: 0; }
.avatar-picker-preview { position: relative; display: grid; place-items: center; flex: 0 0 80px; width: 80px; height: 80px; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--dm-surface-soft, #e5ebf3); color: var(--dm-accent-ink, #203f70); font-size: 24px; font-weight: 500; }
.avatar-picker-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-picker-upload-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 7px 12px; border: 1px solid var(--dm-line, #d8dfe8); background: var(--dm-surface, #fff); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; }
.avatar-picker-upload-button svg { width: 16px; height: 16px; }
.avatar-picker-upload p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.avatar-picker-body h3 { margin: 26px 0 12px; color: var(--ink-soft); font-family: var(--font-sans); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.avatar-picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; scrollbar-width: thin; }
.avatar-picker-option { position: relative; display: grid; place-items: center; min-width: 0; padding: 10px 8px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.avatar-picker-option img { display: block; width: 72px; max-width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 50%; }
.avatar-picker-option[aria-pressed="true"] { border-color: var(--dm-accent-line, #203f70); background: var(--dm-surface-soft, #f2f5f9); }
.avatar-picker-check { position: absolute; bottom: 7px; right: 7px; display: grid; place-items: center; width: 18px; height: 18px; border: 2px solid var(--dm-line, #fff); border-radius: 50%; background: var(--dm-accent-fill, #203f70); color: white; opacity: 0; }
.avatar-picker-check svg { width: 14px; height: 14px; }
.avatar-picker-option[aria-pressed="true"] .avatar-picker-check { opacity: 1; }
.avatar-picker-message { min-height: 18px; margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.avatar-picker-message.error { color: var(--dm-danger-ink, #a33232); }
.avatar-picker-footer { display: flex; flex: 0 0 auto; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 24px 22px; }
.avatar-picker-footer button, .manage-dialog-footer button { min-height: 36px; padding: 8px 14px; border: 1px solid transparent; font-family: var(--font-sans); font-size: 13px; font-weight: 500; cursor: pointer; }
.avatar-picker-cancel, .manage-dialog-footer [data-manage-close] { background: transparent; color: var(--ink-soft); }
.avatar-picker-save, .manage-dialog-footer .manage-primary-button { min-width: 108px; background: var(--dm-accent-fill, #203f70); color: #fff; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) button { transition: background-color 120ms ease, border-color 120ms ease; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) button:active:not(:disabled) { transform: none; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) button:disabled { opacity: .45; cursor: default; }
:is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) button:focus-visible { outline: 2px solid var(--dm-accent-line, #203f70); outline-offset: 2px; }
@media (hover: hover) {
  .avatar-picker-option:hover, .avatar-picker-cancel:hover, .avatar-picker-upload-button:hover, .manage-dialog-footer [data-manage-close]:hover { background: var(--dm-surface-soft, #f3f4f5); }
  .avatar-picker-option[aria-pressed="true"]:hover { background: var(--dm-accent-soft, #eaf0f7); }
  .avatar-picker-save:hover:not(:disabled), .manage-dialog-footer .manage-primary-button:hover:not(:disabled) { background: var(--dm-accent-fill, #19335d); }
}
@media (max-width: 480px) {
  .avatar-picker-header { padding-left: 20px; }
  .avatar-picker-body { padding-inline: 20px; }
  .avatar-picker-upload { gap: 16px; }
  .avatar-picker-preview { flex-basis: 64px; width: 64px; height: 64px; }
  .avatar-picker-option { padding: 8px 5px; }
  .avatar-picker-option img { width: 70px; }
  .avatar-picker-footer { padding: 12px 20px 20px; }
  .avatar-picker-upload-button, .avatar-picker-footer button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog),
  :is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog)::backdrop,
  :is(.avatar-picker, .manage-account-dialog, .manage-delete-dialog) button { transition: none; }
}
@media (max-width: 360px) {
  .avatar-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-height: none; }
}
@keyframes portal-preferences-open { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes portal-preferences-backdrop { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 820px) {
  .portal-sidebar-account { margin-top: auto; padding: 14px 12px max(14px, env(safe-area-inset-bottom)); }
  .portal-settings-button { width: 40px; height: 40px; flex-basis: 40px; }
}
@media (max-width: 620px) {
  #portalPreferencesDialog {
    --preferences-gutter: 18px;
    max-height: 86vh;
    max-height: 86dvh;
  }
  .account-identity-editor { align-items: flex-start; gap: 16px; }
  .account-avatar-button { flex-basis: 64px; width: 64px; height: 64px; margin-top: 26px; }
  .account-name-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  #accountPreferredName { height: 44px; }
  #accountIdentitySave { min-width: 60px; min-height: 44px; padding: 8px 10px; white-space: nowrap; }
  .portal-preferences-dialog { width: calc(100% - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .portal-preferences-header { padding: 12px 18px; }
  .portal-preferences-header h2 { font-size: 20px; }
  .portal-preferences-body { padding: 0 18px 24px; }
  .portal-preferences-body .account-settings-row { grid-template-columns: minmax(0, 1fr); }
  .portal-preferences-body .auth-form input, .portal-preferences-body select { font-size: 16px; }
  .portal-preferences-body .auth-primary, .portal-preferences-body .auth-secondary { min-height: 44px; }
  .portal-preferences-body .owner-invitation-result > div { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-preferences-dialog[open], .portal-preferences-dialog::backdrop { animation: none; }
  #portalPreferencesDialog, #portalPreferencesDialog::backdrop { transition: none; }
  .portal-settings-button, .account-avatar-overlay { transition: none; }
}

/* Owner account management. */
.portal-tab[hidden] { display: none; }
.portal-page[data-tab="manage-account"] #portalBanner,
.portal-page[data-tab="manage-account"] .portal-portal-tools,
.portal-page[data-tab="deposit-withdraw"] #portalBanner,
.portal-page[data-tab="deposit-withdraw"] .portal-portal-tools { display: none; }
.manage-accounts-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; }
.manage-accounts-toolbar p { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.manage-accounts-controls { display: flex; gap: 12px; }
#manageAccountsSearch { width: 260px; min-width: 0; min-height: 40px; border: 1px solid var(--line); padding: 9px 12px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.managed-account-table-wrap { border: 1px solid var(--line); background: var(--card); }
.managed-account-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.managed-account-table th { padding: 14px 18px; font-weight: 500; color: var(--muted); background: var(--surface-subtle); border-bottom: 1px solid var(--line); }
.managed-account-table td { padding: 20px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.managed-account-table tr:last-child td { border-bottom: 0; }
.managed-account-table td:first-child { max-width: 300px; overflow-wrap: anywhere; }
.managed-account-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.managed-account-details { min-width: 0; }
.managed-account-avatar { position: relative; display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; background: var(--dm-surface-soft, #e5ebf3); color: var(--brand-ink); font-size: 13px; font-weight: 500; }
button.managed-account-avatar { min-height: 0; padding: 0; border: 0; box-shadow: none; cursor: pointer; transform: none; transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) {
  button.managed-account-avatar:hover { background: var(--portal-sidebar-hover); }
}
button.managed-account-avatar:active { background: var(--portal-sidebar-press); }
button.managed-account-avatar:focus { outline: none; }
button.managed-account-avatar:focus-visible { outline: 1px solid var(--focus); outline-offset: 3px; }
.managed-account-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.managed-account-table strong { display: block; font-weight: 500; font-size: 14px; }
.managed-account-email { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.managed-account-you { margin-left: 8px; color: var(--dm-accent-ink, #203f70); font-size: 11px; font-weight: 400; }
.managed-account-role { color: var(--dm-accent-ink, #203f70); }
.managed-account-actions { white-space: nowrap; }
#managedAccountEmpty { padding: 28px 18px; }
html:has(.manage-account-dialog[open], .manage-delete-dialog[open]) { overflow: hidden; }
.manage-account-dialog { width: min(760px, calc(100% - 48px)); }
.manage-delete-dialog { width: min(520px, calc(100% - 48px)); }
.manage-account-form { display: flex; flex-direction: column; min-height: 0; }
.manage-account-form .portal-preferences-body { padding-top: 24px; }
.manage-account-form h3 { margin: 28px 0 20px; font-family: var(--font-sans); font-size: 17px; font-weight: 500; }
.manage-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.manage-field-wide { grid-column: 1 / -1; }
.manage-account-form label { display: grid; min-width: 0; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.manage-account-form input, .manage-account-form select { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; min-height: 42px; border: 1px solid var(--dm-line, #d8dfe8); border-radius: 0; background: var(--dm-surface, white); color: var(--ink); padding: 9px 10px; font: inherit; }
.manage-account-form select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23647084' stroke-width='1.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; }
.manage-account-form input[type="date"] { appearance: none; -webkit-appearance: none; height: 42px; min-height: 0; line-height: 22px; text-align: left; }
.manage-account-form input[type="date"]::-webkit-date-and-time-value { min-width: 0; height: 22px; text-align: left; }
.manage-account-form input[type="date"]::-webkit-datetime-edit { padding: 0; }
.manage-account-form select:disabled { background: var(--surface-soft); color: var(--muted); }
.manage-account-hint { margin: 14px 0 0; font-size: 13px; line-height: 1.65; color: var(--muted); }
.manage-dialog-footer { flex: 0 0 auto; padding: 18px 28px; border-top: 1px solid var(--line); }
.manage-dialog-footer > div { display: flex; justify-content: flex-end; gap: 12px; }
.manage-dialog-footer .manage-edit-delete { margin-inline-end: auto; background: transparent; color: var(--dm-danger-ink, #a33232); }
@media (hover: hover) {
  .manage-dialog-footer .manage-edit-delete:hover:not(:disabled) { background: var(--dm-surface-soft, #f3f4f5); }
}
.manage-dialog-footer .manage-edit-delete:active:not(:disabled) { background: var(--portal-sidebar-press); }
.manage-dialog-footer .auth-message { margin: 0 0 14px; }
.manage-primary-button, .manage-danger-button { min-height: 40px; padding: 9px 18px; color: white; border: 0; background: var(--dm-accent-fill, #203f70); font: inherit; font-size: 13px; cursor: pointer; }
.manage-danger-button { background: var(--dm-danger-fill, #a33232); }
.manage-primary-button:disabled, .manage-danger-button:disabled { opacity: .55; cursor: wait; }
#manageDeleteEmail { overflow-wrap: anywhere; font-size: 15px; font-weight: 500; }
.manage-delete-dialog label { margin-top: 24px; }
@media (max-width: 1050px) { .manage-accounts-toolbar { flex-wrap: wrap; } }
@media (max-width: 620px) {
  .manage-accounts-toolbar, .manage-accounts-controls { width: 100%; }
  #manageAccountsSearch { flex: 1; width: 0; font-size: 16px; }
  .managed-account-table thead { display: none; }
  .managed-account-table, .managed-account-table tbody { display: block; }
  .managed-account-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 20px 16px; gap: 18px 12px; border-bottom: 1px solid var(--line); }
  .managed-account-table tr:last-child { border: 0; }
  .managed-account-table td { display: block; padding: 0; border: 0; }
  .managed-account-table td:first-child, .managed-account-table .managed-account-actions { grid-column: 1 / -1; max-width: none; }
  .managed-account-table td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; margin-bottom: 6px; font-size: 11px; color: var(--muted); }
  .managed-account-actions button { min-height: 40px; }
  .manage-account-dialog, .manage-delete-dialog { width: calc(100% - 24px); }
  .manage-fields-grid { grid-template-columns: minmax(0, 1fr); }
  .manage-account-form input, .manage-account-form select { font-size: 16px; }
  .manage-dialog-footer { padding: 16px 18px; }
  .manage-dialog-footer button { min-height: 44px; }
}
@media (max-width: 360px) {
  .manage-account-dialog .manage-dialog-footer > div { gap: 8px; }
  .manage-account-dialog .manage-dialog-footer button { padding-inline: 10px; white-space: nowrap; }
}

/* Keep unavailable sections visible without hover, press or navigation feedback. */
.portal-tab[aria-disabled="true"] {
  opacity: .4;
  cursor: not-allowed;
  background: transparent;
  color: var(--portal-ink);
}

/* Compact controls share the sidebar's hover/press colors without moving. */
.portal-refresh-button,
#portalPreferencesDialog .portal-refresh-button,
.security-dialog .portal-refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.portal-refresh-button svg { width: 16px; height: 16px; }
:is(.portal-settings-button, #portalPreferencesDialog .account-security-action, .portal-refresh-button, #portalPreferencesDialog .account-menu-trigger, #portalPreferencesDialog .account-menu-option) {
  transition: background-color 120ms ease, color 120ms ease;
}
@media (hover: hover) and (pointer: fine) {
  :is(.portal-settings-button, #portalPreferencesDialog .account-security-action, .portal-refresh-button, #portalPreferencesDialog .account-menu-trigger, #portalPreferencesDialog .account-menu-option):hover:not(:disabled) {
    background: var(--portal-sidebar-hover);
    color: var(--portal-ink);
  }
}
:is(.portal-settings-button, #portalPreferencesDialog .account-security-action, .portal-refresh-button, #portalPreferencesDialog .account-menu-trigger, #portalPreferencesDialog .account-menu-option):active:not(:disabled) {
  background: var(--portal-sidebar-press);
  color: var(--portal-ink);
}
.portal-refresh-button:disabled { cursor: wait; }
.invitation-select-field { display: grid; align-content: start; gap: 8px; min-width: 0; }
.invitation-select-label { font-size: 14px; font-weight: 500; cursor: default; }
.invitation-select { min-width: 0; width: 100%; }
.invitation-select .account-menu-trigger { width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; font-size: 13px; }
.invitation-select .account-menu-trigger:focus-visible { outline: 1px solid var(--focus); outline-offset: 0; border-color: var(--brand-color); }
.invitation-select-options {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 10;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 8px 24px rgb(17 24 39 / 10%);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms;
}
.invitation-select.is-open .invitation-select-options { visibility: visible; opacity: 1; pointer-events: auto; }
.invitation-select.opens-up .invitation-select-options { top: auto; bottom: calc(100% + 5px); }
.invitation-select .account-menu-option { min-height: 34px; padding: 6px 8px; gap: 8px; font-size: 13px; }
.invitation-select .account-menu-option.is-highlighted { background: var(--portal-sidebar-hover); }
@media (max-width: 620px) {
  #portalPreferencesDialog { font-size: 13px; }
  #portalPreferencesDialog .portal-preferences-header h2 { font-size: 18px; }
  #portalPreferencesDialog :is(.portal-section-heading h2, .owner-invitations h2) { font-size: 14px; }
  #portalPreferencesDialog :is(.account-settings-copy strong, .account-settings-value, .account-preferred-name label, .auth-form label, .invitation-select-label) { font-size: 12px; }
  #portalPreferencesDialog :is(.account-settings-copy p, .account-avatar-hint, .owner-invitations > p, .owner-invitation-result p, .auth-message) { font-size: 11px; }
  #portalPreferencesDialog :is(.auth-primary, .auth-secondary, .account-menu-trigger, .account-menu-option) { font-size: 12px; }
  #portalPreferencesDialog .owner-invitation-list strong { font-size: 12px; }
  #portalPreferencesDialog .owner-invitation-list span { font-size: 11px; }
  .portal-refresh-button, #portalPreferencesDialog .portal-refresh-button, .security-dialog .portal-refresh-button { flex-basis: 36px; width: 36px; height: 36px; min-height: 36px; }
  /* Keep editable fields at 16px to prevent iOS Safari's automatic zoom. */
  #portalPreferencesDialog input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-refresh-button.refreshing svg { animation: none; }
  .invitation-select-options { transition: none; }
}

/* The member directory slides below the breadcrumb, leaving Portal chrome aligned. */
#communityMembersToggle[hidden] { display: none; }
#communityMembersToggle[aria-expanded="true"] { background: var(--portal-sidebar-press); }
#communityMembersToggle.is-pointer-focus:focus { outline: none; }
.community-members-drawer {
  position: fixed; inset: var(--community-members-top, 112px) 0 auto auto;
  width: min(288px, calc(100vw - 48px)); max-width: none; max-height: none;
  margin: 0; padding: 0; overflow: hidden; border: 0; border-left: 1px solid var(--line);
  background: var(--bg); color: var(--ink-soft);
  transform: translateX(100%); transition: transform 220ms cubic-bezier(.22,.61,.36,1);
}
.community-members-drawer[open] { display: flex; flex-direction: column; }
.community-members-drawer:focus { outline: none; }
.community-members-drawer.is-visible { transform: translateX(0); }
.community-members-drawer::backdrop { inset: var(--community-members-top, 112px) 0 0; background: rgb(12 26 45 / 16%); opacity: 0; transition: opacity 220ms ease; }
.community-members-drawer.is-visible::backdrop { opacity: 1; }
.community-members-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.community-members-header h2 { margin: 0; font: 500 14px/1.4 var(--font-sans); color: var(--ink-soft); }
#communityMembersCount { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.community-members-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px max(24px, env(safe-area-inset-bottom)); }
.community-members-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; gap: 12px 8px; list-style: none; padding: 0; margin: 0; }
.community-members-list > li { min-width: 0; }
.community-member { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; height: 100%; min-width: 0; padding: 12px 6px; border: 0; background: transparent; box-shadow: none; color: var(--ink-soft); transition: background-color 120ms ease; }
.community-member .community-avatar { width: 60px; height: 60px; flex: 0 0 60px; font-size: 20px; font-weight: 400; }
.community-member-name { width: 100%; text-align: center; font: 400 12px/1.5 var(--font-sans); overflow-wrap: anywhere; }
.community-members-status { margin: 12px 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.community-members-retry { border: 0; background: transparent; color: var(--brand-ink); font-size: 12px; font-weight: 400; padding: 8px; }
.community-members-drawer [hidden] { display: none; }
.community-member:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.community-members-drawer.is-pointer-focus button:focus { outline: none; }
@media (hover: hover) and (pointer: fine) {
  .community-member:hover, .community-members-retry:hover { background: var(--portal-sidebar-hover); }
}
.community-member:active, .community-members-retry:active { background: var(--portal-sidebar-press); }
@media (prefers-reduced-motion: reduce) {
  .community-members-drawer, .community-members-drawer::backdrop { transition: none; }
}

/* Community shares the Portal chrome; only the conversation scrolls. */
html.community-viewport { scroll-behavior: auto; }
html.community-viewport body { min-height: 0; }
html.community-viewport .shell {
  flex: 0 0 auto;
  height: max(0px, calc(var(--community-viewport-height, 100dvh) - var(--topbar-height)));
  min-height: 0;
}
#portalPage[data-tab="community"], #portalPage[data-tab="community"] .portal-portal { height: 100%; min-height: 0; }
#portalPage[data-tab="community"] .portal-portal { grid-template-rows: minmax(0, 1fr); }
#portalPage[data-tab="community"] .portal-portal > .portal-portal-nav { top: 0; height: 100%; }
#portalPage[data-tab="community"] .portal-portal-main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 0; }
#portalPage[data-tab="community"] .portal-portal-header { position: relative; top: auto; flex: 0 0 auto; }
#portalPage[data-tab="community"] .portal-page-body { display: flex; flex-direction: column; flex: 1; min-height: 0; max-width: none; padding: 0; }
#portalPage[data-tab="community"] :is(.portal-page-heading, #portalMeta, #portalPrivacyToggle, #portalBanner) { display: none; }
.community-panel:not([hidden]) { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; background: var(--dm-surface, #fff); }
.community-badge { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; width: 18px; height: 18px; padding: 0; margin-left: auto; border-radius: 50% !important; background: var(--brand-color); color: white; font-size: 9px; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; }
.community-conversation { position: relative; flex: 1 1 0; min-height: 0; }
.community-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 12px 32px 20px; }
.community-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.community-empty { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--muted); padding: 32px 16px; }
.community-empty-symbol { color: var(--dm-muted, #a9b6c7); font-size: 46px; font-weight: 300; line-height: 1; }
.community-empty h3 { color: var(--brand-ink); font-size: 19px; font-weight: 400; margin: 18px 0 8px; }
.community-empty p { font-size: 13px; margin: 0; max-width: 340px; line-height: 1.7; }
.community-date { display: flex; align-items: center; gap: 16px; color: var(--dm-muted, #808998); font-size: 11px; font-weight: 500; padding: 20px 0; }
.community-date::before, .community-date::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.community-new-divider { margin: 12px 0; padding-top: 6px; border-top: 1px solid var(--dm-line, #a7b7cf); color: var(--brand-ink); font-size: 10px; text-align: right; }
.community-message { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.community-message--own { flex-direction: row-reverse; }
.community-message > .community-avatar { flex-shrink: 0; margin-top: 2px; }
.community-avatar { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% !important; overflow: hidden; background: var(--dm-surface-soft, #edf0f5); color: var(--brand-ink); font-size: 11px; user-select: none; }
.community-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.community-message-content { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; max-width: min(76%, 680px); }
.community-message--own .community-message-content { align-items: flex-end; }
.community-message-header { display: flex; align-items: center; gap: 8px; min-height: 24px; max-width: 100%; }
.community-message--own .community-message-header { flex-direction: row-reverse; }
.community-message-header strong { min-width: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; color: var(--dm-ink, #2c3848); }
.community-message-header time { color: var(--dm-muted, #8a929e); font-size: 10px; flex-shrink: 0; }
.community-message-bubble { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 100%; padding: 11px 15px; background: var(--dm-surface-soft, #f1f3f6); color: var(--dm-ink-soft, #374151); transition: background-color 120ms ease, box-shadow 120ms ease; }
.community-message--own .community-message-bubble { background: var(--brand-color); color: #fff; }
.community-message-bubble.is-selected { background: var(--dm-hover, #dce4ee); box-shadow: 0 3px 12px #203f7026; }
.community-message--own .community-message-bubble.is-selected { background: var(--dm-accent-fill, #345784); }
.community-message-bubble.has-reactions { margin-top: 22px; min-width: min(100%, var(--community-reaction-width)); }
.community-reactions { position: absolute; top: -25px; right: 6px; display: flex; flex-wrap: wrap; gap: 1px; max-width: calc(100% - 12px); padding: 2px; border: 1px solid var(--dm-line, #d7dce3); border-radius: 999px !important; background: var(--dm-surface, #fff); color: var(--portal-ink); }
.community-panel .community-reaction { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 2px 4px; border: 0; border-radius: 999px !important; background: transparent; color: inherit; font: 16px/20px var(--font-sans); box-shadow: none; }
.community-panel .community-reaction:has(.community-reaction-count) { width: auto; }
.community-reaction-count { font-size: 10px; line-height: 1; }
.community-panel .community-reaction[aria-pressed="true"] { background: var(--dm-accent-soft, #e8eef6); color: var(--brand-ink); }
@media (hover: hover) and (pointer: fine) {
  .community-panel .community-reaction:hover { background: var(--portal-sidebar-hover); }
}
.community-panel .community-reaction:active { background: var(--portal-sidebar-press); transform: none; }
.community-panel .community-reaction:focus { outline: none; }
.community-panel .community-reaction:focus-visible { outline: 1px solid var(--focus); }
.community-message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.65; color: inherit; }
.community-panel .community-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; min-height: 0; padding: 6px; border: 0; color: var(--dm-muted, #657184); background: transparent; box-shadow: none; transition: background-color 120ms ease, color 120ms ease; }
.community-icon-button svg, .community-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.community-panel .community-reply-action { flex: 0 0 28px; opacity: 0; height: 24px; width: 28px; }
.community-message:focus-within .community-reply-action { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .community-message:hover .community-reply-action { opacity: 1; }
}
.community-quote { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 5px 10px; border-left: 2px solid var(--dm-line, #afbdd1); color: var(--dm-muted, #6c7787); font-size: 12px; }
.community-quote strong { font-size: 11px; font-weight: 500; color: var(--brand-ink); }
.community-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-message--own .community-quote { border-color: var(--dm-accent-line, #a8bddb); color: var(--dm-muted, #e0e8f4); }
.community-message--own .community-quote strong { color: #fff; }
.community-message-images { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; max-width: 100%; }
.community-message-images a { display: block; max-width: min(100%, 360px); }
.community-message-images img { display: block; max-width: 100%; width: 100%; height: auto; object-fit: contain; background: var(--dm-surface-soft, #f4f5f7); border: 1px solid var(--line); }
.community-composer-area { flex: 0 0 auto; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 8px 32px 14px; }
.community-composer { position: relative; border: 1px solid var(--dm-line, #d7dce3); background: var(--dm-surface, #fff); transition: border-color 120ms; }
/* Desktop keeps two lines; mobile grows from one line to two based on its draft. */
.community-composer textarea { display: block; box-sizing: border-box; resize: none; width: 100%; min-width: 0; height: 66px; min-height: 66px; max-height: 66px; overflow-y: auto; padding: 12px 14px 6px; border: 0; box-shadow: none; outline: 0; background: transparent; font: 14px/1.5 var(--font-sans); color: var(--ink); }
/* Chat keeps its neutral edge while typing; override the shared form focus ring. */
#communityInput:focus { border-color: transparent !important; box-shadow: none !important; outline: none !important; }
.community-composer-tools { display: flex; align-items: center; justify-content: space-between; padding: 3px 9px 8px; }
.community-composer-left { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 11px; }
.community-panel .community-send { display: grid; place-items: center; padding: 6px; height: 30px; width: 36px; min-height: 0; border: 1px solid var(--brand-color); color: #fff; background: var(--brand-color); box-shadow: none; }
.community-panel .community-send:disabled { opacity: .35; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .community-panel .community-send:not(:disabled):hover { background: var(--dm-accent-fill, #2b4d7f); }
}
.community-panel .community-send:not(:disabled):active { background: var(--dm-accent-fill, #19355e); }
.community-send.is-sending svg { animation: community-send-pulse 900ms ease infinite; }
@keyframes community-send-pulse { 50% { opacity: .35; } }
.community-composer-hint { font-size: 10px; margin: 6px 0 0; color: var(--dm-muted, #959ca6); text-align: right; }
.community-notice { margin: 0 0 8px; color: var(--dm-danger-ink, #963f3f); font-size: 12px; line-height: 1.5; }
.community-reply { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--dm-surface-soft, #f7f8fa); }
.community-reply-preview { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; }
.community-reply-preview strong { font-size: 11px; font-weight: 500; color: var(--brand-ink); }
.community-reply-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.community-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; }
.community-attachment-preview { display: flex; align-items: flex-start; border: 1px solid var(--line); }
.community-attachment-preview img { width: 64px; height: 56px; object-fit: cover; }
.community-panel .community-attachment-preview button { width: 22px; height: 22px; padding: 4px; }
.community-panel .community-earlier { display: block; margin: 8px auto; padding: 6px 12px; min-height: 30px; border: 0; background: transparent; color: var(--brand-ink); font-size: 11px; font-weight: 400; }
.community-panel .community-jump { position: absolute; bottom: 12px; left: 50%; translate: -50% 0; padding: 7px 14px; min-height: 30px; border: 1px solid var(--line); background: var(--dm-surface, #fff); color: var(--brand-ink); font-size: 11px; box-shadow: 0 2px 8px #203f7010; }
@media (hover: hover) and (pointer: fine) {
  .community-panel :is(.community-icon-button, .community-earlier, .community-jump):not(:disabled):hover { background: var(--portal-sidebar-hover); color: var(--portal-ink); }
}
.community-panel :is(.community-icon-button, .community-earlier, .community-jump):not(:disabled):active { background: var(--portal-sidebar-press); }
.community-panel [hidden], .community-badge[hidden] { display: none !important; }
@media (hover: none) { .community-panel .community-reply-action { opacity: 1; } }
@media (max-width: 820px) {
  .community-scroll { padding: 8px 18px 16px; }
  .community-composer-area { padding: 6px 16px max(12px, env(safe-area-inset-bottom)); }
  .community-composer-hint { display: none; }
  .community-message-text { font-size: 13px; }
  .community-message-header strong { font-size: 12px; }
  .community-message { gap: 10px; padding: 6px 0; }
  .community-message-content { max-width: calc(100% - 64px); }
  .community-message-bubble { padding: 10px 12px; }
  .community-avatar { height: 30px; width: 30px; }
  .community-panel .community-icon-button { width: 34px; height: 34px; }
  .community-panel .community-reply-action { flex-basis: 30px; width: 30px; height: 30px; }
  .community-panel .community-send { height: 34px; width: 38px; }
}
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .community-composer { display: grid; grid-template-columns: 34px minmax(0, 1fr) 38px; column-gap: 4px; align-items: end; padding: 5px 7px; }
  .community-composer > .community-reply { grid-column: 1 / -1; grid-row: 1; }
  .community-composer > .community-attachments { grid-column: 1 / -1; grid-row: 2; padding: 6px 0; }
  .community-composer textarea { grid-column: 2; grid-row: 3; height: 34px; min-height: 34px; max-height: 58px; padding: 5px 4px; font-size: 16px; }
  .community-composer-tools, .community-composer-left { display: contents; }
  .community-panel #communityAttach { grid-column: 1; grid-row: 3; width: 34px; height: 34px; }
  .community-panel .community-send { grid-column: 3; grid-row: 3; width: 38px; height: 34px; }
  #communityUploadStatus { grid-column: 1 / -1; grid-row: 4; padding: 4px; color: var(--muted); font-size: 11px; }
  #communityUploadStatus:empty { display: none; }
}
@media (hover: none) and (pointer: coarse) {
  .community-message { padding: 6px 0; }
  .community-panel .community-reply-action { display: none; }
  .community-message-bubble, .community-message-bubble * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .community-message-bubble img { -webkit-user-drag: none; }
}
.community-message-bubble:focus { outline: none; }
.community-message-bubble:focus-visible { outline: 1px solid var(--focus); outline-offset: 3px; }
.community-message-menu { position: fixed; z-index: 140; width: 202px; max-width: calc(100vw - 16px); padding: 4px; border: 1px solid var(--line); background: var(--dm-surface, #fff); color: var(--portal-ink); box-shadow: 0 6px 24px #182b4526; font-family: var(--font-sans); animation: community-message-menu-in 120ms ease-out; }
.community-message-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: 400 13px/1.4 var(--font-sans); text-align: left; cursor: pointer; box-shadow: none; }
.community-reaction-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; border-bottom: 1px solid var(--line); padding: 2px 0 6px; margin-bottom: 4px; }
.community-reaction-picker button { justify-content: center; padding: 6px 0; font-size: 24px; line-height: 1; }
.community-reaction-picker button[aria-checked="true"] { background: var(--dm-accent-soft, #e8eef6); }
.community-message-menu svg { flex: 0 0 18px; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
@media (hover: hover) and (pointer: fine) {
  .community-message-menu button:not(:disabled):hover { background: var(--portal-sidebar-hover); }
}
.community-message-menu button:not(:disabled):active { background: var(--portal-sidebar-press); transform: none; }
.community-message-menu button:focus-visible { outline: 1px solid var(--focus); outline-offset: -1px; }
@keyframes community-message-menu-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .community-message-menu { animation: none; } .community-message-bubble { transition: none; } }
.community-composer .community-input-measure { position: absolute; top: 0; left: 0; height: 0; min-height: 0; max-height: none; overflow: hidden; visibility: hidden; pointer-events: none; }
/* Keep typing and send controls usable with a short landscape keyboard viewport. */
.community-compact-viewport .community-composer-area { padding: 4px 12px 6px; }
.community-compact-viewport .community-composer textarea { font-size: 16px; }
.community-compact-viewport .community-composer-hint { display: none; }
.community-compact-viewport .community-attachments { max-height: 72px; overflow-y: auto; }
.community-compact-viewport .community-reply { padding: 6px 10px; }
@media (prefers-reduced-motion: reduce) { .community-send.is-sending svg { animation: none; } }

/* Community member cards expose only the shared profile fields. */
.community-panel .community-avatar-button { padding: 0; min-height: 0; border: 0; cursor: pointer; box-shadow: none; font-weight: 400; transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) {
  .community-panel .community-avatar-button:hover { background: var(--portal-sidebar-hover); }
}
.community-panel .community-avatar-button:active { background: var(--portal-sidebar-press); transform: none; }
.community-panel .community-avatar-button:focus { outline: none; }
html:has(#communityProfileDialog[open]) { overflow: hidden; }
.community-profile-dialog { width: min(440px, calc(100% - 32px)); }
.community-profile-dialog .security-dialog-body { display: block; padding-top: 8px; height: 350px; min-height: 0; }
.community-profile-identity { display: flex; align-items: center; gap: 18px; margin: 8px 0 28px; }
.community-profile-identity > div { min-width: 0; }
.community-profile-dialog .community-profile-avatar { width: 68px; height: 68px; flex: 0 0 68px; font-size: 22px; }
.community-profile-identity p { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.community-profile-identity h3 { margin: 0; font-family: var(--font-sans); font-size: 21px; font-weight: 500; line-height: 1.35; color: var(--brand-ink); overflow-wrap: anywhere; }
.community-profile-details { display: grid; gap: 18px; margin: 0; }
.community-profile-details > div { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px; align-items: baseline; }
.community-profile-details dt { color: var(--muted); font-size: 12px; line-height: 1.6; }
.community-profile-details dd { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.community-profile-status { min-height: 18px; margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.community-profile-status.error { color: var(--dm-danger-ink, #963f3f); }
@media (hover: hover) and (pointer: fine) {
  .community-profile-dialog .portal-settings-button:hover { background: var(--portal-sidebar-hover); }
}
.community-profile-dialog .portal-settings-button:active { background: var(--portal-sidebar-press); }
@media (max-width: 480px) {
  .community-profile-dialog { width: calc(100% - 32px); max-height: 86dvh; }
  .community-profile-identity { gap: 14px; margin-bottom: 24px; }
  .community-profile-identity h3 { font-size: 18px; }
  .community-profile-dialog .community-profile-avatar { width: 58px; height: 58px; flex-basis: 58px; font-size: 18px; }
  .community-profile-details > div { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
  .community-profile-details dt { font-size: 11px; }
  .community-profile-details dd { font-size: 12px; }
}

/* Pending funding requests use the same dialog and button treatments as account editing. */
.managed-pending-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.managed-pending-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--dm-warning-soft, #fffbeb); color: var(--dm-warning-ink, #92400e); font-size: 11px; white-space: nowrap; }
.managed-pending-badge::before { content: ''; width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: var(--dm-warning-fill, #b7791f); }
.managed-requests-owner { margin: 0 0 24px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.manage-requests-dialog > .portal-preferences-body { padding-top: 24px; }
.managed-request-card { border: 1px solid var(--line); margin-bottom: 16px; }
.managed-request-card:last-child { margin-bottom: 0; }
.managed-request-card > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px; cursor: pointer; list-style: none; }
.managed-request-card > summary::-webkit-details-marker { display: none; }
.managed-request-card > summary::after { content: '+'; margin-left: auto; color: var(--muted); }
.managed-request-card[open] > summary::after { content: '−'; }
.managed-request-type { color: var(--muted); font-size: 13px; }
.managed-request-card > summary strong { color: var(--brand-ink); font-size: 15px; font-weight: 500; }
.managed-request-details { margin: 0; padding: 0 16px 16px; }
.managed-request-details > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 24px; border-top: 1px solid var(--line); padding: 12px 0; font-size: 13px; line-height: 1.6; }
.managed-request-details dt { color: var(--muted); }
.managed-request-details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.withdrawal-review-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }
@media (hover: hover) and (pointer: fine) { .managed-request-card > summary:hover { background: var(--portal-sidebar-hover); } }
.managed-request-card > summary:active { background: var(--portal-sidebar-press); }
@media (max-width: 760px) {
  .managed-account-pending { grid-column: 1 / -1; }
  .managed-request-card > summary { padding: 14px; gap: 8px; }
  .managed-request-details { padding-inline: 14px; }
  .managed-request-details > div { grid-template-columns: minmax(0, 1fr); gap: 4px; font-size: 12px; }
  .withdrawal-review-actions button { flex: 1 1 auto; }
}

/* Personal details share the Preferences dialog controls and motion. */
.account-basic-dialog { width: min(620px, calc(100% - 24px)); }
.account-basic-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; min-width: 0; margin: 0; padding: 0; border: 0; }
.account-basic-wide { grid-column: 1 / -1; }
.account-basic-fields :is(input, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 0; background-color: var(--dm-surface, #fff); color: var(--ink); font: inherit; font-size: 14px; }
.account-basic-fields select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23647084' stroke-width='1.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.account-basic-fields input[type="date"] { appearance: none; -webkit-appearance: none; height: 42px; min-height: 0; line-height: 22px; text-align: left; }
.account-basic-fields input[type="date"]::-webkit-date-and-time-value { min-width: 0; height: 22px; text-align: left; }
.account-basic-fields input[type="date"]::-webkit-datetime-edit { padding: 0; }
#accountBasicReload { justify-self: start; }
@media (max-width: 480px) {
  .account-basic-fields { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .account-basic-fields :is(input, select) { font-size: 16px; }
}
