/* =========================================
   Gauge (Success Rate)
   ========================================= */
.gauge-wrapper {
  width: 200px;
  position: relative;
  margin: 20px auto;
}

.gauge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.gauge-label {
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gauge-percent {
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.success-rate-description {
  margin: -15px auto 12px auto;   /* 12px below the ring (was 22px) */
  text-align: center;
  font-size: var(--fs-body);
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-muted);
}

/* =========================================
   Assets' info (JS: setupAssetsInfoSwitches)
   Same look as on Portfolio Value by Age (Advanced Result page): fixed
   11px, 13px lines. Desktop and downloads: beside the ring / the Total
   Deposit circle, so the card is not made taller (dcasimShrinkToFit makes
   the text smaller if a side is too narrow). Phones: below the ring / the
   circle (see the phone rules).
   ========================================= */
.dca-result-container .dca-assets-info {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 10px;
  font-weight: 400;
  color: #3f3f46;
  text-align: left;
}

.dca-result-container .dca-assets-info-cell.is-num {
  text-align: right;
}

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

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

/* Exactly the table headers (as the plan footer on Portfolio Value). */
.dca-result-container .dca-plan-lines {
  font-weight: 600;
  color: #71717a;
  text-align: left;
}

/* Success Rate and Value at Retirement: the table and the lines together on
   the left of the ring / the Total Deposit circle, centred on it, aligned
   left at the card's inner left edge (left / top set by fitGaugeSideInfo
   and fitValueSideInfo). */
.dca-result-container .gauge-side-info,
.dca-result-container .value-assets-info {
  position: absolute;
  top: 50%;
  z-index: 1;
  font-family: inherit;
  font-size: 11px;
  line-height: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateY(-50%);
}

.dca-result-container .gauge-side-info {
  right: calc(100% + 18px);   /* DCASIM_GAUGE_SIDE_GAP, until placed */
  text-align: left;
}

#value-card .circle-wrapper {
  position: relative;
}

.dca-result-container .value-assets-info {
  right: calc(50% + 18px);
  text-align: left;
}

.dca-result-container .gauge-side-info .dca-plan-lines,
.dca-result-container .value-assets-info .dca-plan-lines {
  margin-top: 8px;
}

.dca-result-container .gauge-side-info .dca-assets-info[hidden] + .dca-plan-lines,
.dca-result-container .value-assets-info .dca-assets-info[hidden] + .dca-plan-lines {
  margin-top: 0;
}

/* Switches below the Success Rate and Value cards (as the strip under
   Portfolio Value), with the cards' usual gap after them. */
.dca-result-container .dca-card-switches {
  grid-column: span 2;
  display: flex;
  align-items: center;
  gap: 5px;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 0 20px;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1;
  white-space: nowrap;
}

.dca-result-container .summary-grid > .dca-card-switches + * {
  margin-top: 15px;
}

.dca-result-container .dca-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
  cursor: pointer;
}

.dca-result-container .dca-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

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

.dca-result-container .dca-switch-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;
}

.dca-result-container .dca-switch input:checked + .dca-switch-track {
  background: #008ffb;
}

.dca-result-container .dca-switch input:checked + .dca-switch-track::after {
  transform: translateX(12px);
}

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

.dca-result-container .dca-switch-label {
  font-weight: 500;
  color: var(--text-muted);
}

/* =========================================
   Timeline Card (กราฟแท่งแนวนอน)
   ========================================= */
.timeline-card {
  grid-column: span 2;
}

.timeline-region {
  position: relative;
  margin: 22px 0;
  /* room for the Hold / Retire labels */
  flex-grow: 1;
  background-color: #e9ecef;
  /* กรอบสีเทาอ่อน */
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* ระยะห่างระหว่างเส้นบน-ล่าง */
}

.timeline-bar-bg {
  width: 100%;
  height: 24px;
  /* ขยายความสูงเป็น 24px เพื่อให้ใส่ตัวหนังสือได้ */
  border-radius: 12px;
}

.timeline-fill-all,
.timeline-fill-all-avg,
.timeline-fill-failed {
  height: 100%;
  border-radius: 12px;
  width: 0%;
  transition: width 5.0s ease-out;

  /* จัดระเบียบตัวหนังสือให้อยู่ข้างใน */
  display: flex;
  justify-content: space-between;
  /* ดันข้อความไปซ้ายสุดและขวาสุด */
  align-items: center;
  color: white;
  /* สีข้อความขาวตัดกับพื้นสีเข้ม */
  font-size: var(--fs-small);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  overflow: hidden;
  /* ซ่อนข้อความตอนที่หลอดยังวิ่งไม่ถึง */
  white-space: nowrap;
}

.timeline-fill-all-avg {
  background-color: #889786;
  /* สีเขียวอมเทา */
}

.timeline-fill-all {
  background-color: #2196F3;
  /* สีฟ้า */
}

.timeline-fill-failed {
  background-color: #f44336;
  /* สีแดง */
}

/* Hold / Retire phase markers */
.timeline-markers {
  position: absolute;
  inset: 6px;
  /* same as .timeline-region padding, so 0-100% matches the bars */
  pointer-events: none;
  z-index: 2;
}

.timeline-marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 0;
  border-left: 1px dashed rgba(9, 9, 11, 0.55);
}

.timeline-marker-label {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* Retire label above the bars, Hold label below (same as the age bar on
   the form), so they never collide when the ages are close or equal. */
.timeline-marker-retire .timeline-marker-label {
  bottom: 100%;
  margin-bottom: 5px;
}

.timeline-marker-hold .timeline-marker-label {
  top: 100%;
  margin-top: 5px;
}

/* =========================================
   Stress Test Intensity (below the Timeline)
   Full card width, as the Retirement Withdrawals bar, so it does not read
   as a fourth Timeline bar. A gradient centred on S.T.%: centre colour
   at S.T.%, "near" at +/- near, "outer" from +/- (near + outer) to the
   ends; near = 15% of S.T.% (5-15%), outer = 20% of S.T.% (5-20%)
   (JS: DCASIM_STRESS_GRADIENT). A light grey dot on the bar at S.T.%
   (8px, the bar 22px), its label below the bar as Hold on the Timeline.
   Colours follow the Success Rate ring: green, orange or red
   (data-tone, set by the script from DCASIM_SUCCESS_TONES); "near" is
   the ring's own colour. Defaults here, overridden from dcasim_settings
   by the PHP (inline style on .dca-result-container).
   (JS: renderStressIntensity, fitStressMarkerLabel)
   ========================================= */
.dca-result-container {
  --stress-green-centre: #2e7d32;   /* darker than near */
  --stress-green-near: #4caf50;    /* the ring's green */
  --stress-green-outer: #c8e6c9;
  --stress-green-dot: #e4e4e7;    /* grey, same in all three */

  --stress-orange-centre: #e65100;  /* darker than near */
  --stress-orange-near: #ff9800;   /* the ring's orange */
  --stress-orange-outer: #fdd3a6;
  --stress-orange-dot: #e4e4e7;

  --stress-red-centre: #c62828;     /* darker than near */
  --stress-red-near: #f44336;      /* the ring's red */
  --stress-red-outer: #ffcdd2;
  --stress-red-dot: #e4e4e7;
}

/* The colours in use: orange until the result sets the tone. */
.dca-result-container .stress-intensity {
  --stress-color-centre: var(--stress-orange-centre);
  --stress-color-near: var(--stress-orange-near);
  --stress-color-outer: var(--stress-orange-outer);
  --stress-color-dot: var(--stress-orange-dot);
}

.dca-result-container .stress-intensity[data-tone="green"] {
  --stress-color-centre: var(--stress-green-centre);
  --stress-color-near: var(--stress-green-near);
  --stress-color-outer: var(--stress-green-outer);
  --stress-color-dot: var(--stress-green-dot);
}

.dca-result-container .stress-intensity[data-tone="red"] {
  --stress-color-centre: var(--stress-red-centre);
  --stress-color-near: var(--stress-red-near);
  --stress-color-outer: var(--stress-red-outer);
  --stress-color-dot: var(--stress-red-dot);
}

/* Same space from the "Hold" label to this title as from the description
   to "Timeline" (35px, text to text). The space for the Hold label is kept
   when there is no Hold age, as the Timeline keeps it for Retire. */
.dca-result-container .stress-intensity-title {
  text-align: center;
  margin: 31px 0 8px;
}

.dca-result-container .stress-intensity {
  position: relative;
  margin: 0 0 20px;   /* room for the label below the bar */
}

.dca-result-container .stress-bar {
  position: relative;
  width: 100%;
  height: 22px;              /* as .withdraw-outcome-bar */
  overflow: hidden;
  border-radius: 12px;
  background: #e9ecef;
  /* Own stacking layer: the band's z-index (above the stripes) stays inside
     the bar, so the S.T. dot still shows on top of the band. */
  isolation: isolate;

  /* Waiting stripes (below). The stripes repeat every --stress-stripe-period
     across them; --stress-stripe-shift is that repeat measured along the
     bar (period / sin(angle): 16px / sin 40deg = 24.892px), so moving the
     stripes by it loops without a jump. Change all three together. */
  --stress-stripe-color: #e0e3e7;   /* just darker than the bar: unobtrusive */
  --stress-stripe-angle: 40deg;
  --stress-stripe-period: 16px;
  --stress-stripe-shift: 24.892px;
}

/* Light grey 40deg stripes running left to right on the empty bar from the
   moment the page appears (.is-striped is in the PHP markup), until the
   coloured band fades in over them; then they fade out (JS:
   renderStressIntensity adds .is-striped-out, then removes both;
   --stress-stripe-fade = the band's fade time). */
.dca-result-container .stress-bar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(-1 * var(--stress-stripe-shift));
  width: calc(100% + var(--stress-stripe-shift));
  background: repeating-linear-gradient(var(--stress-stripe-angle),
    var(--stress-stripe-color) 0 calc(var(--stress-stripe-period) / 2),
    transparent calc(var(--stress-stripe-period) / 2) var(--stress-stripe-period));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--stress-stripe-fade, 900ms) ease-out;
}

.dca-result-container .stress-bar.is-striped::before {
  opacity: 1;
  animation: dcasimStressStripes 1s linear infinite;
}

.dca-result-container .stress-bar.is-striped.is-striped-out::before {
  opacity: 0;
}

@keyframes dcasimStressStripes {
  to { transform: translateX(var(--stress-stripe-shift)); }
}

@media (prefers-reduced-motion: reduce) {
  .dca-result-container .stress-bar.is-striped::before { animation: none; }
}

.dca-result-container .stress-band {
  position: relative;        /* above the waiting stripes */
  z-index: 1;
  height: 100%;
  border-radius: 12px;
  opacity: 0;                /* faded in by the script */
  /* --stress-near and --stress-outer (set by the script) grow with S.T.%:
     "near" at +/- near, "outer" from +/- (near + outer). */
  background: linear-gradient(to right,
    var(--stress-color-outer) 0%,
    var(--stress-color-outer) calc(var(--stress-pct, 50%) - var(--stress-near, 10%) - var(--stress-outer, 10%)),
    var(--stress-color-near) calc(var(--stress-pct, 50%) - var(--stress-near, 10%)),
    var(--stress-color-centre) var(--stress-pct, 50%),
    var(--stress-color-near) calc(var(--stress-pct, 50%) + var(--stress-near, 10%)),
    var(--stress-color-outer) calc(var(--stress-pct, 50%) + var(--stress-near, 10%) + var(--stress-outer, 10%)),
    var(--stress-color-outer) 100%);
}

/* At S.T.% (left set by the script), as tall as the bar. */
.dca-result-container .stress-marker {
  position: absolute;
  top: 0;
  bottom: 0;   /* the box holds only the bar, so: the bar's height */
  width: 0;
  pointer-events: none;
}

/* Dot: about 3/8 of the bar's height, centred on the bar. */
.dca-result-container .stress-dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stress-color-dot);
  transform: translate(-50%, -50%);
}

/* Label 5px below the bar, as Hold below the Timeline. */
.dca-result-container .stress-marker .timeline-marker-label {
  top: 100%;
  margin-top: 5px;
}

/* No value: the label only ("S.T. n/a"), no dot. */
.dca-result-container .stress-marker.is-na .stress-dot {
  display: none;
}

/* =========================================
   Success Rate + Timeline: one card, downloadable as JPG
   Same card look and download icon as the Advanced Result page.
   (JS: setupShareCardDownload)
   ========================================= */
.dca-result-container .dca-share-card {
  grid-column: span 2;   /* full row, as the cards it holds (timeline-card etc.) */
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 12px 20px 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* A gap above each combined card that follows another card. */
.dca-result-container .summary-grid > * + .dca-share-card {
  margin-top: 15px;
}

/* The parts inside are no longer cards of their own. */
.dca-result-container .dca-share-card > .summary-card {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  width: auto;
  max-width: none;
}

/* Asset CAGR and Asset Allocation share a card: some room between them. */
.dca-result-container #assets-card > .summary-card + .summary-card {
  margin-top: 30px;
}

.dca-result-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-result-container .dca-chart-download:hover {
  background: #f4f4f5;
  color: #3f3f46;
}

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

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

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

/* =========================================
   Financial Flow Card (วงกลมแสดงผลลัพธ์)
   ========================================= */
.financial-flow-card {
  grid-column: span 2;
  /* ขยายให้กว้าง 2 ช่อง */
  text-align: center;
}

.circles-container {
  display: flex;
  justify-content: center;
  align-items: flex-start; /* 🌟 เปลี่ยนกลับเป็น flex-start ครับ */
  gap: 30px;
  margin-top: 10px;
  margin-bottom: 30px;
}

.circle-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 230px; /* was 280px; circles are 25% smaller. 🌟 เพิ่มบรรทัดนี้ เพื่อสร้างกรอบให้สูงเท่ากันทุกกล่อง */
}

.circle-shape {
  border-radius: 50%;
  width: 0;
  height: 0;
  transition: all 5.0s ease-out;
  box-shadow: inset 0 -5px 15px rgba(0, 0, 0, 0.1),
    0 5px 10px rgba(0, 0, 0, 0.15);
  will-change: width, height;
  display: flex;
  align-items: center;
  justify-content: center;

  /* 🌟 เพิ่ม 2 บรรทัดนี้เข้าไปครับ */
  margin-top: auto;
  margin-bottom: auto;
}

.circle-multiplier {
  opacity: 0;
  /* เริ่มต้นด้วยการซ่อนตัวหนังสือ */
  transition: opacity 1.5s ease-in;
  /* เอฟเฟกต์ Fade in 1.5 วินาที */
  color: #ffffff; 
  font-weight: 700;
  font-size: 1.1em;
  font-variant-numeric: tabular-nums;
}

/* Total Deposit: purple "1X" on a very light purple circle, the colour of
   Invest / m on the form. Dividend circles are pink (set in the PHP), the
   colour of Dividend % on the form. */
#circle-deposit .circle-multiplier {
  color: #4f46e5;
}

.circle-label {
  margin-top: 0px;
  font-size: var(--fs-body);
  font-weight: 400;
  color: var(--text-muted);
}

.circle-value {
  font-size: var(--fs-title);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  margin-top: 4px;
  margin-bottom: 15px;
  /* ระยะห่างระหว่างตัวเลขกับตัววงกลมด้านล่าง */
}


/* =========================================
   Responsive Design (มือถือ)
   ========================================= */
@media (max-width: 600px) {
  .circles-container {
    flex-direction: column;
    align-items: center;
    gap: 30px; /* ระยะห่างระหว่างแต่ละวงกลมในแนวตั้ง ปรับลด/เพิ่มได้ตามชอบครับ */
  }

  /* 🌟 เพิ่มโค้ดบล็อกนี้เพื่อยกเลิกความสูงบนมือถือ */
  .circle-wrapper {
    min-height: auto; 
  }
}





/* =========================================
   🌟 Consistent UX/UI Variables & Buttons 
      (อิงจากหน้า wp-form-to-go-dcasim.css)
   ========================================= */
.dca-result-container {
  --bg-panel: #ffffff;
  --bg-body: #f4f4f5;
  --text-main: #09090b;
  --text-muted: #71717a;
  --border-subtle: #e4e4e7;
  --accent-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);

  /* Typography: one scale and three text colours for the whole page */
  --text-body: #3f3f46;
  --fs-display: 28px;   /* success rate */
  --fs-title: 16px;     /* card titles, key values */
  --fs-body: 14px;      /* labels, tables, legends */
  --fs-small: 12px;     /* notes, captions, column headers */

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
}

/* Base text for the result cards. The Back / Advanced buttons sit
   outside .summary-grid and keep their original typography. */
.dca-result-container .summary-grid {
  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;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Shared text styles */
.dca-result-container .dca-card-title {
  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);
}

.dca-result-container .dca-group-title {
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.dca-result-container .dca-card-note,
.dca-result-container .dca-cell-sub {
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--text-muted);
}

.dca-result-container .dca-axis-label {
  font-size: var(--fs-small);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* 🌟 Base Button (อิงจากคลาส .button ของหน้าฟอร์ม) */
.dca-result-container .button {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  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;
  font-family: inherit;
}
.dca-result-container .button:active {
  transform: translateY(1px);
}

/* 🌟 Primary Button (ปุ่มรัน/ปุ่มสำคัญ) */
.dca-result-container .btn-primary {
  background: var(--accent-gradient) !important;
  color: white !important;
  border: none !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.dca-result-container .btn-primary:hover {
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

/* 🌟 Secondary Button (ปุ่มกลับ) */
.dca-result-container .btn-secondary {
  background: #ffffff !important; /* บังคับพื้นหลังสีขาวล้วน */
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.dca-result-container .btn-secondary:hover {
  background: var(--bg-body) !important; /* โฮเวอร์แล้วค่อยเป็นสีเทาอ่อน */
  color: var(--text-main);
}

 
/* 🌟 Outline Button (ย่อขนาดปุ่ม 3 ปุ่มด้านใน) */
.dca-result-container .btn-outline {
  padding: 6px 12px !important; 
  font-size: 0.85em !important; 
  font-weight: normal;          
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle); 
  
  /* 🌟 เพิ่มคำสั่งนี้เพื่อบังคับให้อยู่บรรทัดเดียวกันเสมอ */
  white-space: nowrap !important;
}

.dca-result-container .btn-outline:hover {
  border-color: #a1a1aa;
  background: var(--bg-body);
  color: var(--text-main);
  transform: translateY(-1px); /* โฮเวอร์แล้วขยับขึ้นแค่นิดเดียวพอ */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* =========================================
   🌟 Layouts & Grouping
   ========================================= */
/* Navigation Group (Back & Advanced) */
.dca-nav-actions {
  display: flex;
  gap: 16px;
  margin-top: 30px;
  justify-content: center;
}
.dca-nav-actions .button {
  flex: 1;
  max-width: 300px; /* ไม่ให้ปุ่มยืดกว้างเกินไปบนจอใหญ่ */
}



/* =========================================
   🌟 Responsive Design (หน้าจอมือถือ)
   ========================================= */
@media (max-width: 600px) {
  .dca-nav-actions {
    flex-direction: column;
    align-items: center;
  }
  .dca-nav-actions .button {
    width: 100%;
    max-width: 100%;
  }

}

/* ========================================== */
/* 🌟 สไตล์การ์ดตารางแบบพับเก็บได้ (Collapsible) */
/* ========================================== */
.dca-collapsible-card {
  transition: all 0.2s ease-in-out;
  padding: 16px 20px !important;
}

.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;
}

/* ซ่อนสามเหลี่ยมค่าเริ่มต้นของแท็ก details ใน Safari/Chrome */
.dca-collapsible-header::-webkit-details-marker {
  display: none;
}

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

/* เมื่อการ์ดถูกกดกางออก (open) ให้หมุนลูกศรขึ้นข้างบน */
.dca-collapsible-card[open] .dca-toggle-icon {
  transform: rotate(180deg);
  color: #2196F3;
}

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

/* Withdrawal Details and Asset Allocation (the fold-out tables under the
   Withdrawals + Assets card): compact rows with no gap between them, as
   "Exchanges / Instruments / Dividends by Age" on the Advanced page. */
.dca-result-container .summary-grid > .dca-collapsible-card.dca-compact-card {
  padding: 4px 20px !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

.dca-result-container .summary-grid > .dca-collapsible-card.dca-compact-card[open] {
  padding-bottom: 16px !important;
}

/* The first of the two keeps the usual card gap above it. */
.dca-result-container .summary-grid > .dca-share-card + .dca-compact-card,
.dca-result-container .summary-grid > .dca-compact-card[hidden] + .dca-compact-card {
  margin-top: 15px !important;
}

/* ========================================== */
/* 🌟 สไตล์ตารางเปรียบเทียบ Nominal vs Real   */
/* ========================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dca-comparison-table {
  width: 100%;
  border-collapse: collapse; /* แน่ใจว่าขอบตารางยุบรวมกันเรียบร้อย */
  font-size: var(--fs-body);
  color: var(--text-body);
  background: #fff;
}

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

.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-comparison-table th.num-header {
  text-align: right;
}

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

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

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

.dca-comparison-table td.num-cell {
  text-align: right;
  font-family: inherit;
  font-variant-numeric: tabular-nums; /* จัดหลักตัวเลขให้ตรงกัน */
  font-weight: 500;
}

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

.dca-comparison-table td:nth-child(2) {
  color: var(--text-main);
}

#nominal-vs-real-card .dca-comparison-table td:nth-child(3) {
  color: #1e88e5; /* สีฟ้าเน้นค่า Real */
  font-weight: 600;
}

.dca-comparison-table .tbl-sub {
  font-size: var(--fs-small);
  color: var(--text-muted);
  font-weight: 400;
  display: inline-block;
  margin-left: 4px;
}

@media (max-width: 480px) {
  .dca-comparison-table {
    font-size: 13px;
  }
  .dca-comparison-table th,
  .dca-comparison-table td {
    padding: 8px 6px;
  }
  .dca-comparison-table .tbl-sub {
    display: block;
    margin-left: 0;
  }
}

/* =========================================
   Retirement Income
   ========================================= */

.dca-result-container [hidden] {
  display: none !important;
}

.retirement-income-card,
.withdrawal-details-card {
  grid-column: 1 / -1;
  margin-top: 15px;
}

.retirement-income-heading,
.withdraw-details-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.retirement-income-heading {
  justify-content: center;   /* title centred, as the other card titles */
}

.retirement-income-heading h3 {
  text-align: center;
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-main);
}

.retirement-income-path-count,
.withdraw-details-count {
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 400;
  white-space: nowrap;
}


/* Outcome bar */

.withdraw-outcome-bar {
  display: flex;
  width: 100%;
  height: 22px;
  margin: 18px 0 14px;
  overflow: hidden;
  border-radius: 12px;
  background: #e9ecef;
}

.withdraw-outcome-segment {
  width: 0;
  height: 100%;
  min-width: 0;
  transition: width 3s ease-out;
  will-change: width;
}

/* Withdraw green, as Withdraw on the form and the Total Withdraw circle;
   "with reductions" is the same green at 50% (mixed with white). */
.withdraw-outcome-full {
  background: #16a34a;
}

.withdraw-outcome-reduced {
  background: #8ad1a4;
}

.withdraw-outcome-depleted {
  background: #f44336; /* same red as P10 (Worst Case) on the timeline */
}


/* Outcome legend */

.withdraw-outcome-legend {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 10px 20px;
  margin-bottom: 16px;
}

.withdraw-outcome-legend.is-two-part {
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
}

.withdraw-outcome-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-body);
  font-size: var(--fs-body);
}

.withdraw-outcome-legend-item strong {
  white-space: nowrap;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.withdraw-outcome-legend-item:nth-child(2) {
  justify-content: center;
}

.withdraw-outcome-legend-item:last-child {
  justify-content: flex-end;
}

.withdraw-legend-dot {
  flex-shrink: 0;   /* stays round when the label wraps */
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.withdraw-legend-full {
  background: #16a34a;
}

.withdraw-legend-reduced {
  background: #8ad1a4;
}

.withdraw-legend-depleted {
  background: #f44336;
}


/* Visible lifetime-income line */

.retirement-income-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 13px;
  border-top: 1px solid #eeeeee;
  color: var(--text-body);
  font-size: var(--fs-body);
}

.retirement-income-summary-values {
  white-space: nowrap;
}

.retirement-income-separator {
  margin: 0 8px;
  color: #aaa;
}

.retirement-income-p10-note,
.retirement-income-note {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.5;
}

.retirement-income-note {
  color: var(--text-body);
}


/* Withdrawal Details */

.withdraw-details-table-wrap {
  margin-top: 15px;
}

.withdrawal-details-table td:nth-child(2),
.withdrawal-details-table td:nth-child(3) {
  color: var(--text-main);
  font-weight: 500;
}

.withdraw-details-meta {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.7;
}

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


/* Mobile */

@media (max-width: 600px) {
  .withdraw-outcome-legend,
  .withdraw-outcome-legend.is-two-part {
    grid-template-columns: 1fr;
  }

  .retirement-income-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .retirement-income-summary-values {
    white-space: normal;
  }

  .retirement-income-heading,
  .withdraw-details-section-heading {
    align-items: flex-start;
  }

  .withdraw-outcome-legend-item:nth-child(2),
.withdraw-outcome-legend-item:last-child {
  justify-content: flex-start;
}
}

/* =======================================================
   🌟 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; }
}

/* =========================================
   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.
   Same as the Advanced Result page. --dcr-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 card styles.
   ========================================= */
@media (max-width: 600px) {
  html body .dca-result-container {
    box-sizing: border-box;
    width: auto;
    max-width: none !important;
    margin-left: calc(50% - var(--dcr-vw, 100vw) / 2) !important;
    margin-right: calc(50% - var(--dcr-vw, 100vw) / 2) !important;
    padding-left: 8px;
    padding-right: 8px;
  }

  .dca-result-container .summary-grid > .summary-card,
  .dca-result-container .summary-grid > .dca-share-card {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .dca-result-container .summary-grid > .dca-collapsible-card.dca-compact-card {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .dca-result-container .dca-card-switches {
    padding: 0 12px;
  }

  /* Assets' info: no room beside the ring, so below it (not in downloads,
     which keep the desktop layout). The ring's centre text stays on the
     ring (100px = half the 200px ring) although the wrapper grows. */
  .dca-result-container .dca-share-card:not(.dca-exporting) .gauge-text {
    top: 100px;
  }

  .dca-result-container .dca-share-card:not(.dca-exporting) .gauge-side-info {
    position: static;
    width: max-content;
    max-width: calc(var(--dcr-vw, 100vw) - 40px);
    margin-top: 12px;
    margin-left: 50%;
    transform: translateX(-50%);
  }

  .dca-result-container .dca-share-card:not(.dca-exporting) .gauge-side-info .dca-plan-lines {
    text-align: center;
  }

  /* Value at Retirement: below the Total Deposit circle. */
  .dca-result-container .dca-share-card:not(.dca-exporting) .value-assets-info {
    position: static;
    width: max-content;
    max-width: calc(var(--dcr-vw, 100vw) - 40px);
    margin-top: 12px;
    transform: none;
  }

  .dca-result-container .dca-share-card:not(.dca-exporting) .value-assets-info .dca-plan-lines {
    text-align: center;
  }

  /* Downloads use the desktop layout (JS: layoutCardForExport): the card
     is laid out off-screen at its desktop width with .dca-exporting, so the
     phone rules are undone inside it (same values as the desktop rules). */
  .dca-result-container .summary-grid > .dca-share-card.dca-exporting {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  .dca-result-container .dca-exporting .circles-container {
    flex-direction: row;
    align-items: flex-start;
  }

  .dca-result-container .dca-exporting .circle-wrapper {
    min-height: 230px;
  }

  .dca-result-container .dca-exporting .withdraw-outcome-legend {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dca-result-container .dca-exporting .withdraw-outcome-legend.is-two-part {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dca-result-container .dca-exporting .withdraw-outcome-legend-item:nth-child(2) {
    justify-content: center;
  }

  .dca-result-container .dca-exporting .withdraw-outcome-legend-item:last-child {
    justify-content: flex-end;
  }

  .dca-result-container .dca-exporting .retirement-income-heading {
    align-items: center;
  }
}
