:root {
  --portfolio-bg: #071221;
  --portfolio-panel: #0d1c30;
  --portfolio-line: #253b55;
  --portfolio-text: #f4f8ff;
  --portfolio-muted: #91a8c4;
  --portfolio-blue: #55a7ff;
  --portfolio-mint: #42d9ae;
  --portfolio-rose: #d76f8d;
  --portfolio-amber: #f3ba5b;
}

.portfolio-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 64px;
  color: var(--portfolio-text);
}

.sample-data-banner {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid #a57425;
  border-radius: 8px;
  background: #2d210d;
  color: #ffd98c;
  font-weight: 700;
  text-align: center;
}

.portfolio-topbar,
.portfolio-header-actions,
.portfolio-intro,
.portfolio-chart-head,
.portfolio-chart-controls,
.breakdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.portfolio-topbar {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--portfolio-line);
}

.portfolio-brand {
  margin: 4px 0 0;
  font-size: 1.15rem;
  font-weight: 760;
}

.global-page-nav a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--portfolio-muted);
  text-decoration: none;
}

.global-page-nav a[aria-current="page"] {
  border-color: #458ecf;
  background: #102b49;
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--portfolio-blue);
}

.portfolio-message {
  margin: 48px auto;
  max-width: 760px;
  padding: 32px;
  border: 1px solid var(--portfolio-line);
  border-radius: 14px;
  background: var(--portfolio-panel);
  text-align: center;
}

.portfolio-error {
  border-color: #8e4055;
}

/* ヒーローセクション: 1180px以上で2列一体型 */
.portfolio-hero {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
  padding: 28px 0;
  border-bottom: 1px solid var(--portfolio-line);
}

.portfolio-summary-col {
  width: 360px;
  min-width: 320px;
  max-width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portfolio-chart-col {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portfolio-intro h1 {
  margin: 4px 0 0;
  font-size: clamp(1.4rem, 2.2vw, 2.1rem);
  font-weight: 700;
}

.coverage-status {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--portfolio-muted);
}

.coverage-status[data-state="incomplete"] {
  color: var(--portfolio-amber);
}

.portfolio-intro-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.compact-refresh-button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portfolio-hero-kpi {
  min-width: 0;
}

.portfolio-hero-kpi .kpi-label {
  color: var(--portfolio-muted);
  font-size: 0.86rem;
}

.portfolio-hero-kpi strong.hero-number,
.portfolio-kpi strong {
  display: block;
  min-width: 0;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(2.2rem, 3.2vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: #f4f8ff;
  overflow-wrap: anywhere;
}

.portfolio-hero-kpi p.growth-since-start,
.portfolio-kpi p {
  margin: 8px 0 0;
  color: var(--portfolio-mint);
  font-size: clamp(0.98rem, 1.4vw, 1.25rem);
  font-weight: 700;
}

.portfolio-hero-kpi .latest-change,
.portfolio-kpi .latest-change {
  margin-top: 4px;
  color: var(--portfolio-muted);
  font-size: 0.84rem;
  font-weight: 400;
}

.portfolio-compact-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--portfolio-line);
  border-radius: 8px;
  background: rgba(13, 28, 48, 0.6);
}

.uplift-card {
  padding: 15px 16px;
  border: 1px solid rgba(66, 217, 174, 0.55);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(20, 93, 74, 0.3), rgba(7, 30, 31, 0.75));
}

.uplift-card > span,
.uplift-comparison span {
  color: #9acdbf;
  font-size: 0.78rem;
}

.uplift-card > strong {
  display: block;
  margin-top: 4px;
  color: var(--portfolio-mint);
  font: 760 clamp(1.65rem, 2.5vw, 2.25rem)/1.15 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.uplift-card > p {
  margin: 5px 0 12px;
  color: #c9f5e8;
  font-size: 0.86rem;
  font-weight: 700;
}

.uplift-comparison {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(66, 217, 174, 0.22);
}

.uplift-comparison b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

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

.fact-item span {
  font-size: 0.74rem;
  color: var(--portfolio-muted);
}

.fact-item strong {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.portfolio-capital-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #1c324c;
  border-radius: 8px;
  background: #0b1a2d;
}

.breakdown-item {
  min-width: 0;
}

.breakdown-item span {
  display: block;
  font-size: 0.76rem;
  color: var(--portfolio-muted);
}

.breakdown-item strong {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.growth-support div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--portfolio-line);
  border-radius: 6px;
  background: rgba(7, 18, 33, 0.4);
}

.growth-support dt {
  color: var(--portfolio-muted);
  font-size: 0.74rem;
}

.growth-support dd {
  min-width: 0;
  margin: 3px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.portfolio-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-top: 16px;
  border-block: 1px solid var(--portfolio-line);
}

.portfolio-facts div {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--portfolio-line);
}

.portfolio-facts div:last-child {
  border-right: 0;
}

.portfolio-facts span,
.portfolio-facts strong {
  display: block;
}

.portfolio-facts span {
  color: var(--portfolio-muted);
  font-size: .78rem;
}

.portfolio-facts strong {
  min-width: 0;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.portfolio-definition,
.chart-truth-note {
  color: var(--portfolio-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0;
}

/* 1観測点用 原点カード */
.portfolio-origin-card {
  min-height: 140px;
  padding: 20px 24px;
  border: 1px solid #1a304a;
  border-radius: 12px;
  background: #091628;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.origin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.origin-tag {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid rgba(85, 167, 255, 0.28);
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #55a7ff;
  background: rgba(85, 167, 255, 0.12);
}

.origin-date {
  font-size: 0.82rem;
  color: var(--portfolio-muted);
}

.origin-card-body {
  margin: 4px 0;
}

.origin-label {
  display: block;
  font-size: 0.82rem;
  color: var(--portfolio-muted);
}

.origin-value {
  display: block;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: #f4f8ff;
}

.origin-notice {
  margin: 0;
  font-size: 0.84rem;
  color: var(--portfolio-muted);
}

/* チャートセクション */
.portfolio-main-chart-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.portfolio-chart-section,
.portfolio-secondary,
.portfolio-breakdown {
  padding: 28px 0;
  border-bottom: 1px solid var(--portfolio-line);
}

.portfolio-chart-head h2,
.portfolio-secondary h2,
.breakdown-head h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.portfolio-chart-head p,
.portfolio-secondary p,
.breakdown-head p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--portfolio-muted);
}

.portfolio-chart-controls {
  margin: 8px 0 4px;
}

.compact-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-toggle button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #324a66;
  border-radius: 7px;
  background: #0b192a;
  color: #a9bdd5;
  font-size: 0.84rem;
  cursor: pointer;
}

.compact-toggle button[aria-pressed="true"] {
  border-color: var(--portfolio-blue);
  background: #12365b;
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--portfolio-blue);
}

.compact-toggle button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #20344c;
  background: #071221;
}

.portfolio-chart-wrap {
  position: relative;
  height: 420px;
  min-height: 380px;
  border: 1px solid var(--portfolio-line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(25, 53, 84, .22), transparent);
  overflow: hidden;
}

.portfolio-chart-wrap canvas,
.portfolio-debt-chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.portfolio-chart-wrap canvas:focus-visible {
  outline: 2px solid var(--portfolio-blue);
  outline-offset: -2px;
}

.portfolio-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 10px;
  color: var(--portfolio-muted);
  font-size: .82rem;
}

.portfolio-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-line {
  width: 26px;
  height: 3px;
  background: var(--portfolio-blue);
  border-radius: 1px;
}

.legend-line.capital {
  height: 0;
  border-top: 2px dashed #a6b4c8;
  background: transparent;
}

.legend-line.qqq {
  height: 0;
  border-top: 2px dotted var(--portfolio-amber);
  background: transparent;
}

.legend-line.debt { background: var(--portfolio-blue); }
.legend-line.ltv {
  height: 0;
  border-top: 2px dashed var(--portfolio-amber);
  background: transparent;
}

.legend-band {
  width: 26px;
  height: 10px;
  background: rgba(66, 217, 174, .20);
  border-radius: 2px;
}

.legend-band.negative {
  background: rgba(215, 111, 141, .20);
}

.legend-account {
  width: 16px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 3px;
}

.portfolio-tooltip {
  display: block;
  min-height: 38px;
  margin-top: 10px;
  color: #c6d9ee;
  font-size: 0.86rem;
}

.comparison-picker {
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) auto minmax(260px, 2fr);
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.comparison-picker label {
  color: var(--portfolio-muted);
  font-size: .84rem;
}

.comparison-picker select {
  min-height: 36px;
}

.comparison-picker output {
  color: #c6d9ee;
  font-size: 0.86rem;
}

/* QQQ参考キャプション */
.qqq-reference-caption {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 3px solid var(--portfolio-amber);
  background: rgba(243, 186, 91, .07);
  border-radius: 0 6px 6px 0;
}

.qqq-reference-caption p {
  margin: 0 0 4px;
  font-size: 0.84rem;
}

.qqq-reference-caption p:last-child {
  margin-bottom: 0;
}

.comparison-boundary {
  color: var(--portfolio-amber);
}

.portfolio-table-details,
.portfolio-risk {
  margin-top: 16px;
  border: 1px solid var(--portfolio-line);
  border-radius: 10px;
  background: rgba(13, 28, 48, .65);
}

.portfolio-table-details summary,
.portfolio-risk summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 700;
}

/* 借入残高・LTV推移サブレーン */
.debt-sublane {
  margin-top: 16px;
  border: 1px solid var(--portfolio-line);
  border-radius: 10px;
  background: rgba(9, 22, 40, 0.6);
}

.debt-sublane summary {
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  font-size: 0.92rem;
}

.debt-sublane summary small {
  color: var(--portfolio-muted);
  font-weight: 400;
}

.sublane-content {
  padding: 0 18px 18px;
}

.portfolio-debt-chart-wrap {
  height: 320px;
  margin-top: 10px;
  border: 1px solid var(--portfolio-line);
  border-radius: 6px;
  overflow: hidden;
}

.debt-chart-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 12px;
}

.legend-area {
  display: inline-block;
  width: 24px;
  height: 10px;
  margin-right: 7px;
  border-radius: 2px;
  vertical-align: middle;
}

.legend-area.drawdown {
  background: rgba(215, 111, 141, .3);
  border-bottom: 2px solid #d76f8d;
}

.legend-area.rebound {
  background: linear-gradient(90deg, rgba(240, 121, 147, .35) 0 48%, rgba(66, 217, 174, .35) 52% 100%);
  border-bottom: 2px solid #42d9ae;
}

@media (max-width: 620px) {
  .portfolio-debt-chart-wrap {
    height: 280px;
  }

  .debt-chart-legend {
    grid-template-columns: 1fr;
  }
}

.table-scroll {
  overflow-x: auto;
  padding: 0 18px 18px;
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll th,
.table-scroll td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--portfolio-line);
  text-align: right;
  white-space: nowrap;
}

.table-scroll th:first-child,
.table-scroll td:first-child,
.table-scroll th:last-child,
.table-scroll td:last-child {
  text-align: left;
}

.breakdown-bars {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(200px, 4fr) auto;
  align-items: center;
  gap: 16px;
}

.breakdown-row-name strong,
.breakdown-row-name small {
  display: block;
  overflow-wrap: anywhere;
}

.breakdown-row-name {
  min-width: 0;
}

.breakdown-row-name small {
  color: var(--portfolio-muted);
}

.breakdown-track {
  height: 12px;
  border-radius: 999px;
  background: #13263d;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--portfolio-blue);
}

.breakdown-value {
  min-width: 140px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.portfolio-risk {
  margin-bottom: 40px;
}

.portfolio-risk > summary {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.portfolio-risk > summary > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 0 20px 22px;
}

.risk-grid > * {
  min-width: 0;
}

.risk-grid h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.risk-grid p,
.plain-list {
  color: var(--portfolio-muted);
  font-size: .84rem;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--portfolio-line);
}

.risk-facts {
  margin: 0;
}

.risk-facts div,
.stress-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--portfolio-line);
}

.risk-facts dt,
.risk-facts dd,
.stress-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.risk-facts dt {
  color: var(--portfolio-muted);
}

.risk-facts dd {
  margin: 0;
  text-align: right;
}

/* Responsive breakpoint rules (pure CSS) */
@media (max-width: 1179px) {
  .portfolio-hero {
    flex-direction: column;
    gap: 24px;
  }

  .portfolio-summary-col {
    width: 100%;
    max-width: 100%;
  }

  .portfolio-chart-col {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .portfolio-shell {
    width: min(100% - 24px, 1440px);
    padding-top: 16px;
  }

  .portfolio-intro,
  .portfolio-chart-head,
  .breakdown-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .coverage-status {
    text-align: left;
  }

  .portfolio-hero-kpi strong.hero-number,
  .portfolio-kpi strong {
    font-size: clamp(2.1rem, 9vw, 3.2rem);
  }

  .portfolio-chart-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .comparison-picker {
    grid-template-columns: 1fr;
  }

  .portfolio-chart-wrap {
    height: 340px;
    min-height: 320px;
  }

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

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

  .breakdown-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .breakdown-value {
    min-width: 0;
  }
}

@media (max-width: 767px) {
  .portfolio-shell {
    padding-top: 12px;
  }

  .portfolio-topbar {
    min-height: 44px;
    padding-bottom: 8px;
    flex-direction: row;
    align-items: center;
  }

  .portfolio-brand-group {
    display: none;
  }

  .portfolio-header-actions {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .global-page-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 0;
  }

  .global-page-nav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .logout-button {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .portfolio-hero {
    padding: 12px 0;
    gap: 12px;
  }

  .portfolio-summary-col {
    gap: 10px;
  }

  .portfolio-compact-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .fact-item span {
    font-size: 0.7rem;
  }

  .fact-item strong {
    font-size: 0.85rem;
  }

  .portfolio-capital-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 10px;
  }

  .breakdown-item span {
    font-size: 0.72rem;
  }

  .breakdown-item strong {
    font-size: 0.92rem;
  }

  .growth-support {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .portfolio-hero-kpi strong.hero-number,
  .portfolio-kpi strong {
    font-size: clamp(1.8rem, 8vw, 2.3rem);
  }

  .portfolio-risk > summary,
  .risk-facts div,
  .stress-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .risk-facts dd {
    text-align: left;
  }
}
