/* 🌟 จัดการกล่อง Tooltip ของ ApexCharts โดยรวม */
.apexcharts-tooltip {
  background: rgba(255, 255, 255, 0.85) !important;
  border: 1px solid #e3e3e3 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

/* 🌟 จัดการแถบหัวข้อ (ที่บอกอายุ) ด้านบนของ Tooltip */
.apexcharts-tooltip-title {
  background: rgba(248, 249, 250, 0.7) !important;
  border-bottom: 1px solid #e3e3e3 !important;
  font-weight: 600 !important;
}

/* 🌟 จัดการกราฟแท่ง Port CAGR & MDD */
#chart-port-cagr-mdd {
  min-height: 350px;
  display: block;
}

#chart-port-cagr-mdd .apexcharts-datalabel text {
  text-anchor: start !important;
}

/* ดันกลุ่มข้อความทั้งหมดไปทางขวา 10px เพื่อไม่ให้ชิดเส้นแกน 0% จนเกินไป */
#chart-port-cagr-mdd .apexcharts-datalabel {
  transform: translateX(10px);
}

/* ... [Keep your existing ApexCharts Tooltip CSS above this] ... */

/* =========================================
   Typography (same scale as the Result page)
   ========================================= */
.dca-advanced-container {
  --text-main: #09090b;
  --text-body: #3f3f46;
  --text-muted: #71717a;
  --fs-title: 16px;     /* card titles */
  --fs-body: 14px;      /* body text */
  --fs-small: 12px;     /* notes, chart labels */

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Thai", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cards: padding inside the 100% width, so each card fits the
   content area and lines up with the buttons below. */
.dca-advanced-container #yearlyChartWrapper,
.dca-advanced-container .chart-card {
  box-sizing: border-box;
}

.dca-advanced-container .dca-card-title {
  margin: 0 0 4px;
  font-family: inherit;
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-main);
}

/* ApexCharts tooltips are drawn inside the chart, so they follow the page font. */
.dca-advanced-container .apexcharts-tooltip,
.dca-advanced-container .apexcharts-xaxistooltip {
  font-family: inherit !important;
  font-size: var(--fs-small);
}

/* =========================================
   Download-as-JPG icon (top-right of each chart card)
   Scoped under the container so theme button styles don't leak in.
   ========================================= */
.dca-advanced-container .chart-card {
  position: relative;
}

.dca-advanced-container .dca-chart-download {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: #a1a1aa;
  line-height: 0;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dca-advanced-container .dca-chart-download:hover {
  background: #f4f4f5;
  color: #3f3f46;
}

.dca-advanced-container .dca-chart-download:focus-visible {
  outline: 2px solid rgba(0, 143, 251, 0.35);
  outline-offset: 1px;
}

.dca-advanced-container .dca-chart-download:disabled {
  opacity: 0.5;
  cursor: progress;
}

.dca-advanced-container .dca-chart-download svg {
  display: block;
}

.dca-advanced-container .dca-chart-empty {
  text-align: center;
  padding: 30px 10px;
  font-size: var(--fs-body);
  color: var(--text-muted);
}

/* =========================================
   🌟 Shared Button Styles & Layout
   ========================================= */
.dca-nav-actions {
  display: flex;
  gap: 16px;
  margin-top: 30px;
  justify-content: center;
}

.dca-nav-actions .button {
  background: #ffffff;
  border: 1px solid #e4e4e7;
  color: #09090b;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* Same font as the Result page buttons */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  flex: 1;
  max-width: 300px;
}

.dca-nav-actions .button:active {
  transform: translateY(1px);
}

.dca-nav-actions .btn-primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
  color: white !important;
  border: none !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.dca-nav-actions .btn-primary:hover {
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.dca-nav-actions .btn-secondary {
  background: #ffffff !important;
  color: #71717a;
  border: 1px solid #e4e4e7;
}

.dca-nav-actions .btn-secondary:hover {
  background: #f4f4f5 !important;
  color: #09090b;
}

@media (max-width: 600px) {
  .dca-nav-actions {
    flex-direction: column;
    align-items: center;
  }
  .dca-nav-actions .button {
    width: 100%;
    max-width: 100%;
  }
}

/* =========================================
   PXW controls — separate compact strip below Portfolio Value card
   ========================================= */
.pxw-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  width: 100%;
  max-width: 900px;
  box-sizing: border-box;
  margin: -10px auto 20px;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.pxw-controls::-webkit-scrollbar {
  display: none;
}

.pxw-controls-label {
  font-weight: 500;
  color: var(--text-muted);
}

.pxw-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  cursor: pointer;
}

.pxw-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.pxw-toggle-track {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: #d4d4d8;
  transition: background-color 0.15s ease;
}

.pxw-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}

.pxw-toggle input:checked + .pxw-toggle-track {
  background: #008ffb;
}

.pxw-toggle input:checked + .pxw-toggle-track::after {
  transform: translateX(12px);
}

.pxw-toggle input:focus-visible + .pxw-toggle-track {
  outline: 2px solid rgba(0, 143, 251, 0.25);
  outline-offset: 2px;
}

.pxw-weight-field {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Weight dropdowns, 1 to 9. Own look (no browser/theme select style): a
   small box with the number and a grey chevron on the right. */
.dca-advanced-container .pxw-weight-field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 36px !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 22px !important;
  min-height: 0 !important;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 14px 0 7px !important;
  border: 1px solid #d4d4d8 !important;
  border-radius: 4px !important;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%2371717a'/%3E%3C/svg%3E") no-repeat right 5px center / 8px 5px !important;
  box-shadow: none !important;
  color: var(--text-main);
  font: inherit;
  font-weight: 500;
  line-height: 20px !important;
  text-align: left;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.dca-advanced-container .pxw-weight-field select:focus {
  outline: none;
  border-color: #a1a1aa !important;
  box-shadow: none !important;
}

.pxw-controls.is-off .pxw-controls-label,
.pxw-controls.is-off .pxw-weight-field,
.pxw-controls.is-off .pxw-footnote {
  opacity: 0.45;
}

.dca-advanced-container .pxw-controls.is-off .pxw-weight-field select {
  background-color: #f4f4f5 !important;
  cursor: not-allowed;
}

.pxw-footnote {
  flex: 0 0 auto;
  margin-left: 4px;
  color: var(--text-muted);
  font: inherit;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .pxw-controls {
    justify-content: flex-start;
    gap: 4px;
    margin-top: -10px;
    padding: 0 20px;
    font-size: 10px;
  }

  .pxw-toggle-track {
    width: 24px;
    height: 14px;
  }

  .pxw-toggle input:checked + .pxw-toggle-track::after {
    transform: translateX(10px);
  }

  .pxw-weight-field {
    gap: 2px;
  }

  .dca-advanced-container .pxw-weight-field select {
    width: 32px !important;
    height: 20px !important;
    padding: 0 12px 0 6px !important;
    line-height: 18px !important;
    background-position: right 4px center !important;
  }

  .pxw-footnote {
    margin-left: 2px;
  }
}

/* =======================================================
   🌟 FULLSCREEN LOADING OVERLAY & SPINNER
   ======================================================= */
#dca-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75); 
    backdrop-filter: blur(6px);            
    -webkit-backdrop-filter: blur(6px);
    z-index: 999999;                       
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.dca-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2); 
    border-radius: 50%;
    border-top-color: #ffffff;                  
    animation: dca-spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite; 
    margin-bottom: 20px;
}

.dca-loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    animation: dca-pulse 1.5s ease-in-out infinite; 
}

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

@keyframes dca-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
/* =========================================
   Stable plot-relative presentation layers
   ========================================= */

/*
 * Reserve each chart's height (same as its Apex `chart.height`) so the
 * cards have their final size before ApexCharts loads and draws.
 */
#yearlyChart {
  min-height: 340px;
}

/* Keep the three auxiliary charts visually equal in height. */
#chart-survival-curve,
#chart-mwrr-adm-mdd,
#chart-sharpe-sortino {
  min-height: 300px;
}

/*
 * Apex owns the chart. CSS owns the non-data presentation layer.
 * After every Apex draw (mounted/updated), JS copies Apex's own plot
 * rectangle (w.globals translateX/Y, gridWidth/Height) into:
 * --plot-left, --plot-top, --plot-width, --plot-height, --watermark-size.
 */
.dca-chart-stage {
  position: relative;
  min-width: 0;
  isolation: isolate;
  --plot-left: 0px;
  --plot-top: 0px;
  --plot-width: 0px;
  --plot-height: 0px;
  --watermark-size: 32px;
}

.dca-chart-stage > #yearlyChart,
.dca-chart-stage > #chart-survival-curve,
.dca-chart-stage > #chart-sharpe-sortino {
  position: relative;
  z-index: 1;
}

/* Keep Apex backgrounds transparent so the watermark truly sits behind it. */
.dca-chart-stage .apexcharts-canvas,
.dca-chart-stage .apexcharts-svg {
  background: transparent !important;
}

/* Centre of the plot rectangle, centred on its own box. */
.dca-chart-watermark {
  position: absolute;
  z-index: 0;
  left: calc(var(--plot-left) + (var(--plot-width) / 2));
  top: calc(var(--plot-top) + (var(--plot-height) / 2));
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  color: rgba(15, 23, 42, 0.045);
  font-family: inherit;
  font-size: var(--watermark-size);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  opacity: 0;
}

.dca-chart-stage.is-plot-positioned .dca-chart-watermark {
  opacity: 1;
}

.portfolio-callout-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  font-family: inherit;
  color: #0f172a;
}

.dca-chart-stage.is-plot-positioned .portfolio-callout-layer {
  opacity: 1;
}

/*
 * Both callouts share one top and the same row structure
 * (value -> caption), so "$3.2M" / "79.8%" and their captions
 * always sit on the same y lines.
 */
.portfolio-callout {
  position: absolute;
  top: calc(var(--plot-top) + 2px);
  white-space: nowrap;
}

/*
 * x positions use plain px offsets from the plot edges, in the same
 * calc() form as the watermark rule (no variables built from calc).
 * Age Buy tag ends ~17px inside the plot's left edge  -> 17 + 10 gap = 27px.
 * Age Stop tag sits outside the plot, so the right block only keeps
 * a small 8px margin from the plot's right edge.
 */
.portfolio-callout-left {
  left: calc(var(--plot-left) + 27px);
  text-align: left;
}

/*
 * The block's right edge stays 8px inside the plot; inside it,
 * "Success rate" starts at the left edge of the "…%" above it.
 */
.portfolio-callout-right {
  left: calc(var(--plot-left) + var(--plot-width) - 8px);
  transform: translateX(-100%);
  text-align: left;
}

/*
 * One rule for all three big values: "$…M", "…X" and "…%".
 * !important on size/weight so no theme rule can make one differ.
 * line-height 0.82 makes the line box hug the digits/capitals
 * (numbers have no descenders), so the caption sits right under them.
 */
.dca-advanced-container .portfolio-callout-primary {
  margin: 0;
  font-size: 30px !important;
  font-weight: 700 !important;
  line-height: 0.82;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.portfolio-retire-value {
  color: #16a34a;
}

/*
 * Caption sits visually midway between "$3.2M" and "6X"
 * (spacing tuned by eye). "Success rate" uses the same rule,
 * so it lines up with "At retirement age ..." exactly.
 */
.portfolio-callout-caption {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  color: #0f172a;
}

/* 4px more than the caption's gap to the value above, so the space from
   the caption to "…X" looks the same as from "…M" to the caption (the
   caption's descenders and the capitals' height make it look smaller). */
.portfolio-retire-multiple {
  margin-top: 14px;
}

@media (max-width: 600px) {
  .portfolio-callout {
    top: calc(var(--plot-top) + 1px);
  }

  .portfolio-callout-left {
    left: calc(var(--plot-left) + 25px);
  }

  .portfolio-callout-right {
    left: calc(var(--plot-left) + var(--plot-width) - 6px);
  }

  .dca-advanced-container .portfolio-callout-primary {
    font-size: 22px !important;
  }

  .portfolio-callout-caption {
    margin-top: 2px;
    font-size: 10px;
  }

  .portfolio-retire-multiple {
    margin-top: 11px;
  }
}

/* =========================================
   Sections: Risk, Diversity
   Same card, title and chart rules as the charts above; the table copies
   the Result page's collapsible "Assets Allocation" table, scoped here so
   it does not depend on the Result page's stylesheet.
   ========================================= */
/* Section headings ("Risk", "Diversity"): same spacing and title style. */
.dca-advanced-container .dca-result-section {
  margin-top: 36px;
}

.dca-advanced-container .dca-section-title {
  max-width: 900px;
  margin: 0 auto 4px;
  padding: 0 4px;
  font-family: inherit;
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Subtitle line under a card title (also drawn into the JPG export). */
.dca-advanced-container .dca-chart-note {
  margin: 0 0 4px;
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--text-muted);
}

/* Reserve the chart heights before ApexCharts draws (same as above). */
#chart-growth-by-age {
  min-height: 300px;
}

.dca-advanced-container .dca-pie-chart {
  min-height: 300px;
}

.dca-chart-stage > #chart-growth-by-age,
.dca-chart-stage > .dca-pie-chart {
  position: relative;
  z-index: 1;
}

/* Exchanges + Instruments: one card (one download), two pies side by side;
   one per row on phones. */
.dca-advanced-container .dca-pie-pair-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  padding: 12px 20px 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.dca-advanced-container .dca-pie-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.dca-advanced-container .dca-pie-cell {
  min-width: 0;
}

.dca-advanced-container .dca-diversity-table-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.dca-advanced-container .dca-collapsible-card.dca-diversity-table-card {
  padding: 4px 20px !important;
  margin-top: 0;
  margin-bottom: 0;
}

/* No theme spacing on the header row itself. */
.dca-advanced-container .dca-diversity-table-card > summary {
  margin: 0;
  padding: 0;
}

.dca-advanced-container .dca-collapsible-card.dca-diversity-table-card[open] {
  padding-bottom: 16px !important;
}

.dca-advanced-container .dca-diversity-table-card + .dca-diversity-table-card {
  margin-top: 0;
}

/* The first of the three tables follows the pie note directly. */
.dca-advanced-container .dca-diversity-note + .dca-diversity-table-card {
  margin-top: 0;
}

.dca-advanced-container .dca-diversity-note {
  max-width: 900px;
  margin: -8px auto 20px;
  padding: 0 4px;
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .dca-advanced-container .dca-pie-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Collapsible table (as on the Result page) ---------- */
.dca-advanced-container .dca-collapsible-card {
  transition: all 0.2s ease-in-out;
  padding: 16px 20px !important;
}

.dca-advanced-container .dca-collapsible-card[open] {
  padding-bottom: 20px !important;
}

.dca-advanced-container .dca-collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-body); /* light black, #3f3f46 */
  cursor: pointer;
  list-style: none;
  user-select: none;
  outline: none;
}

.dca-advanced-container .dca-collapsible-header::-webkit-details-marker {
  display: none;
}

.dca-advanced-container .dca-toggle-icon {
  font-size: var(--fs-small);
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.dca-advanced-container .dca-collapsible-card[open] .dca-toggle-icon {
  transform: rotate(180deg);
  color: #2196F3;
}

.dca-advanced-container .dca-card-subtitle {
  font-size: var(--fs-body);
  font-weight: 400;
  color: var(--text-muted);
}

.dca-advanced-container .table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dca-advanced-container .dca-comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
  color: var(--text-body);
  background: #fff;
}

.dca-advanced-container .dca-comparison-table thead tr {
  border-bottom: 2px solid #eaeaea;
  background-color: #fcfcfc;
}

.dca-advanced-container .dca-comparison-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.dca-advanced-container .dca-comparison-table th.num-header {
  text-align: right;
}

.dca-advanced-container .dca-comparison-table tbody tr {
  border-bottom: 1px solid #f2f2f2;
  transition: background-color 0.2s ease;
}

.dca-advanced-container .dca-comparison-table tbody tr:hover {
  background-color: #f9fbfd;
}

.dca-advanced-container .dca-comparison-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.dca-advanced-container .dca-comparison-table td.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.dca-advanced-container .dca-comparison-table strong {
  font-weight: 600;
  color: var(--text-main);
}

/* Share on the second line of a cell, as in "Assets Allocation". */
.dca-advanced-container .dca-cell-sub {
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--text-muted);
}

/* Values in the main text colour, as in Withdrawal Details. */
.dca-advanced-container .growth-age-table td.num-cell {
  color: var(--text-main);
}

/* Table footnotes: one per line (assets list first). */
.dca-advanced-container .withdraw-details-note > div + div {
  margin-top: 2px;
}

.dca-advanced-container .withdraw-details-note {
  margin-top: 7px;
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .dca-advanced-container .dca-comparison-table {
    font-size: 13px;
  }

  .dca-advanced-container .dca-comparison-table th,
  .dca-advanced-container .dca-comparison-table td {
    padding: 8px 6px;
  }
}

/* =========================================
   Assets' info switch (first in the strip under Portfolio Value)
   ========================================= */
.assets-info-label {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 10px;
}

.pxw-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.pxw-group[hidden] {
  display: none;
}

/* =========================================
   Assets' info overlay — under the retirement "…X", towards the x-axis.
   Fixed 11px (does not scale with the chart): 10 assets + "+ N more".
   A white halo keeps it readable over the lines; it never takes clicks,
   so the chart tooltip still works underneath.
   ========================================= */
.portfolio-assets-info {
  display: grid;
  grid-template-columns: auto auto auto auto;
  column-gap: 10px;
  /* Pulled left from the callout (27px in) to a small gap from the y-axis.
     It starts below "…X", so it clears the Age Buy tag above it. */
  margin-top: 10px;
  margin-left: -21px;
  font-size: 11px !important;
  font-weight: 400;
  line-height: 13px;
  color: #3f3f46;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff;
  pointer-events: none;
}

.portfolio-assets-info[hidden] {
  display: none;
}

.portfolio-assets-info-cell.is-num {
  text-align: right;
}

.portfolio-assets-info-cell.is-head {
  font-weight: 600;
  color: #71717a;
}

.portfolio-assets-info-cell.is-more {
  grid-column: 1 / -1;
  color: #71717a;
}

@media (max-width: 600px) {
  .assets-info-label {
    margin-right: 6px;
  }

  .pxw-group {
    gap: 4px;
  }

  .portfolio-assets-info {
    margin-top: 8px;
    margin-left: -19px;
    column-gap: 8px;
  }
}

/* =========================================
   Plan footer (Assets' info on), two lines, right-aligned to the plot:
   "Inflation …% · S.T. …%" on the row of the "Age" x-axis title and the
   legend, "Withdraw …/m at age …" one line above it. Both fit inside the
   chart, so Assets' info never makes this chart taller than the others.
   --plan-footer-top is set by placePlanFooter(). Fixed 11px, never shrunk.
   ========================================= */
.portfolio-plan-footer {
  position: absolute;
  left: calc(var(--plot-left) + var(--plot-width));
  top: var(--plan-footer-top, 0px);
  /* Line 2 centred on the "Age" row: up one 13px line plus half a line,
     +2px to sit level with the SVG title by eye. Line 1 is just above. */
  transform: translate(-100%, calc(-13px - 6.5px + 2px));
  text-align: right;
  /* Exactly the Assets' info headers (Asset, Invest/m, Div., T.W.). */
  font-family: inherit;
  font-size: 11px !important;
  font-weight: 600;
  line-height: 13px;
  color: #71717a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  /* Same white halo as Assets' info, should line 1 meet an age number. */
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff;
  pointer-events: none;
}

.portfolio-plan-footer[hidden] {
  display: none;
}

/* =========================================
   Phones and small screens: the page uses the full screen width (past the
   theme's side padding), cards 8px from the edges, slimmer card padding so
   the charts get more room. --dca-vw is the page width without a
   scrollbar (set by the script; 100vw until then). The margins are
   !important because block themes centre content with "margin: auto
   !important"; card padding is !important to beat the inline style.
   ========================================= */
@media (max-width: 600px) {
  html body .dca-advanced-container {
    box-sizing: border-box;
    width: auto;
    max-width: none !important;
    margin-left: calc(50% - var(--dca-vw, 100vw) / 2) !important;
    margin-right: calc(50% - var(--dca-vw, 100vw) / 2) !important;
    padding-left: 8px;
    padding-right: 8px;
  }

  .dca-advanced-container #yearlyChartWrapper,
  .dca-advanced-container .chart-card {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .dca-advanced-container .dca-collapsible-card.dca-diversity-table-card {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .dca-advanced-container .pxw-controls {
    padding: 0 12px;
  }

  /* Downloads keep the desktop card padding (see below). */
  .dca-advanced-container #yearlyChartWrapper.dca-exporting,
  .dca-advanced-container .chart-card.dca-exporting {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

/* =========================================
   Image download (JS: layoutCardForExport)
   Downloads always use the desktop layout: the card is laid out off-screen
   at its desktop width (as on a full-screen desktop) with .dca-exporting,
   so on phones the phone rules above are undone inside it (same values
   as the desktop rules).
   ========================================= */
@media (max-width: 600px) {
  .dca-exporting .portfolio-callout {
    top: calc(var(--plot-top) + 2px);
  }

  .dca-exporting .portfolio-callout-left {
    left: calc(var(--plot-left) + 27px);
  }

  .dca-exporting .portfolio-callout-right {
    left: calc(var(--plot-left) + var(--plot-width) - 8px);
  }

  .dca-advanced-container .dca-exporting .portfolio-callout-primary {
    font-size: 30px !important;
  }

  .dca-exporting .portfolio-callout-caption {
    margin-top: 4px;
    font-size: 12px;
  }

  .dca-exporting .portfolio-retire-multiple {
    margin-top: 14px;
  }

  .dca-exporting .portfolio-assets-info {
    margin-top: 10px;
    margin-left: -21px;
    column-gap: 10px;
  }

  .dca-advanced-container .dca-exporting .dca-pie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
