:root {
  --bg: #f5f5f5;
  --paper: #ffffff;
  --ink: #121417;
  --muted: #626a73;
  --line: #dfe4ea;
  --soft-line: #edf0f4;
  --green: #0f7a2f;
  --red: #b42318;
  --blue: #1d4f91;
  --gold: #c58a14;
  --shadow: 0 8px 24px rgba(18, 20, 23, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 12px clamp(16px, 4vw, 42px);
  background: rgba(245, 245, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0;
}

.management-link,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.management-link:hover,
.ghost-button:hover {
  border-color: #b9c3cf;
  box-shadow: var(--shadow);
}

.management-link.primary {
  background: #fff4cf;
  border-color: #d7b866;
  color: #2f2410;
}

.management-link.primary:hover {
  background: #ffe9a6;
  border-color: #c79b35;
  color: #1f2937;
}

.band {
  width: 100%;
  border-bottom: 1px solid var(--line);
}

.overview-band {
  background: var(--paper);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 42px);
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(480px, 0.9fr);
  gap: 30px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(36px, 6vw, 76px);
  line-height: 0.95;
}

h2 {
  font-size: 24px;
}

.lede {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

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

.metric {
  min-width: 0;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.metric dt {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metric dd {
  margin: 0;
  direction: ltr;
  text-align: right;
  font-size: 25px;
  font-weight: 900;
  line-height: 1.1;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.legend,
.management-legend {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  direction: ltr;
}

.legend span,
.management-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.portfolio {
  background: var(--green);
}

.legend-dot.benchmark {
  background: var(--blue);
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px dashed var(--gold);
}

.chart-shell {
  height: clamp(330px, 47vw, 520px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.table-band {
  background: #fafafa;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f4f7;
  color: #48515c;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.return-table td,
.return-table th {
  text-align: center;
}

.year-cell {
  color: var(--ink);
  font-weight: 900;
}

.positive {
  color: var(--green);
  font-weight: 900;
}

.negative {
  color: var(--red);
  font-weight: 900;
}

.neutral {
  color: var(--muted);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  direction: ltr;
}

.status-pill.live {
  border-color: #b8dec4;
  background: #eef9f1;
  color: var(--green);
}

.status-pill.cash {
  border-color: #e7d5a7;
  background: #fff8e8;
  color: #8a640e;
}

.date-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.date-control input,
.password-row input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 8px 10px;
}

.chart-tools {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.mode-switch button {
  min-width: 86px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.mode-switch button.active {
  background: var(--ink);
  color: var(--paper);
}

.year-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.year-tab {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.year-tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.trade-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--bg);
}

.auth-panel {
  width: min(520px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 28px;
}

.auth-panel h1 {
  margin-bottom: 22px;
  font-size: 34px;
  line-height: 1;
}

.auth-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
}

.password-row button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.manager-app[hidden],
[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .overview {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .management-link,
  .ghost-button {
    width: 100%;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 76px;
  }

  .metric dd {
    font-size: 23px;
  }

  .chart-shell {
    height: 340px;
  }

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

/* Public client display */
body[data-page="public"] {
  background: #f2f4f7;
  overflow-x: hidden;
}

body[data-page="public"] .site-header {
  min-height: 60px;
  background: #ffffff;
  border-bottom-color: #e3e7ed;
}

body[data-page="public"] .management-link {
  min-height: 36px;
  border-radius: 6px;
  box-shadow: none;
}

.public-shell {
  width: 100%;
  max-width: 1220px;
  margin: 24px auto 46px;
  padding: 0 16px;
}

.public-board {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.board-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 2px 4px;
}

.board-head h1 {
  margin: 0;
  font-size: clamp(27px, 3vw, 36px);
  line-height: 1;
  letter-spacing: 0;
}

.portfolio-view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.portfolio-view-switch a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.portfolio-view-switch a.active,
.portfolio-view-switch a:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.portfolio-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  direction: ltr;
}

.portfolio-meta span,
.board-status,
.as-of {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #fff;
  color: #536071;
  font-size: 12px;
  font-weight: 800;
}

.portfolio-meta span,
.as-of {
  gap: 4px;
  direction: ltr;
}

.portfolio-meta b {
  color: #121417;
  font-weight: 900;
}

.board-status {
  gap: 7px;
  color: #102a4c;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.public-panel {
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
  min-width: 0;
  max-width: 100%;
}

.metrics-panel,
.chart-panel,
.monthly-panel {
  padding: 16px 18px 18px;
}

.panel-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title-row h2 {
  color: #102a4c;
  font-size: 18px;
  line-height: 1.15;
}

.client-display-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.client-display-note strong {
  color: var(--ink);
}

.performance-comparison {
  border: 1px solid #e2e7ee;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.performance-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.12fr) repeat(4, minmax(112px, 1fr));
  min-height: 68px;
}

.performance-row + .performance-row {
  border-top: 1px solid #e2e7ee;
}

.series-cell,
.metric-mini {
  min-width: 0;
  padding: 11px 13px;
  border-right: 1px solid #e2e7ee;
}

.series-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: #f7f9fc;
  color: #102a4c;
  direction: ltr;
  font-size: 13px;
  font-weight: 900;
}

.metric-mini {
  display: grid;
  align-content: center;
  gap: 6px;
  background: #fbfcfe;
}

.metric-mini span {
  color: #536071;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.metric-mini strong {
  direction: ltr;
  text-align: left;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}

.benchmark-row .series-cell,
.benchmark-row .metric-mini {
  background: #ffffff;
}

.benchmark-row .metric-mini strong {
  font-size: 18px;
}

.performance-row > :last-child {
  border-right: 0;
}

.public-chart-shell {
  height: clamp(360px, 43vw, 500px);
  border-radius: 6px;
  box-shadow: none;
}

body[data-page="public"] .table-wrap {
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

body[data-page="public"] .return-table {
  direction: ltr;
  min-width: 920px;
}

body[data-page="public"] th {
  background: #f5f7fa;
  color: #455163;
}

body[data-page="public"] .return-table td,
body[data-page="public"] .return-table th {
  padding: 10px 11px;
}

@media (max-width: 1080px) {
  body[data-page="public"] .site-header {
    padding-inline: 24px;
  }

  .performance-row {
    grid-template-columns: minmax(136px, 0.92fr) repeat(4, minmax(104px, 1fr));
  }

  .series-cell,
  .metric-mini {
    padding: 10px 11px;
  }

  .metric-mini strong {
    font-size: 18px;
  }
}

@media (max-width: 860px) {
  .public-shell {
    margin-top: 18px;
  }

  .metrics-panel,
  .chart-panel,
  .monthly-panel {
    padding: 14px;
  }

  .public-chart-shell {
    height: 380px;
  }

  .performance-row {
    grid-template-columns: minmax(124px, 0.84fr) repeat(4, minmax(94px, 1fr));
  }

  .metric-mini span {
    font-size: 10px;
  }
}

@media (max-width: 720px) {
  body[data-page="public"] .site-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: 9px 10px;
  }

  body[data-page="public"] .brand {
    min-width: 0;
    font-size: 14px;
  }

  body[data-page="public"] .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-page="public"] .brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }

  body[data-page="public"] .management-link {
    width: auto;
    min-width: 38px;
    min-height: 34px;
    padding: 7px 10px;
    flex: 0 0 auto;
  }

  body[data-page="public"] .management-link span:last-child {
    display: none;
  }

  .public-shell {
    width: 100%;
    padding: 0 10px;
    margin-top: 14px;
  }

  .board-head,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .board-head {
    gap: 12px;
  }

  .portfolio-meta {
    gap: 6px;
  }

  .portfolio-meta span,
  .board-status,
  .as-of {
    min-height: 26px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .performance-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
  }

  .series-cell {
    grid-column: 1 / -1;
    min-height: 42px;
    border-right: 0;
    border-bottom: 1px solid #e2e7ee;
  }

  .metric-mini {
    min-height: 60px;
    border-right: 1px solid #e2e7ee;
  }

  .performance-row > .metric-mini:nth-child(3),
  .performance-row > .metric-mini:nth-child(5) {
    border-right: 0;
  }

  .benchmark-row .metric-mini strong,
  .metric-mini strong {
    font-size: 17px;
  }

  .public-chart-shell {
    height: 330px;
  }
}

@media (max-width: 460px) {
  .metrics-panel,
  .chart-panel,
  .monthly-panel {
    padding: 12px;
  }

  .board-head h1 {
    font-size: 27px;
  }

  .panel-title-row h2 {
    font-size: 17px;
  }

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

  .series-cell,
  .metric-mini,
  .performance-row > .metric-mini:nth-child(3),
  .performance-row > .metric-mini:nth-child(5) {
    border-right: 0;
    border-bottom: 1px solid #e2e7ee;
  }

  .performance-row > :last-child {
    border-bottom: 0;
  }

  .metric-mini {
    min-height: 54px;
  }

  .public-chart-shell {
    height: 295px;
  }

  body[data-page="public"] .return-table {
    min-width: 820px;
  }
}

@media (max-width: 360px) {
  body[data-page="public"] .brand span:last-child {
    max-width: 138px;
  }

  .portfolio-meta {
    align-items: stretch;
    flex-direction: column;
  }

  .portfolio-meta span {
    justify-content: space-between;
    width: 100%;
  }
}

/* Management console */
body[data-page="manage"] {
  background: #eef1f5;
  direction: ltr;
  overflow-x: hidden;
}

body[data-page="manage"] .manage-header {
  min-height: 58px;
  padding: 10px clamp(16px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom-color: #dfe5ec;
}

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

.manage-shell {
  display: grid;
  gap: 12px;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2.6vw, 32px) 42px;
}

.manage-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 2px 2px 4px;
}

.manage-hero h1 {
  font-size: clamp(24px, 2.7vw, 34px);
  line-height: 1;
}

.manage-context {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.manage-context span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #ffffff;
  color: #536071;
  font-size: 12px;
  font-weight: 850;
}

.manage-context b {
  color: #121417;
}

.manage-context b.export-ok {
  color: var(--green);
}

.manage-context b.export-warning {
  color: #a66b00;
}

.manage-context b.export-failed {
  color: var(--red);
}

.manage-context b.export-legacy {
  color: var(--muted);
}

.management-metrics {
  display: flex;
  gap: 0;
  margin: 0;
  overflow-x: auto;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

body[data-page="manage"] .metric {
  flex: 1 0 170px;
  min-height: 54px;
  padding: 8px 10px;
  border: 0;
  border-right: 1px solid #e2e7ee;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-page="manage"] .metric-highlight {
  border-top: 0;
}

body[data-page="manage"] .metric:last-child {
  border-right: 0;
}

body[data-page="manage"] .metric dt {
  margin-bottom: 4px;
  color: #536071;
  font-size: 9px;
  line-height: 1.1;
  text-transform: uppercase;
}

body[data-page="manage"] .metric dd {
  margin-bottom: 5px;
  text-align: left;
  font-size: 17px;
}

.metric-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: #536071;
  font-size: 8.8px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-meta span {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}

.metric-meta b {
  font-size: 10px;
}

body[data-page="manage"] .metric-live {
  background: #fffdf7;
}

.work-panel {
  min-width: 0;
  padding: 14px 16px 16px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: none;
}

.chart-work-panel {
  padding-bottom: 16px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 12px;
}

.signal-panel {
  padding-top: 12px;
}

.live-source-panel {
  background: #fbfcfe;
}

.source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 12px;
  align-items: stretch;
}

.source-grid > div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #ffffff;
}

.source-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.source-path,
.source-copy {
  color: #121417;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.source-path {
  direction: ltr;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #dfe5ec;
  border-radius: 999px;
  background: #f8fafc;
  color: #536071;
  font-size: 12px;
  font-weight: 900;
}

.source-pill.active {
  border-color: #bdd7c3;
  background: #f1faf3;
  color: var(--green);
}

.source-pill.fallback {
  border-color: #e7d5a7;
  background: #fff8e8;
  color: #8a640e;
}

.signal-symbol-cell {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 120px;
}

.remove-live-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 1px solid #efc2bd;
  border-radius: 999px;
  background: #fff3f1;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
}

.remove-live-button:hover {
  border-color: var(--red);
}

.remove-live-button:disabled {
  cursor: progress;
  opacity: .6;
}

.signal-context {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #f8fafc;
  color: #536071;
  font-size: 12px;
  font-weight: 900;
}

.signal-context b {
  color: #121417;
}

body[data-page="manage"] .signal-table {
  min-width: 760px;
}

body[data-page="manage"] .signal-table th,
body[data-page="manage"] .signal-table td {
  padding-top: 9px;
  padding-bottom: 9px;
}

.signal-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #d8dee7;
  border-radius: 5px;
  background: #f8fafc;
  color: #536071;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.signal-pill.buy {
  border-color: #b8dec4;
  background: #eef9f1;
  color: var(--green);
}

.signal-pill.sale,
.signal-pill.sell {
  border-color: #efc2bd;
  background: #fff3f1;
  color: var(--red);
}

.signal-pill.hold {
  border-color: #bad1ef;
  background: #f1f6fd;
  color: var(--blue);
}

.signal-pill.no-trade {
  border-color: #e7d5a7;
  background: #fff8e8;
  color: #8a640e;
}

body[data-page="manage"] .section-head {
  margin-bottom: 14px;
}

body[data-page="manage"] .section-head.compact {
  margin-bottom: 12px;
}

body[data-page="manage"] .section-head h2 {
  color: #102a4c;
  font-size: 16px;
  line-height: 1.15;
}

body[data-page="manage"] .chart-tools {
  align-items: center;
  justify-content: flex-end;
}

body[data-page="manage"] .mode-switch {
  min-height: 36px;
  background: #f6f8fb;
}

body[data-page="manage"] .mode-switch button {
  min-width: 84px;
  padding: 0 10px;
}

body[data-page="manage"] .mode-switch button.active {
  background: #102a4c;
}

body[data-page="manage"] .date-control {
  gap: 5px;
  text-transform: uppercase;
}

body[data-page="manage"] .date-control input {
  min-height: 36px;
}

body[data-page="manage"] .management-legend {
  margin-bottom: 12px;
}

body[data-page="manage"] .chart-shell {
  height: clamp(320px, 34vw, 430px);
  border-radius: 6px;
  box-shadow: none;
}

.board-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 30px) 44px;
}

.board-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.board-hero h1 {
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1;
}

.board-hero-meta,
.board-combined-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.board-hero-meta span,
.board-combined-stats span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.board-hero-meta strong,
.board-combined-stats strong {
  color: var(--ink);
  font-size: 13px;
}

.signal-board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.board-signal-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.board-signal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
}

.board-signal-head h2 {
  font-size: 18px;
  line-height: 1.15;
}

.board-signal-card .as-of {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.board-signal-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
}

.board-signal-table th,
.board-signal-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--soft-line);
  text-align: left;
  font-size: 13px;
}

.board-signal-table th {
  background: #f4f6f9;
  color: #515b68;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.board-combined-panel {
  margin-top: 12px;
}

body[data-page="board"] .public-chart-shell {
  height: 360px;
}

.board-return-panel {
  margin-top: 12px;
}

.board-return-table {
  min-width: 980px;
}

.board-return-table th,
.board-return-table td {
  padding: 8px 10px;
  text-align: right;
  font-size: 12px;
}

.board-return-table th:first-child,
.board-return-table td:first-child {
  text-align: left;
}

body[data-page="manage"] .table-wrap {
  border-color: #e2e7ee;
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
}

body[data-page="manage"] table {
  direction: ltr;
}

body[data-page="manage"] th,
body[data-page="manage"] td {
  padding: 10px 11px;
  text-align: left;
}

body[data-page="manage"] th {
  background: #f5f7fa;
  color: #455163;
}

body[data-page="manage"] .return-table {
  min-width: 920px;
}

body[data-page="manage"] .data-table {
  min-width: 620px;
}

body[data-page="manage"] .panel-grid .data-table {
  min-width: 560px;
}

body[data-page="manage"] .year-cell {
  color: #102a4c;
}

body[data-page="manage"] .status-pill {
  min-width: 66px;
  min-height: 25px;
  padding: 3px 8px;
}

body[data-page="manage"] .year-tabs {
  gap: 6px;
  margin-bottom: 12px;
}

body[data-page="manage"] .year-tab {
  min-height: 32px;
  padding: 6px 10px;
  background: #ffffff;
}

body[data-page="manage"] .year-tab.active {
  background: #102a4c;
  border-color: #102a4c;
}

body[data-page="manage"] .trade-summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #ffffff;
  color: #536071;
}

body[data-page="manage"] .auth-view {
  background: #eef1f5;
}

body[data-page="manage"] .auth-panel {
  border-color: #dfe5ec;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
}

body[data-page="manage"] .auth-panel h1 {
  font-size: 34px;
}

@media (max-width: 1120px) {
  .signal-board-grid {
    grid-template-columns: 1fr;
  }

  .board-signal-card {
    box-shadow: none;
  }

  .board-signal-table {
    min-width: 0;
  }

  .board-signal-table th,
  .board-signal-table td {
    padding: 8px 9px;
  }

  .management-metrics {
    display: flex;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .source-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .board-shell {
    padding: 18px 10px 34px;
  }

  .board-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .board-hero h1 {
    font-size: 32px;
  }

  .board-hero-meta,
  .board-combined-stats {
    justify-content: flex-start;
    width: 100%;
  }

  .board-hero-meta span,
  .board-combined-stats span {
    flex: 1 1 150px;
    justify-content: space-between;
  }

  .signal-board-grid {
    grid-template-columns: 1fr;
  }

  .board-signal-head {
    align-items: flex-start;
    flex-direction: column;
  }

  body[data-page="board"] .public-chart-shell {
    height: 330px;
  }

  body[data-page="manage"] .manage-header {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding: 9px 10px;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  body[data-page="manage"] .ghost-button {
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
  }

  body[data-page="manage"] .ghost-button:first-child {
    display: none;
  }

  .manage-shell {
    padding: 16px 10px 34px;
  }

  .manage-hero,
  body[data-page="manage"] .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .manage-hero {
    gap: 12px;
  }

  .manage-hero h1 {
    font-size: 31px;
  }

  .manage-context {
    justify-content: flex-start;
  }

  .management-metrics {
    display: flex;
  }

  body[data-page="manage"] .metric {
    flex-basis: 162px;
    min-height: 54px;
  }

  .work-panel {
    padding: 14px;
  }

  body[data-page="manage"] .chart-tools {
    align-items: stretch;
    width: 100%;
  }

  body[data-page="manage"] .mode-switch {
    width: 100%;
  }

  body[data-page="manage"] .mode-switch button {
    min-width: 0;
    flex: 1;
  }

  body[data-page="manage"] .date-control {
    width: 100%;
  }

  body[data-page="manage"] .date-control input {
    width: 100%;
  }

  body[data-page="manage"] .management-legend {
    flex-wrap: wrap;
  }

  body[data-page="manage"] .chart-shell {
    height: 330px;
  }
}

@media (max-width: 460px) {
  body[data-page="manage"] .brand span:last-child {
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .manage-context {
    width: 100%;
  }

  .manage-context span {
    width: 100%;
    justify-content: space-between;
  }

  body[data-page="manage"] .chart-shell {
    height: 300px;
  }
}

/* =========================================================
   UNIFIED TOPBAR (Engel Research design system)
   Restyles existing .site-header / .brand / .management-link
   to match the global topbar. No class names changed —
   all JS data-attributes preserved.
   ========================================================= */
.site-header {
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom: 1px solid #e2e8f0 !important;
  min-height: 56px !important;
  padding: 12px 22px !important;
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}

.brand {
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: .14em !important;
  text-transform: uppercase;
  color: #0f172a !important;
}
.brand-mark { display: none !important; }
.brand span { color: inherit; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.management-link {
  min-height: 36px !important;
  padding: 8px 14px !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #64748b !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: .01em;
  box-shadow: none !important;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.management-link:hover {
  background: #f1f4f9 !important;
  border-color: transparent !important;
  color: #0f172a !important;
  box-shadow: none !important;
}
.management-link.active {
  background: #f1f4f9 !important;
  color: #0f172a !important;
}
.management-link.primary {
  background: #fbf6e7 !important;
  border-color: #e3d2a0 !important;
  color: #5a4413 !important;
  font-weight: 700 !important;
}
.management-link.primary:hover {
  background: #f6efd2 !important;
  border-color: #b08a3e !important;
  color: #3f2e08 !important;
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px !important;
  }
  .brand { text-align: center; justify-content: center; }
  .header-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .management-link {
    min-height: 44px !important;
    font-size: 11px !important;
    padding: 6px 4px !important;
    border: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    text-align: center;
    white-space: normal;
    line-height: 1.2;
  }
  .management-link.primary {
    background: #fbf6e7 !important;
    border-color: #e3d2a0 !important;
  }
}
