/* DCASim form styles — stable version 13.5 */

#dca-sim-wrapper.dca-role-pending .dsgu,
#dca-sim-wrapper.dca-role-pending .dsfm,
#dca-sim-wrapper.dca-role-pending .dspm,
#dca-sim-wrapper.dca-role-pending .dsptn,
#dca-sim-wrapper.dca-role-pending .dsutm {
    display: none !important;
}

/* =======================================================
   🌟 AI MODERNIST THEME + CUSTOM RESPONSIVE GRID
   ======================================================= */
#dca-sim-wrapper {
  --bg-panel: #ffffff;
  --bg-body: #f4f4f5;
  --text-main: #09090b;
  --text-muted: #71717a;
  --border-subtle: #e4e4e7;
  --accent-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
  
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  box-sizing: border-box;
  width: 100%;
}

#dca-sim-wrapper fieldset {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  min-width: 0;
}

#dca-sim-wrapper legend {
  font-weight: 700;
  color: var(--text-main);
  padding: 0 10px;
}

/* 🌟 Form Controls */
#dca-sim-wrapper input[type="text"],
#dca-sim-wrapper input[type="number"],
#dca-sim-wrapper select {
  background: #fafafa;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.2s;
  color: var(--text-main);
  box-sizing: border-box;
}
#dca-sim-wrapper input:focus,
#dca-sim-wrapper select:focus {
  border-color: #a1a1aa;
  background: #ffffff;
  outline: none;
}

/* 🌟 Buttons */
#dca-sim-wrapper .button {
  background: #ffffff !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-main) !important;
  border-radius: 8px !important;
  padding: 8px 16px !important;
  font-weight: 500;
  cursor: pointer;
}

/* ลดขนาดเฉพาะปุ่มไอคอนในส่วน asset-actions */
#dca-sim-wrapper .asset-actions .button {
    padding: 6px 8px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    min-width: auto !important; /* ป้องกันกรณีธีมบังคับความกว้างขั้นต่ำของปุ่ม */
    height: auto !important;    /* ป้องกันกรณีธีมบังคับความสูง */
}

/* 🌟 ปุ่ม RUN SIMULATION สถานะปกติ */
#dca-sim-wrapper #run-sim-btn {
  background: var(--accent-gradient) !important;
  color: white !important;
  border: none !important;
  padding: 12px 24px !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 16px !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  
  /* 🌟 เพิ่มคำสั่ง Transition เพื่อให้ขยับลอยขึ้นลงอย่างนุ่มนวลเวลา Hover */
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease !important;
  cursor: pointer;
  min-width: 200px; /* ลดความกว้างสูงสุดลง (ปรับตัวเลขนี้ได้ตามต้องการ) */
    width: 50%;
}
/* 🌟 เมื่อเอาเมาส์ไปชี้ (Hover) -> ยกลอยขึ้น 2px และขยายเงาให้ฟุ้งมีมิติ */
/* Keep Run Simulation and the Add/Cancel modal buttons the same height. */
#dca-sim-wrapper #run-sim-btn {
    height: 46px !important;
    min-height: 46px !important;
    box-sizing: border-box !important;
}

#dca-sim-wrapper #run-sim-btn:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.45);
  transform: translateY(-2px);
}

/* 🌟 เมื่อกดคลิกจริง (Active) -> ยุบตัวลงไป 1px ให้ความรู้สึกเหมือนปุ่มกดสปริง */
#dca-sim-wrapper #run-sim-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

/* 🔒 คงสถานะนิ่งๆ ไว้สำหรับตอนที่ปุ่มโดนล็อก (Disabled) ยังไม่ให้กด */
#dca-sim-wrapper #run-sim-btn:disabled {
  opacity: 0.6;
  transform: none !important;
  box-shadow: none !important;
  /* cursor: not-allowed; */
}


/* 🌟 Utilities */
.field-group { display: flex; align-items: center; gap: 8px; }
.field-group label { white-space: nowrap; color: var(--text-muted); font-size: 0.85em; font-weight: 500; margin: 0; }
.field-group input, .field-group select { flex: 1; min-width: 0; }
.input-group { display: flex; align-items: center; gap: 5px; }
.input-group input { flex: 1; min-width: 0; }
#dca-sim-wrapper input.tbx-age { width: 65px !important; flex: none !important; }
#dca-sim-wrapper input.tbx-small { width: 70px !important; flex: none !important; }
#dca-sim-wrapper input.tbx-medium { width: 100px !important; flex: none !important; }
#dca-sim-wrapper input.asset-ticker { width: 100px !important; flex: none !important; }
#dca-sim-wrapper input.asset-month { width: 100px !important; flex: none !important; }

/* 🌟 Dropdowns that replaced number boxes keep the exact same width. */
#dca-sim-wrapper select.tbx-age { width: 65px !important; flex: none !important; }
#dca-sim-wrapper select.tbx-small { width: 70px !important; flex: none !important; }
#dca-sim-wrapper select.tbx-micro { width: 60px !important; max-width: 60px !important; flex: none !important; }
/* A select is 2px taller than a text box with the same padding: match the height. */
#dca-sim-wrapper select.tbx-age,
#dca-sim-wrapper select.tbx-small,
#dca-sim-wrapper select.tbx-micro { padding-top: 7px; padding-bottom: 7px; }
/* 60px is narrow: small side padding so 3-digit values (100, 120) are not clipped. */
#dca-sim-wrapper select.tbx-micro { padding-left: 6px; padding-right: 2px; }

/* 🌟 Radio Label Styling */
.field-label { 
  display: flex; align-items: center; gap: 6px; margin: 0; 
  color: var(--text-muted); font-size: 0.85em; font-weight: 500; white-space: nowrap; 
}
.field-label:has(input[type="radio"]), .field-label:has(input[type="checkbox"]) { cursor: pointer; }

/* =======================================================
   🌟 GRID: .col-L-M-S
   Columns at three widths: L (over 1200px), M (751-1200px), S (750px
   and less). col-4-4-2 = 4 columns, 4, then 2.
   ======================================================= */
.col-4-4-2, .col-3-3-3, .col-2-2-2 {
  display: grid;
  gap: 16px;
  align-items: center;
}

.col-4-4-2 > *, .col-3-3-3 > *, .col-2-2-2 > * {
  min-width: 0;
}

.col-4-4-2 { grid-template-columns: repeat(4, 1fr); }
.col-3-3-3 { grid-template-columns: repeat(3, 1fr); }
.col-2-2-2 { grid-template-columns: repeat(2, 1fr); }

/* S */
@media (max-width: 750px) {
  .col-4-4-2 { grid-template-columns: repeat(2, 1fr); }
}

/* S, phones (600px and less, where Advanced Features and Stress Tests go
   full width):
   - .dcasim-stack-s: each label sits above its box, so a label never runs
     into the box beside it (Asset-to-Cash, Rebalance, Stress Tests).
   - .dcasim-wd-dynamic (Withdraw Dynamic): 2 x 2, Never | % per year,
     then Max cut | Buffer. */
@media (max-width: 600px) {
  #dca-sim-wrapper .dcasim-stack-s .field-group,
  #dca-sim-wrapper .field-group.dcasim-stack-s {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
  #dca-sim-wrapper .dcasim-stack-s .field-group > label,
  #dca-sim-wrapper .field-group.dcasim-stack-s > label {
    min-width: 0 !important;
  }
  #dca-sim-wrapper .dcasim-stack-s { row-gap: 12px; }

  #dca-sim-wrapper .dcasim-wd-dynamic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
  }
  #dca-sim-wrapper .dcasim-wd-dynamic > .field-label:first-child {
    grid-column: auto !important;
  }
  #dca-sim-wrapper .dcasim-wd-dynamic .field-group { gap: 6px; }
}

/* Advanced Features Headers */
.feature-section h4 { margin: 20px 0 10px 0; font-size: 0.9em; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* =======================================================
   🌟 Upgrade Prompts & Visibility Classes (-only and -above)
   ======================================================= */
/* 1. สไตล์ตกแต่งเฉพาะสำหรับข้อความแจ้งเตือนให้อัปเกรด (-only) */
.dsgu-only, .dsfm-only, .dspm-only, .dsptn-only, .dsutm-only {
    font-style: italic; 
    color: var(--text-muted, #888888); 
    font-size: 0.90em; 
    margin-top: 4px; 
    line-height: 1.4; 
}

/* 2. การซ่อน Text Prompts พื้นฐาน */
.dsgu-only, .dsfm-only, .dspm-only, .dsptn-only, .dsutm-only {
    display: none;
}

/* 3. กฎการแสดงผล Text Prompts (-only) สำหรับแจ้งเตือน */
#dca-sim-wrapper.dsgu .dsgu-only { display: block; }
#dca-sim-wrapper.dsfm:not(.dspm) .dsfm-only { display: block; }
#dca-sim-wrapper.dspm:not(.dsptn) .dspm-only { display: block; }


/* 4. กฎการซ่อน Structural Elements (-above) อย่างปลอดภัย! ไม่ทำลายเลย์เอาต์ Grid/Flexbox */
#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .dsfm-above { display: none !important; }
#dca-sim-wrapper:not(.dspm):not(.debug-ignore-css) .dspm-above { display: none !important; }
#dca-sim-wrapper:not(.dsptn):not(.debug-ignore-css) .dsptn-above { display: none !important; }
#dca-sim-wrapper:not(.dsutm):not(.debug-ignore-css) .dsutm-above { display: none !important; }
/* =======================================================
   🌟 Locked Features Styling (Disabled State)
   ======================================================= */
[data-feature].is-locked {
    opacity: 0.5;
    pointer-events: none; /* ป้องกันการคลิก */
}

/* ปลดล็อกให้ข้อความแจ้งเตือนอัปเกรดสามารถคลิกได้เผื่อมีการใส่ลิงก์ */
[data-feature].is-locked .dsfm-only,
[data-feature].is-locked .dspm-only {
    pointer-events: auto;
}

/* =======================================================
   🌟 Tooltip Icon "i" (CSS Only)
   ======================================================= */
details.info-tip { position: relative; display: inline-block; margin: 0; }
details.info-tip summary {
    margin-left: 10px; list-style: none; display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border: 1px solid #a3a3a3; border-radius: 50%; font-size: 11px;
    font-style: normal; color: #737373; cursor: pointer; user-select: none; text-transform: none !important; 
}
details.info-tip summary::-webkit-details-marker { display: none; }
/* Tooltips stay readable on locked (tier-gated) sections. */
[data-feature].is-locked details.info-tip,
.dcasim-preset-section.is-locked details.info-tip { pointer-events: auto; }

/* Preset Settings: greyed like the other Stress Tests when the tier has
   no preset at all (the JS sets .is-locked; its buttons each carry their
   own data-feature). */
#dca-sim-wrapper .dcasim-preset-section.is-locked {
    opacity: 0.5;
    pointer-events: none;
}
#dca-sim-wrapper .dcasim-preset-section.is-locked .dsgu-only,
#dca-sim-wrapper .dcasim-preset-section.is-locked .dsfm-only {
    pointer-events: auto;
}
details.info-tip summary:hover { background-color: #eee; color: #333; }

/* 🌟 สไตล์พื้นฐานที่ใช้ร่วมกันของ Popup ทุกตัว */
details.info-tip .tip-popup-above,
details.info-tip .tip-popup-below {
    display: none; 
    position: absolute; 
    z-index: 999; 
    left: 50%; 
    transform: translateX(calc(-50% + var(--tip-shift, 0px))); /* --tip-shift: set by JS to stay inside the panel */
    width: 250px; 
    white-space: normal;
    word-wrap: break-word;
    background-color: #333; 
    color: #fff; 
    padding: 0px 10px;
    border-radius: 6px;
    font-size: 14px; 
    font-style: normal; 
    font-weight: normal; 
    line-height: 1.4; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-transform: none !important;
    text-align: left;
}

/* --- 1. แบบเด้งขึ้นด้านบน (Above) --- */
details.info-tip .tip-popup-above {
    bottom: 150%; 
    top: auto;
}
details.info-tip .tip-popup-above::after {
    content: ""; 
    position: absolute; 
    top: 100%; 
    bottom: auto;
    left: calc(50% - var(--tip-shift, 0px)); /* arrow keeps pointing at the i */
    margin-left: -5px; 
    border-width: 5px; 
    border-style: solid; 
    border-color: #333 transparent transparent transparent; 
}

/* --- 2. แบบเด้งลงด้านล่าง (Below) --- */
details.info-tip .tip-popup-below {
    top: 150%; 
    bottom: auto;
}
details.info-tip .tip-popup-below::after {
    content: ""; 
    position: absolute; 
    bottom: 100%; 
    top: auto;
    left: calc(50% - var(--tip-shift, 0px)); /* arrow keeps pointing at the i */
    margin-left: -5px; 
    border-width: 5px; 
    border-style: solid; 
    border-color: transparent transparent #333 transparent; 
}

/* สั่งให้แสดงผลเมื่อคลิกเปิด (Open) */
details.info-tip[open] .tip-popup-above,
details.info-tip[open] .tip-popup-below { 
    display: block; 
    animation: fadeIn 0.2s ease; 
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translate(calc(-50% + var(--tip-shift, 0px)), 5px); } 
    to { opacity: 1; transform: translate(calc(-50% + var(--tip-shift, 0px)), 0); } 
}


/* =======================================================
   🌟 Advanced Features Toggle
   ======================================================= */
.feature-header {
    font-weight: bold; font-size: 1.1em; cursor: pointer; padding: 0px 0; display: flex; align-items: center;
    justify-content: space-between; user-select: none; color: #333; transition: color 0.2s ease;
}
.feature-header:hover { color: #0073aa; }

#user-settings-toggle-icon,
#feature-toggle-icon,
#stress-toggle-icon { 
    font-size: 0.8em; 
    transition: transform 0.3s ease; 
}




.feature-content > div { overflow: hidden; }
/* =======================================================
   🌟 Generic Up/Down Animation (CSS Grid)
   ======================================================= */
/* 1. กล่องนอกสุดสำหรับจัดการความสูง */
.animated-content-wrapper {
    display: grid;
    grid-template-rows: 0fr; /* ค่าเริ่มต้นคือหุบ (0) */
    transition: grid-template-rows 0.4s ease-out;
}

/* 2. เมื่อถูกสั่งให้เปิด จะกางออกเต็ม 100% (1fr) */
.animated-content-wrapper.is-open {
    grid-template-rows: 1fr; 
}

/* 3. กล่องด้านในสำหรับซ่อนเนื้อหาที่ล้นตอนกำลังหุบ */
.animated-content-inner {
    overflow: hidden; 
}

/* 🌟 Generic Icon Rotation (สำหรับหมุนลูกศร ▼ ให้เป็น ▲) */
.animated-icon {
    display: inline-block; /* บังคับให้ transform ทำงานได้ */
    transition: transform 0.3s ease;
}

.animated-icon.open {
    transform: rotate(180deg);
}


/* =======================================================
   🌟 NEW ASSET ENTRY ANIMATION (Subtle Glassmorphic Reveal)
   ======================================================= */
.asset-row-animate {
    position: relative !important;
    overflow: hidden !important; 
    contain: paint !important; 
    opacity: 0;
    transform: translateX(-20px); 
    animation: slideInFromLeft 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* 🔮 แผ่นกระจกฝ้า iPhone จะคำนวณตำแหน่งอิงจากขอบเขตความสูงของกล่องเนื้อหาใหม่ล่าสุด */
.asset-row-animate::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0; /* 🌟 บังคับจับขอบล่างให้พอดีความสูงจริง */
    
    /* สไลด์ขยายจาก -20px ยื่นไปฝั่งขวา +20px ของพื้นที่ชิ้นใหม่ */
    left: -20px !important;
    width: calc(100% + 40px) !important;
    height: 100%;
    margin: 0 !important;
    
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.18), rgba(124, 58, 237, 0.18)); 
    /*  backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px); */
    
    border: none;
    border-radius: 0; 
    z-index: 10;
    
    transform: scaleX(0);
    transform-origin: left;
    animation: revealBlock 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@media (
    prefers-reduced-motion:
    reduce
) {
    #dca-sim-wrapper *,
    #dca-sim-wrapper *::before,
    #dca-sim-wrapper *::after {
        animation-duration:
            0.01ms !important;

        animation-iteration-count:
            1 !important;

        transition-duration:
            0.01ms !important;
    }
}

.asset-row-animate .asset-details-wrapper {
    opacity: 0;
    animation: fadeInContent 0.2s ease forwards;
    animation-delay: 0.2s;
}

/* --- Keyframes กระชับเวลาความเร็ว --- */
@keyframes slideInFromLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
@keyframes revealBlock {
    0% { transform: scaleX(0); transform-origin: left; }
    50% { transform: scaleX(1); transform-origin: left; }
    50.1% { transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
}
@keyframes fadeInContent {
    to { opacity: 1; }
}

/* =======================================================
   🌟 ปุ่ม Add Asset แบบวงกลม (Minimalist + Hover/Click Effects)
   ======================================================= */
/* 1. สถานะปกติของปุ่ม */
#dca-sim-wrapper #btn-add-asset {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important; /* บังคับเป็นวงกลม */
    padding: 0 !important;
    
    /* จัดเครื่องหมาย + ให้อยู่ตรงกลางเป๊ะ */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    
    font-size: 26px !important; /* ขนาดเครื่องหมาย + */
    font-weight: 300 !important;
    line-height: 1 !important;
    
    background: #ffffff !important;
    color: var(--text-muted) !important;
    border: 1px solid var(--border-subtle) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    
    /* สั่งให้ตอนเปลี่ยนสี มีความสมูทลื่นไหล (Transition) */
    transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* 🌟 2. สถานะเมื่อเอาเมาส์ไปชี้ (Mouse Over / Hover) */
#dca-sim-wrapper #btn-add-asset:hover {
    background: var(--accent-gradient) !important; /* 👈 ดึงสีม่วง-น้ำเงินจากปุ่ม RUN SIMULATION */
    color: #ffffff !important;                     /* 👈 เปลี่ยนเครื่องหมาย "+" เป็นสีขาว */
    border-color: transparent !important;          /* ซ่อนเส้นขอบ */
    transform: translateY(-2px);                  /* ให้ปุ่มลอยขึ้นนิดๆ */
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); /* ใส่เงาสีฟุ้งๆ ให้ดูมีมิติ */
}

/* =======================================================
   🌟 แก้ปัญหากรอบค้างหลังจากกดคลิกปุ่ม (Focus State Reset)
   ======================================================= */
/* 1. เมื่อปุ่มโดนคลิกค้างไว้ (มีสถานะ Focus) ให้ล้างกรอบกลับไปเป็นสีอ่อน */
#dca-sim-wrapper #btn-add-asset:focus {
    outline: none !important; /* ปิดกรอบ Focus มาตรฐานของเบราว์เซอร์ */
    border: 1px solid var(--border-subtle) !important; /* คืนค่าขอบสีเทาอ่อน */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important; /* คืนค่าเงาเดิม */
}

/* 2. ถ้าเพิ่งคลิกเสร็จและเมาส์ยังวางคาอยู่ (Focus + Hover) ให้ใช้สไตล์โปร่งใสแบบตอน Hover */
#dca-sim-wrapper #btn-add-asset:focus:hover {
    border-color: transparent !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}


/* =======================================================
   🌟 สถานะปุ่ม Add Asset เมื่อเต็มโควต้า (Maxed / Dot state) - FOOLPROOF
   ======================================================= */
/* รวบยอดทั้งสถานะ ปกติ, ตอนเมาส์ชี้ (Hover) และตอนกด (Active) ให้อยู่นิ่งๆ เป็นสีเทา */
#dca-sim-wrapper #btn-add-asset.is-maxed,
#dca-sim-wrapper #btn-add-asset.is-maxed:hover,
#dca-sim-wrapper #btn-add-asset.is-maxed:active {
    background: #f4f4f5 !important;
    background-image: none !important;            /* ล้าง Gradient ทุกชนิด */
    color: #a1a1aa !important;                    /* บังคับจุดให้เป็นสีเทา */
    -webkit-text-fill-color: #a1a1aa !important;  /* ป้องกันธีมแอบใส่สีที่เนื้อตัวอักษร */
    border: 0.5px solid #e4e4e7 !important;         /* บังคับขอบให้เป็นสีเทาอ่อน */

    box-shadow: none !important;                  /* ล้างแสงเงา */
    transform: none !important;                   /* ไม่ต้องขยับลอยขึ้นลง */
    cursor: pointer !important;
}


/* =======================================================
   🌟 REMOVE ASSET ANIMATION (Simple Transparent Red Fade)
   ======================================================= */
.asset-row-remove-animate {
    position: relative !important;
    pointer-events: none; /* ป้องกันการกดปุ่มซ้ำขณะกำลังจะลบทิ้ง */
    animation: fadeOutSimple 0.3s ease forwards;
}

/* 🔴 สร้างแผ่นสีแดงโปร่งแสงคลุมทับทั้งการ์ดแบบเรียบง่าย */
.asset-row-remove-animate::after {
    content: '';
    position: absolute;
    /* กางคลุมพื้นที่ทั้งหมดของแถว */
    top: -5px; left: -10px; right: -10px; bottom: -5px; 
    /*background-color: rgba(239, 68, 68, 0.15);  สีแดงโปร่งแสง */
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    z-index: 10;
    opacity: 0;
    animation: showRedOverlay 0.1s ease forwards;
}

/* จังหวะที่ 1: สีแดงโผล่ขึ้นมาเตือนอย่างรวดเร็ว */
@keyframes showRedOverlay {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 1; }
}

/* จังหวะที่ 2: ทั้งการ์ดค่อยๆ จางและหดตัวลงเล็กน้อยก่อนหายไป */
@keyframes fadeOutSimple {
    0% { opacity: 1; transform: scale(1); }
    40% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.98); }
}


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

/* 🌀 ตัววงแหวน Spinner */
.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 --- */
@keyframes dca-spin {
    to { transform: rotate(360deg); }
}

@keyframes dca-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* =======================================================
   🌟 REBALANCE STRATEGY STYLES
   ======================================================= */
/* กล่องจัดกลุ่มการตั้งค่าย่อยให้ดูเป็นสัดส่วน */
#dca-sim-wrapper .rebalance-sub-settings {
    background: #fafafa;
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin-top: 10px;
}

/* ขนาดช่องกรอกแบบจิ๋ว (สำหรับตัวเลขอายุ 2 หลัก) */
#dca-sim-wrapper input.tbx-micro {
    width: 60px !important;
    max-width: 60px !important;
    flex: none !important;
    text-align: center;
    padding: 8px 4px; /* ลดขอบซ้ายขวาให้ตัวเลขไม่เบียด */
}

/* ตัวขีดคั่นกลางระหว่างอายุ ( - ) */
#dca-sim-wrapper .range-separator {
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 4px;
}

/* ป้ายกำกับหน่วยด้านหลัง (mo, %) */
#dca-sim-wrapper .unit-label {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-left: 4px;
    font-weight: 500;
}


/* =======================================================
   🌟 TEXTBOX PREFIX AND SUFFIX (หน่วยต่อท้ายช่อง Input)
   ======================================================= */

#dca-sim-wrapper .tbx-prefix {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-right: -4px; 
}

#dca-sim-wrapper .tbx-suffix {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-left: -2px;

}

/* =======================================================
   🌟 RESET BUTTON
   ======================================================= */
#dca-sim-wrapper .btn-reset {
    background: transparent !important;
    border: 1px solid #e4e4e7 !important; 
    color: #a1a1aa !important; 
    box-shadow: none !important;
    font-weight: 500 !important;
    
    /* 🌟 กำหนด Padding และ Font-size ให้เท่ากับปุ่ม Run Simulation เป๊ะๆ */
    padding: 12px 24px !important; 
    font-size: 16px !important;
    
    transition: all 0.2s ease !important;
}

#dca-sim-wrapper .btn-reset:hover {
    border-color: #a1a1aa !important;
    color: #71717a !important;
    background: #fafafa !important;
}

/* =======================================================
   🌟 ASSETS SUMMARY (Existing / Invest / Div. / T.W.)
   Only two layouts:
     .is-1x4  one line. Rebalance on (4 items): equal columns, each a
              quarter of the width. Rebalance off (3 items, .cols-3):
              side by side with normal spacing, not spread out.
     .is-2x2  Existing | Invest, then Div. | T.W., each half the width
   Never 3 + 1. The JS (Assets summary: 1 x 4 or 2 x 2) tries one line
   and uses 2 x 2 when it does not fit.
   ======================================================= */
#dca-sim-wrapper .dcasim-asset-summary.is-1x4,
#dca-sim-wrapper .dcasim-asset-summary.is-2x2 {
    display: grid !important;
    gap: 6px 12px !important;
}
#dca-sim-wrapper .dcasim-asset-summary.is-1x4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
#dca-sim-wrapper .dcasim-asset-summary.is-1x4.cols-3 {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px 24px !important;
}
#dca-sim-wrapper .dcasim-asset-summary.is-1x4 > * {
    white-space: nowrap;
}
#dca-sim-wrapper .dcasim-asset-summary.is-2x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* =======================================================
   🌟 RUN SIMULATION ROW
   Wide: Back at the left, RUN SIMULATION centred, Reset at the right.
   Narrow (row under 520px): RUN SIMULATION takes the full width,
   Back and Reset share the row below it, half each.
   ======================================================= */
#dca-sim-wrapper .dcasim-run-row {
    container-type: inline-size;
    container-name: dcasim-run;
    margin: 30px 0;
    width: 100%;
}
#dca-sim-wrapper .dcasim-run-row-inner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}
#dca-sim-wrapper .dcasim-run-row #back-sim-btn  { position: absolute; left: 0; }
#dca-sim-wrapper .dcasim-run-row #reset-sim-btn { position: absolute; right: 0; }

@container dcasim-run (max-width: 519px) {
    #dca-sim-wrapper .dcasim-run-row-inner {
        flex-wrap: wrap;
        gap: 10px;
    }
    #dca-sim-wrapper .dcasim-run-row #run-sim-btn {
        order: -1;
        flex: 1 0 100%;
        width: 100%;
        min-width: 0;
    }
    #dca-sim-wrapper .dcasim-run-row #back-sim-btn,
    #dca-sim-wrapper .dcasim-run-row #reset-sim-btn {
        position: static;
        flex: 1 1 0;
        min-width: 0;
        margin: 0 !important;
    }
}

/* 🌟 ล้างระยะห่างส่วนเกินของปุ่ม Radio และ Checkbox ที่ติดมาจากธีม WordPress */
#dca-sim-wrapper .field-label input[type="radio"],
#dca-sim-wrapper .field-label input[type="checkbox"] {
    margin: 0 !important;
    padding: 0 !important;
}
/* =======================================================
   🌟 ASSET ROWS — one line per asset at every width
   -------------------------------------------------------
   Columns follow the width of the asset list itself (container query),
   not the screen, so the layout is right whatever width the theme gives
   the form.
     Main line     : wide   [ticker] [Monthly] [Div] [T.W.]          [▼]
                     narrow [ticker] [Monthly] [Div 1.2% / T.W. 25%] [▼]
                     (Div and T.W. boxes move into the asset settings)
     Asset settings: Existing | Trade fee | Mgmt fee (3 columns)
                     Existing | Dividend, T.W., Trade fee | Mgmt fee (narrow)
                     Deposit skip | Dividend skip
                     Price vol. | Slippage vol. | Dividend vol.
                     Crash | Short history | Dependency
   Tier visibility is unchanged: dsfm-above / dspm-above / data-feature.
   ======================================================= */
/* 🌟 Asset list width classes
   The asset layouts follow the width of the list itself, not the screen.
   A ResizeObserver in the JS ("Asset list width classes") sets these
   classes on .dcasim-assets-wrap:
     .cq-428  the list is 428px or wider
     .cq-470  470px or wider
     .cq-564  564px or wider
   No class yet (before the first layout) = the narrowest layout.

   Why native CSS container queries were removed (earlier 13.5 build):
   with them, in Chrome 156 on a
   370-375px screen with Rebalance off and "Assets full width" on, the
   asset list could end up with no layout box at all: rows in the page,
   totals right, nothing drawn, no console error. Removing the container
   queries alone brought the rows back, with the grid columns unchanged.
   The exact Chromium cause is not confirmed; it did not happen in
   Chrome 153. Do not bring container queries back to the asset list
   without testing it at small phone widths in current Chrome and
   Chrome Beta. */

/* Column headings for the one-line layout; hidden otherwise. */
#dca-sim-wrapper .asset-colhead {
    display: none;
}

#dca-sim-wrapper .asset-container {
    border-top: 1px solid var(--border-subtle);
    padding: 7px 0 10px;
}

/* --- Assets legend across the top border: title, a line like the border,
       then Expand one | Expand all (the sections' icons) and ▲ --- */
#dca-sim-wrapper fieldset > legend.dcasim-assets-legend {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding-right: 0;
}
#dca-sim-wrapper .dcasim-legend-title {
    white-space: nowrap;
}
#dca-sim-wrapper .dcasim-legend-line {
    flex: 1 1 auto;
    height: 1px;
    margin-left: 10px;
    background: var(--border-subtle);
}
#dca-sim-wrapper .dcasim-asset-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    padding-right: 4px;
}
#dca-sim-wrapper .dcasim-asset-tools[hidden] {
    display: none;
}
#dca-sim-wrapper .dcasim-assets-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 28px !important;
    margin: 0 0 0 18px !important;        /* 24px from the icons, as in the sections */
    padding: 0 2px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #333 !important;
    font-size: 0.88em;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
}
#dca-sim-wrapper .dcasim-assets-toggle:hover { color: #0073aa !important; }
#dca-sim-wrapper .dcasim-assets-toggle:focus { outline: none; }
#dca-sim-wrapper .dcasim-assets-toggle:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 1px;
}

/* The asset rows slide shut like the main sections. Clipped only while
   sliding or shut, so the colour squares in the side padding show. */
#dca-sim-wrapper .dcasim-assets-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.4s ease-out;
}
#dca-sim-wrapper .dcasim-assets-body.is-collapsed {
    grid-template-rows: 0fr;
}
#dca-sim-wrapper .dcasim-assets-body-inner {
    min-height: 0;
}
#dca-sim-wrapper .dcasim-assets-body.is-collapsed > .dcasim-assets-body-inner,
#dca-sim-wrapper .dcasim-assets-body.is-animating > .dcasim-assets-body-inner {
    overflow: hidden;
}

/* --- head: ticker, colour dot, ▼ ✖ --- */
#dca-sim-wrapper .asset-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    margin-bottom: 4px;
}

/* The ticker always starts at the panel's content edge (in line with
   "Monthly:" and the T.W. bar), whether Rebalance is on or off. */
#dca-sim-wrapper .asset-name {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
}

/* Ticker line: colour dot + ticker. The dot is centred on this line, so it
   stays level with the ticker when the company name shows below. */
#dca-sim-wrapper .asset-ticker-line {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* Company name under the ticker: normal weight, grey, cut to the column. */
#dca-sim-wrapper .asset-company {
    min-width: 0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.25;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}
#dca-sim-wrapper .asset-company[hidden] {
    display: none;
}
/* With a company name, the ticker + name sit a little lower. */
#dca-sim-wrapper .asset-name:has(.asset-company:not([hidden])) {
    top: 2px;
}

#dca-sim-wrapper .asset-ticker-label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.3px;
    color: #4f46e5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

/* Restored from an old saved form without an asset ID. */
#dca-sim-wrapper .asset-ticker-label.is-invalid {
    color: #dc2626;
    text-decoration: line-through;
}

/* Rebalance on: the colour square sits in the panel's side padding,
   between the left border and the ticker, so the ticker does not move. */
#dca-sim-wrapper .asset-color-dot {
    display: none;
    position: absolute;
    top: 50%;
    left: -13px;              /* 8px square + 5px gap to the ticker */
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 2px;
}
#dca-sim-wrapper.dcasim-rb-on .asset-color-dot {
    display: block;
}

/* Phones: the panel padding is 12px, so a smaller square and gap. */
@media (max-width: 600px) {
    #dca-sim-wrapper .asset-color-dot {
        left: -10px;
        width: 7px;
        height: 7px;
        margin-top: -3.5px;
    }
}

#dca-sim-wrapper .asset-head .asset-actions {
    display: flex;
    gap: 5px;
    flex: none;
    margin-left: auto;
}

/* --- the grids --- */
#dca-sim-wrapper .asset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    align-items: center;
}

#dca-sim-wrapper .asset-cell {
    min-width: 0;
}

/* T.W. is hidden unless Rebalance is on (toggleTWVisibility also sets it). */
#dca-sim-wrapper:not(.dcasim-rb-on) .asset-main .cell-tw {
    display: none !important;
}

#dca-sim-wrapper .asset-main .cell-tw,
#dca-sim-wrapper .asset-main .cell-div,
#dca-sim-wrapper .cell-div-line {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Narrow lists only (see "Narrow list" below): the Div / T.W. text and
   the Dividend / T.W. copies in the asset settings. Elsewhere the
   Dividend slot stays empty so Trade fee + Mgmt fee share a row. */
#dca-sim-wrapper .asset-sum,
#dca-sim-wrapper .asset-details-grid .cell-tw-alt {
    display: none;
}

#dca-sim-wrapper .asset-details-grid .cell-div-alt {
    visibility: hidden;
}

#dca-sim-wrapper .asset-st-spacer {
    display: none;
}

/* list min-width: 470px (class .cq-470) */
#dca-sim-wrapper .dcasim-assets-wrap.cq-470 .asset-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

#dca-sim-wrapper .dcasim-assets-wrap.cq-470 .asset-details-grid .cell-div-alt {
        display: none;
    }

/* Deposit skip | Dividend skip | (empty), then the volatility row. */
#dca-sim-wrapper .dcasim-assets-wrap.cq-470 .asset-st-spacer {
        display: block;
    }


/* 🌟 Wide list: one line per asset, fields packed to the left
      Rebalance off (list ≥ 428px): [ticker] [Monthly] [Div ⟲]          [▼]
      Rebalance on  (list ≥ 564px): [ticker] [Monthly] [Div ⟲] [T.W. ⫼ ⫽] [▼]
   (Div +8px and T.W. +16px, and the breakpoints with them, since the
   boxes gained their up / down buttons.)
   Each column has a minimum (used at the breakpoint) and a maximum: when
   the list is wider — an iPad mini in portrait, a desktop — the columns
   grow to their maximum before the empty space at the right takes the
   rest, so long tickers (ADVANC.BK) and 5-character dividends (12.34)
   are not cut. The fields stay packed to the left.
   Rebalance on: Div and T.W. stop at what "12.34" and "16.67" need;
   Monthly gets the extra width (room for 1000000).
   (✖ moved into the asset settings, so the line needs less width than it
   did with ▼ ✖ side by side: 470px and 570px before.)
   The head and the main row stop being boxes of their own
   (display: contents), so their pieces sit in one grid on the card.
   The last column (▼, 28px) has a fixed width in the rows and in the
   headings alike, so both grids share out the same spare width and the
   headings stay over their boxes at every width.
   Fixed column widths keep every asset's fields lined up; a long ticker is
   shortened with "…" (the full ticker and name are in its tooltip).
   Narrower lists keep the ticker line above the fields. */
/* list min-width: 428px (class .cq-428) */
#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container {
        display: grid;
        grid-template-columns: minmax(96px, 116px) minmax(140px, 160px) minmax(126px, 146px) minmax(0, 1fr) 28px;
        column-gap: 6px;
        align-items: center;
    }

/* Headings over Monthly and Div; the boxes drop their own "Div". */
#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428:has(.asset-row) > .asset-colhead {
        display: grid;
        grid-template-columns: minmax(96px, 116px) minmax(140px, 160px) minmax(126px, 146px) minmax(0, 1fr) 28px;
        column-gap: 6px;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-colhead .ch-tw {
        display: none;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-main .cell-div .af-tag {
        display: none;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .asset-head,
#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .asset-main {
        display: contents;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .asset-name { grid-column: 1; grid-row: 1; }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .cell-month { grid-column: 2; grid-row: 1; }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .cell-div { grid-column: 3; grid-row: 1; }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .asset-actions {
        grid-column: 5;
        grid-row: 1;
        margin-left: 0;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-container .asset-details-wrapper {
        grid-column: 1 / -1;
        grid-row: 2;
    }

#dca-sim-wrapper:not(.dcasim-rb-on) .dcasim-assets-wrap.cq-428 .asset-main .asset-field {
        padding: 0 8px;
        gap: 3px;
    }


/* list min-width: 564px (class .cq-564) */
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container {
        display: grid;
        grid-template-columns: minmax(84px, 108px) minmax(130px, 180px) minmax(124px, 134px) minmax(160px, 170px) minmax(0, 1fr) 28px;
        column-gap: 6px;
        align-items: center;
    }

/* Headings over Monthly, Div and T.W.; the boxes drop their own
       "Div" and "T.W." words (the checkbox stays). Div gains the 12px
       the T.W. word gave up, for its history button, so every column
       still starts where it did. */
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564:has(.asset-row) > .asset-colhead {
        display: grid;
        grid-template-columns: minmax(84px, 108px) minmax(130px, 180px) minmax(124px, 134px) minmax(160px, 170px) minmax(0, 1fr) 28px;
        column-gap: 6px;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-main .cell-div .af-tag,
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-main .af-tw-text {
        display: none;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .asset-head,
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .asset-main {
        display: contents;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .asset-name { grid-column: 1; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .cell-month { grid-column: 2; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .cell-div { grid-column: 3; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .cell-tw { grid-column: 4; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .asset-actions {
        grid-column: 6;
        grid-row: 1;
        margin-left: 0;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-container .asset-details-wrapper {
        grid-column: 1 / -1;
        grid-row: 2;
    }

/* Slimmer padding so Monthly, Div and T.W. (with its step arrows)
       all fit beside the ticker. */
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap.cq-564 .asset-main .asset-field {
        padding: 0 7px;
        gap: 3px;
    }


/* 🌟 Narrow list: still one line per asset
      Rebalance off (list < 428px): [ticker] [Monthly] [Div 1.2%]           [▼]
      Rebalance on  (list < 564px): [ticker] [Monthly] [Div 1.2% / T.W. 25%]  [▼]
   Only Monthly keeps its box on the line; Div (and T.W., while ticked)
   show as text, and a tap on it opens the asset settings, where their
   boxes are (Existing | Dividend, then T.W. on a row of its own). The
   head and main row are display: contents, as in the wide layout. */
/* list max-width: 427px (class :not(.cq-428)) */
#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container {
        display: grid;
        grid-template-columns: minmax(56px, 96px) minmax(88px, 120px) max-content minmax(4px, 1fr) 28px;
        column-gap: 6px;
        align-items: center;
    }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-head,
#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-main {
        display: contents;
    }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-name { grid-column: 1; grid-row: 1; }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .cell-month { grid-column: 2; grid-row: 1; }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-sum { grid-column: 3; grid-row: 1; display: flex; }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-actions { grid-column: 5; grid-row: 1; margin-left: 0; }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-container .asset-details-wrapper { grid-column: 1 / -1; grid-row: 2; }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-main .cell-div,
#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-main .cell-tw {
        display: none !important;
    }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-main .asset-field {
        padding: 0 8px;
        gap: 3px;
    }

/* Asset settings on 2 columns: Existing | Dividend first. */
#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-details-grid,
#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-check-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-check-row > .asset-check:nth-of-type(2) {
        max-width: calc(100% - 34px);
    }

#dca-sim-wrapper .dcasim-assets-wrap:not(.cq-428) .asset-details-grid .cell-div-alt {
        display: block;
        visibility: visible;
    }


/* list max-width: 563px (class :not(.cq-564)) */
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container {
        display: grid;
        grid-template-columns: minmax(56px, 96px) minmax(88px, 120px) max-content minmax(4px, 1fr) 28px;
        column-gap: 6px;
        align-items: center;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-head,
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-main {
        display: contents;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-name { grid-column: 1; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .cell-month { grid-column: 2; grid-row: 1; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-sum { grid-column: 3; grid-row: 1; display: flex; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-actions { grid-column: 5; grid-row: 1; margin-left: 0; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-container .asset-details-wrapper { grid-column: 1 / -1; grid-row: 2; }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-main .cell-div,
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-main .cell-tw {
        display: none !important;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-main .asset-field {
        padding: 0 8px;
        gap: 3px;
    }

/* Asset settings on 2 columns: Existing | Dividend first. */
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-details-grid,
#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-check-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-check-row > .asset-check:nth-of-type(2) {
        max-width: calc(100% - 34px);
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-details-grid .cell-div-alt {
        display: block;
        visibility: visible;
    }

#dca-sim-wrapper.dcasim-rb-on .dcasim-assets-wrap:not(.cq-564) .asset-details-grid .cell-tw-alt {
        display: block;
        grid-column: 1 / -1;
    }


/* The Div / T.W. text: small grey words, the numbers in the main colour,
   right after Monthly (the spare width goes between it and ▼). A plain
   button: themes style buttons. */
#dca-sim-wrapper .asset-sum {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 12.5px !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: var(--text-muted) !important;
    cursor: pointer;
}

#dca-sim-wrapper .asset-sum-item {
    white-space: nowrap;
}

/* Narrow list: Monthly is capped at 120px and the Div / T.W. column is
   sized to its text (max-content), so it never runs under ▼; at least
   4px are kept between them. */

#dca-sim-wrapper .asset-sum-v {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

#dca-sim-wrapper .asset-sum-item[hidden],
#dca-sim-wrapper:not(.dcasim-rb-on) .asset-sum-tw {
    display: none !important;
}

#dca-sim-wrapper .asset-sum:focus {
    outline: none !important;
}

#dca-sim-wrapper .asset-sum:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 2px;
}

/* Very small phones (360px screens and less): the checkbox alone says
   T.W., and the settings checkboxes use slightly smaller text so labels
   fit. */
@media (max-width: 360px) {
    #dca-sim-wrapper .af-tw-text {
        display: none;
    }

    #dca-sim-wrapper .asset-check {
        gap: 5px;
        font-size: 12.5px;
    }
}

/* --- one field: [prefix][number][suffix] in a single box --- */
#dca-sim-wrapper .asset-field {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 38px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 0 10px;
    background: #fafafa;
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

#dca-sim-wrapper .asset-field:focus-within {
    background: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Wins over the older fixed widths (input.asset-month, .tbx-*) and the
   generic number-input box styling. 16px stops iPhones zooming in. */
#dca-sim-wrapper .asset-field input[type="number"] {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
    font-size: 16px;
    line-height: 1.2;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

/* The browser's own step arrows are off: with a mouse every number box in
   an asset row (and Withdraw) has its own up / down buttons
   (.dcasim-nudge); on phones and tablets neither. ↑ / ↓ keys still step
   the box. */
#dca-sim-wrapper .asset-field input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Money in and money out, in the same colours as the Start guide's picture:
   Invest / m in purple (every asset row), Withdraw in bold green. */
#dca-sim-wrapper .asset-field input.asset-month[type="number"] {
    color: #4f46e5;
}

#dca-sim-wrapper .asset-field input#withdraw-per-month[type="number"] {
    color: #16a34a;
    font-weight: 700;
}

/* Dividend % in pink (asset rows and the summary), so it is not confused
   with Withdraw (green) or T.W. (blue). */
#dca-sim-wrapper .asset-field input.asset-dividend[type="number"],
#dca-sim-wrapper .asset-field input.asset-dividend-mirror[type="number"] {
    color: #f472b6;
}

/* T.W. % in blue, as T.W. in the summary, but not bold (grey while its
   box is unticked, see below). The T.W. number in the narrow Div / T.W.
   text too. */
#dca-sim-wrapper .asset-field input.asset-rebalance-target-weight[type="number"],
#dca-sim-wrapper .asset-field input.asset-rebalance-target-weight-mirror[type="number"] {
    color: #2189dd;
    font-weight: 400;
}

#dca-sim-wrapper .asset-sum-tw .asset-sum-v {
    color: #2189dd;
}

#dca-sim-wrapper .asset-field input[type="number"]::-webkit-inner-spin-button,
#dca-sim-wrapper .asset-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#dca-sim-wrapper .af-pre,
#dca-sim-wrapper .af-suf {
    flex: none;
    font-size: 14px;
    color: #a1a1aa;
}

#dca-sim-wrapper .af-tag {
    flex: none;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* T.W.: [☑ T.W. 25 %] then the two split icons */
#dca-sim-wrapper .af-tw-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
    margin: 0;
    cursor: pointer;
}

#dca-sim-wrapper .af-tw-check input[type="checkbox"] {
    margin: 0 !important;
    padding: 0 !important;
}

#dca-sim-wrapper .cell-tw:has(.asset-can-rebalance:not(:checked)) .asset-rebalance-target-weight,
#dca-sim-wrapper .cell-tw-alt:has(.asset-can-rebalance-mirror:not(:checked)) .asset-rebalance-target-weight-mirror {
    color: #a1a1aa;
}

/* --- asset settings (▼) --- */
#dca-sim-wrapper .asset-details-box {
    margin: 8px 0 2px;
    padding: 12px;
    background: #fafafa;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

#dca-sim-wrapper .asset-details-box .asset-field {
    background: #ffffff;
}

#dca-sim-wrapper .ad-label {
    display: block;
    margin: 0 0 4px 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

#dca-sim-wrapper .asset-check {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    min-width: 0;
    min-height: 30px;
    margin: 0;
    padding: 6px 0 4px;
    box-sizing: border-box;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.3;
    color: #3f3f46;
    /* Long names (Short-history penalty) wrap onto a second line on
       phones instead of being cut off. */
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
}

#dca-sim-wrapper .asset-check input[type="checkbox"] {
    flex: none;
    margin: 2px 0 0 !important;
    padding: 0 !important;
}

#dca-sim-wrapper .asset-st {
    margin-top: 6px;
}

/* "S.T. ▾" line: collapsed by default, opens the per-asset stress tests. */
#dca-sim-wrapper .asset-st-title {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 2px 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: inherit !important;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

/* Dashed line on both sides, so the pill sits in the centre — away from
   the ✖ at the right of the row above. */
#dca-sim-wrapper .asset-st-title::before,
#dca-sim-wrapper .asset-st-title::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--border-subtle);
}

#dca-sim-wrapper .asset-st-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    line-height: 1.2;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: #ffffff;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    transition: border-color 0.15s, color 0.15s;
}

#dca-sim-wrapper .asset-st-chev {
    display: inline-block;
    font-size: 10px;
    transition: transform 0.3s ease;
}

#dca-sim-wrapper .asset-st-title.is-open .asset-st-chev {
    transform: rotate(180deg);
}

#dca-sim-wrapper .asset-st-title.is-open .asset-st-pill,
#dca-sim-wrapper .asset-st-title:focus-visible .asset-st-pill {
    border-color: #c7d2fe;
    color: #4f46e5;
}

@media (hover: hover) {
    #dca-sim-wrapper .asset-st-title:hover .asset-st-pill {
        border-color: #c7d2fe;
        color: #4f46e5;
    }
}

/* No thick theme focus ring on the S.T. line or the ▼ / ✖ buttons after a
   click. Keyboard users still get a light indigo ring (and the S.T. pill
   turns indigo). */
#dca-sim-wrapper .asset-st-title:focus,
#dca-sim-wrapper .asset-st-title:focus-visible,
#dca-sim-wrapper .asset-head .asset-actions .button:focus {
    outline: none !important;
    box-shadow: none !important;
}

#dca-sim-wrapper .asset-head .asset-actions .button:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 1px;
}

#dca-sim-wrapper .asset-st-body .asset-st-grid {
    padding-top: 4px;
}

#dca-sim-wrapper .asset-st-grid {
    row-gap: 2px;
}

#dca-sim-wrapper .asset-st-grid .fixed-rate-warning {
    grid-column: 1 / -1;
    margin: 2px 0;
    font-size: 0.85em;
    font-style: italic;
    color: var(--text-muted);
}

/* New-card animation covers the new head and main row too. */
.asset-row-animate .asset-head,
.asset-row-animate .asset-main {
    opacity: 0;
    animation: fadeInContent 0.2s ease forwards;
    animation-delay: 0.2s;
}


/* =======================================================
   🌟 USER SETTINGS — one bar: Invest | Hold | Retire
   No outer box and no title: the bar and Withdraw run the full
   width of the form. Ages are typed into the boxes on the bar; positions
   are set by dcasimRenderUserTimeline(). Invest/Retire labels above,
   Hold below.
   One row (wide): bar 75% | Withdraw 25%, both 80px tall with
   their rows lined up (label / box / hint). Narrow: withdraw under the bar,
   close to it so both rows read as one section.
   ======================================================= */
#dca-sim-wrapper > .dcasim-user-settings {
    margin: 0 0 14px;
    padding: 0;               /* wins over the phone rule for > div */
}

#dca-sim-wrapper .dcasim-user-settings .us-layout {
    container-type: inline-size;
    container-name: dcasim-us;
}

#dca-sim-wrapper .us-lab {
    position: relative;
    height: 20px;
    font-size: 15px;
    line-height: 20px;
}

#dca-sim-wrapper .us-lab > span {
    position: absolute;
    top: 0;
    white-space: nowrap;
}

#dca-sim-wrapper .us-lab b {
    font-weight: 600;
}

/* "buy" / "sell" after the years */
#dca-sim-wrapper .us-lab .us-act {
    font-weight: 400;
    opacity: 0.7;
}

#dca-sim-wrapper .us-lab-inv { color: #4f46e5; }
#dca-sim-wrapper .us-lab-ret { color: #0f766e; }
#dca-sim-wrapper .us-lab-hold { color: var(--text-muted); }

#dca-sim-wrapper .us-bar {
    position: relative;
    height: 34px;
    margin: 3px 0;
}

#dca-sim-wrapper .us-track {
    position: absolute;
    inset: 0;
    display: flex;
    gap: 2px;
    border-radius: 10px;
    overflow: hidden;
}

#dca-sim-wrapper .us-seg {
    display: block;
    height: 100%;
    flex-basis: 0;
    min-width: 0;
}

#dca-sim-wrapper .us-seg-inv { background: var(--accent-gradient); }
#dca-sim-wrapper .us-seg-ret { background: #14b8a6; }
#dca-sim-wrapper .us-seg-hold {
    /* Stripes in a lighter tint of the Invest colour. */
    background: repeating-linear-gradient(-45deg, #a78bfa 0 3px, #f4f4f5 3px 6px);
}

/* The four age boxes on the bar (2 digits). Each is a .us-age-box: the
   age and its up / down buttons in one white pill, the same size on every
   screen. The JS moves the box along the bar and reads its width.
   16px stops iPhones zooming. */
#dca-sim-wrapper .us-bar .us-age-box {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    align-items: stretch;
    width: 56px;
    height: 26px;
    background: #ffffff;
    border-radius: 7px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
    /* Never animate the position: the boxes would slide into place when the
       form is restored, e.g. on coming back from the result page. */
    transition: box-shadow 0.15s ease;
}

#dca-sim-wrapper .us-bar .us-age-box:focus-within {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px rgba(79, 70, 229, 0.55);
}

#dca-sim-wrapper .us-bar input.us-age {
    position: static;
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 26px !important;
    margin: 0 !important;
    padding: 0 0 0 3px !important;
    border: 0 !important;
    border-radius: 7px 0 0 7px !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--text-main) !important;
    font-size: 16px;
    font-weight: 600;
    line-height: 26px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

#dca-sim-wrapper .us-bar input.us-age::-webkit-inner-spin-button,
#dca-sim-wrapper .us-bar input.us-age::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* The bar, its labels and the ages stay hidden until the JavaScript has
   laid them out once (it adds .us-ready), so the boxes are never seen at
   their starting spot. If the script never runs, they appear after 1.5 s. */
#dca-sim-wrapper .us-timeline:not(.us-ready) {
    visibility: hidden;
    animation: dcasimUsReveal 0s linear 1.5s forwards;
}

@keyframes dcasimUsReveal {
    to { visibility: visible; }
}


/* Ages out of order: grey bar, red message. */
#dca-sim-wrapper .us-invalid .us-track {
    filter: grayscale(1);
    opacity: 0.55;
}

/* "Check ages" message, in the row under the bar. */
#dca-sim-wrapper .us-lab .us-lab-error {
    color: #dc2626;
}

/* Withdraw: in-field label when narrow, label above when wide.
   Box is 34px tall, the same as the bar. */
#dca-sim-wrapper .us-withdraw {
    margin-top: 1px;
}

#dca-sim-wrapper .us-withdraw .asset-field {
    height: 34px;
    padding: 0 10px;
}

#dca-sim-wrapper .us-wd-label {
    display: none;
    margin: 0 0 3px 2px;
    height: 20px;
    line-height: 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dca-sim-wrapper .us-wd-tag {
    font-size: 15px;
}

#dca-sim-wrapper .us-wd-hint {
    margin: 3px 2px 0 0;
    text-align: right;           /* under the end of the Withdraw box, at every width */
    height: 20px;
    line-height: 20px;
    font-size: 15px;
    font-style: italic;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* One row from 560px: below that the 25% column is too narrow for
   "$ 150000 /m" with its step arrows and for "In today's money". */
@container dcasim-us (min-width: 560px) {
    #dca-sim-wrapper .us-grid {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
        column-gap: 12px;
        align-items: start;
    }

    #dca-sim-wrapper .us-withdraw {
        margin-top: 0;
    }

    #dca-sim-wrapper .us-withdraw .asset-field {
        padding: 0 8px;
    }

    /* One row: "Withdraw" and "In today's money" line up with the
       right edge of the box. */
    #dca-sim-wrapper .us-wd-label {
        display: block;
        margin-left: 0;
        margin-right: 2px;
        text-align: right;
    }


    #dca-sim-wrapper .us-wd-tag {
        display: none;
    }
}


/* =======================================================
   🌟 TARGET-WEIGHT BAR (Rebalance on)
   One coloured slice per asset, sized by its T.W.
   ======================================================= */
#dca-sim-wrapper .dcasim-tw-strip {
    display: flex;
    gap: 2px;
    height: 22px;
    margin: 0 0 10px;
    border-radius: 7px;
    overflow: hidden;
}

#dca-sim-wrapper .dcasim-tw-strip[hidden] {
    display: none !important;
}

#dca-sim-wrapper .dcasim-tw-strip.is-over {
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

#dca-sim-wrapper .dcasim-tw-strip .tw-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-basis: 0;
    min-width: 0;
    overflow: hidden;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* A label that does not fit its slice is cut off (no JS measuring). */
#dca-sim-wrapper .dcasim-tw-strip .tw-seg > span {
    overflow: hidden;
    text-overflow: clip;
    padding: 0 3px;
}

#dca-sim-wrapper .dcasim-tw-strip .tw-gap {
    background: repeating-linear-gradient(-45deg, #fde68a 0 5px, #fffbeb 5px 10px);
    color: #92400e;
}


/* =======================================================
   🌟 PHONES: the form uses (nearly) the full screen width
   Pulls the form out over the theme's side padding, leaving 6px. Uses
   WordPress's root padding variable; if a theme does not set it, nothing
   changes.
   ======================================================= */
@media (max-width: 600px) {
    #dca-sim-wrapper {
        --dcasim-bleed-left: max(0px, calc(var(--wp--style--root--padding-left, 0px) - 6px));
        --dcasim-bleed-right: max(0px, calc(var(--wp--style--root--padding-right, 0px) - 6px));
        width: auto;
        margin-left: calc(-1 * var(--dcasim-bleed-left));
        margin-right: calc(-1 * var(--dcasim-bleed-right));
    }

    #dca-sim-wrapper fieldset {
        padding: 14px 12px;
        border-radius: 14px;
    }

    /* Agreement line and Back / Run / Reset keep a small inner margin. */
    #dca-sim-wrapper > div {
        padding-left: 6px;
        padding-right: 6px;
    }
}

/* 🌟 No assets yet: a quiet prompt where the cards will appear */
#dca-sim-wrapper #assets-container:empty::before {
    content: "No assets yet. Tap + to add one.";
    display: block;
    padding: 12px 0;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-muted);
}


/* =======================================================
   🌟 ADD ASSET WINDOW (modal)
   Appended to <body>, outside #dca-sim-wrapper, so it is styled on its own
   id. !important only where WordPress themes commonly restyle buttons and
   inputs.
   ======================================================= */
html.dcasim-modal-open,
html.dcasim-modal-open body {
    overflow: hidden !important;
}

#dcasim-asset-modal {
    position: fixed;
    inset: 0;
    z-index: 999990;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10vh 16px 16px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #09090b;
    text-align: left;
}

#dcasim-asset-modal[hidden] {
    display: none !important;
}

#dcasim-asset-modal *,
#dcasim-asset-modal *::before,
#dcasim-asset-modal *::after {
    box-sizing: border-box;
}

#dcasim-asset-modal .dcasim-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 11, 0.45);
}

#dcasim-asset-modal .dcasim-modal-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Same width as the Dividend window (an asset row's Div button). */
    max-width: 400px;
    /* One fixed height for both steps: the window never grows or shrinks. */
    height: 620px;
    max-height: calc(90vh - 16px);
    max-height: calc(90dvh - 16px);
    padding: 18px 20px 16px;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    animation: dcasimModalIn 0.18s ease;
}

#dcasim-asset-modal .dcasim-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* Add Asset: bring the Ticker label closer to the modal heading. */
#dcasim-asset-modal:not(.is-div-mode) .dcasim-modal-head {
    margin-bottom: 6px;
}

#dcasim-asset-modal .dcasim-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    color: #09090b;
}

#dcasim-asset-modal .dcasim-modal-x {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 -8px 0 0 !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #71717a !important;
    font-size: 24px !important;
    line-height: 1 !important;
    cursor: pointer;
}

#dcasim-asset-modal .dcasim-modal-x:hover {
    background: #f4f4f5 !important;
    color: #09090b !important;
}

#dcasim-asset-modal .dcasim-modal-label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 500;
    color: #71717a;
}

/* 16px stops iOS from zooming the page when the field is focused. */
#dcasim-asset-modal .dcasim-modal-input {
    display: block;
    width: 100% !important;
    max-width: none !important;
    height: 46px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #09090b !important;
    background: #fafafa !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    outline: none !important;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

#dcasim-asset-modal .dcasim-modal-input::placeholder {
    text-transform: none;
    letter-spacing: 0;
    color: #a1a1aa;
}

#dcasim-asset-modal .dcasim-modal-input:focus {
    background: #ffffff !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

#dcasim-asset-modal .dcasim-modal-input:disabled {
    opacity: 0.6;
}

/* Spinner: in front of "Searching…" and inside the ticker box (right). */
#dcasim-asset-modal .dcasim-spin{
    display: inline-block;
    width: 14px;
    height: 14px;
    flex: none;
    border: 2px solid #c7d2fe;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: dcasimSpin 0.7s linear infinite;
}

@keyframes dcasimSpin {
    to { transform: rotate(360deg); }
}

#dcasim-asset-modal .dcasim-modal-status.is-busy {
    display: flex;
    align-items: center;
    gap: 7px;
}

#dcasim-asset-modal .dcasim-search-wrap {
    position: relative;
}

#dcasim-asset-modal .dcasim-search-wrap .dcasim-modal-input {
    padding-right: 40px !important;
}

#dcasim-asset-modal .dcasim-search-spin {
    position: absolute;
    right: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    visibility: hidden;
}

#dcasim-asset-modal.is-searching .dcasim-search-spin {
    visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
    #dcasim-asset-modal .dcasim-spin{
        animation-duration: 1.6s;
    }
}

/* Monthly amount: [−] [$ 1000 /m] [+] */
#dcasim-asset-modal .dcasim-modal-label-gap {
    margin-top: 6px;
}

#dcasim-asset-modal .dcasim-stepper {
    display: flex;
    align-items: center;
    gap: 10px;
}

#dcasim-asset-modal .dcasim-step-btn {
    flex: none;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1px solid #e4e4e7 !important;
    background: #ffffff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
    color: #71717a !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Hover colour only with a mouse: on phones it would stay lit after a tap. */
@media (hover: hover) {
    #dcasim-asset-modal .dcasim-step-btn:hover:not(:disabled) {
        background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
        border-color: transparent !important;
        color: #ffffff !important;
    }
}

#dcasim-asset-modal .dcasim-step-btn:active:not(:disabled) {
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
    color: #4f46e5 !important;
}

#dcasim-asset-modal .dcasim-step-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

#dcasim-asset-modal .dcasim-step-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 12px;
    background: #fafafa;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

#dcasim-asset-modal .dcasim-step-field:focus-within {
    background: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

#dcasim-asset-modal .dcasim-step-affix {
    flex: none;
    font-size: 15px;
    color: #a1a1aa;
}

#dcasim-asset-modal .dcasim-step-field input[type="number"] {
    flex: 1 1 auto;
    width: 100% !important;
    min-width: 0;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    font-size: 17px !important;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #09090b !important;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* The − / + buttons replace the browser's own arrows here. */
#dcasim-asset-modal .dcasim-step-field input[type="number"]::-webkit-inner-spin-button,
#dcasim-asset-modal .dcasim-step-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#dcasim-asset-modal .dcasim-modal-status {
    min-height: 18px;
    margin: 10px 0 6px;
    font-size: 13px;
    line-height: 1.4;
    color: #71717a;
}

#dcasim-asset-modal .dcasim-modal-status.is-error {
    color: #dc2626;
}

#dcasim-asset-modal .dcasim-modal-results {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid #e4e4e7;
}

#dcasim-asset-modal .dcasim-modal-results:empty {
    border-top: 0;
}

#dcasim-asset-modal .dcasim-result {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    margin: 0 !important;
    padding: 8px 2px !important;
    border-bottom: 1px solid #f0f0f2;
    list-style: none !important;
}

#dcasim-asset-modal .dcasim-result::before,
#dcasim-asset-modal .dcasim-result::marker {
    content: none;
}

#dcasim-asset-modal .dcasim-result-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

#dcasim-asset-modal .dcasim-result-ticker {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: #09090b;
    overflow-wrap: anywhere;
}

#dcasim-asset-modal .dcasim-result-name {
    font-size: 13px;
    line-height: 1.35;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dcasim-asset-modal .dcasim-result-yahoo .dcasim-result-name {
    white-space: normal;
}

/* Add / Check & Add: at least 44px tall for a comfortable tap. */
#dcasim-asset-modal .dcasim-result-btn {
    flex: 0 0 auto;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 72px !important;
    min-height: 44px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 16px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    white-space: nowrap;
    color: #4f46e5 !important;
    background: #ffffff !important;
    border: 1px solid #4f46e5 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

#dcasim-asset-modal .dcasim-result-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}

#dcasim-asset-modal .dcasim-result-btn:disabled {
    color: #a1a1aa !important;
    background: #f4f4f5 !important;
    border-color: #e4e4e7 !important;
    cursor: default;
}

#dcasim-asset-modal .dcasim-result-btn.is-loading {
    color: #4f46e5 !important;
    background: #ffffff !important;
    border-color: #4f46e5 !important;
    cursor: progress;
}

/* Footer: Add in the centre, Cancel on the right (Add is hidden in step 1). */
#dcasim-asset-modal .dcasim-modal-foot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding-top: 12px;
}

#dcasim-asset-modal .dcasim-modal-foot .dcasim-modal-cancel {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}

#dcasim-asset-modal .dcasim-modal-foot .dcasim-modal-add {
    grid-column: 2;
    grid-row: 1;
}

#dcasim-asset-modal .dcasim-modal-cancel {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 44px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 18px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    text-transform: none !important;
    color: #a1a1aa !important;
    background: #ffffff !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    cursor: pointer;
}

#dcasim-asset-modal .dcasim-modal-foot .dcasim-modal-add,
#dcasim-asset-modal .dcasim-modal-foot .dcasim-modal-cancel {
    height: 46px !important;
    min-height: 46px !important;
    box-sizing: border-box !important;
}

#dcasim-asset-modal .dcasim-modal-cancel:hover {
    color: #71717a !important;
    background: #fafafa !important;
    border-color: #a1a1aa !important;
}

/* ---------- Two steps (Select ticker → Dividend → Add) ---------- */

/* Themes sometimes override [hidden]; the steps depend on it. */
#dcasim-asset-modal [hidden] {
    display: none !important;
}

/* Ticker slot: the search box (step 1) and the locked label (step 2) share
   one 46px row, so switching steps moves nothing below them. */
#dcasim-asset-modal .dcasim-ticker-slot {
    height: 46px;
}

#dcasim-asset-modal .dcasim-locked {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 4px 0 12px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
}

#dcasim-asset-modal .dcasim-locked-text {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

#dcasim-asset-modal .dcasim-locked-ticker {
    flex: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #4f46e5;
}

#dcasim-asset-modal .dcasim-locked-name {
    min-width: 0;
    font-size: 13px;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dcasim-asset-modal .dcasim-locked-change {
    flex: none;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 0 !important;
    min-height: 36px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 12px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-transform: none !important;
    color: #4f46e5 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    cursor: pointer;
}

#dcasim-asset-modal .dcasim-locked-change:hover {
    background: #e0e7ff !important;
}

/* Lower area: results list (step 1) or dividend panel (step 2). It takes
   whatever height is left, the same in both steps, and scrolls inside. */
#dcasim-asset-modal .dcasim-modal-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Step 2 has no search status: give its line back to the dividend panel. */
#dcasim-asset-modal.is-step-2 .dcasim-modal-status {
    display: none;
}

#dcasim-asset-modal.is-step-2 .dcasim-div-panel {
    margin-top: 14px;
}

#dcasim-asset-modal .dcasim-div-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid #e4e4e7;
}

#dcasim-asset-modal .dcasim-div-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-height: 20px;
}

#dcasim-asset-modal .dcasim-div-head .dcasim-modal-label {
    margin: 0;
}

#dcasim-asset-modal .dcasim-div-warn {
    font-size: 12px;
    font-weight: 400;
    color: #a1a1aa;
}

/* Spinner + "Getting dividend…" sits in the note line under the choices. */
#dcasim-asset-modal .dcasim-div-loading {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

/* A small table: row label | Min | Median, rows 10-year and All years,
   then Average of all years across all three columns. The headings name
   each number, so the number buttons show the value only. */
#dcasim-asset-modal .dcasim-div-choices{
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    align-items: stretch;
}

#dcasim-asset-modal .dcasim-div-colhead{
    align-self: end;
    margin-bottom: -2px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    color: #71717a;
    text-align: center;
}

#dcasim-asset-modal .dcasim-div-rowlabel{
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    color: #3f3f46;
}

/* The years "All years" covers, under its label ("2007–2025"): Yahoo's
   history can start after the real listing. */
#dcasim-asset-modal .dcasim-div-rowyears{
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: #71717a;
    white-space: nowrap;
}

/* Two rows of numbers plus Average fit the Add-asset window's fixed height,
   so the number buttons keep the full 44px tap target. */
#dcasim-asset-modal .dcasim-div-choice.is-num{
    justify-content: center;
    min-height: 44px !important;
    padding: 0 8px !important;
}

#dcasim-asset-modal .dcasim-div-choice{
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0 !important;
    min-height: 44px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 14px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    line-height: 1.15 !important;
    background: #ffffff !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

/* Labels may wrap to two lines on narrow screens (the 44px button height
   holds them); the value never wraps. */
#dcasim-asset-modal .dcasim-div-choice-label{
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: #71717a;
    white-space: normal;
    text-align: left;
}

#dcasim-asset-modal .dcasim-div-choice-value{
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #09090b;
    white-space: nowrap;
}

#dcasim-asset-modal .dcasim-div-choice.is-avg{
    grid-column: 1 / -1;
    background: #fafafa !important;
    margin-bottom: 6px !important; /* Small gap before the four yield choices */
}

/* "Tap one or more to average them." — under the four yields, above the % box. */
#dcasim-asset-modal .dcasim-div-hint{
    grid-column: 1 / -1;
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: #71717a;
}

@media (hover: hover) {
    #dcasim-asset-modal .dcasim-div-choice:hover:not(:disabled){
        border-color: #4f46e5 !important;
    }
}

#dcasim-asset-modal .dcasim-div-choice.is-selected{
    background: #eef2ff !important;
    border-color: #4f46e5 !important;
}

#dcasim-asset-modal .dcasim-div-choice.is-selected .dcasim-div-choice-value{
    color: #4f46e5;
}

#dcasim-asset-modal .dcasim-div-choice:disabled{
    cursor: default;
    opacity: 0.55;
}

#dcasim-asset-modal .dcasim-div-note {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 18px;
    font-size: 13px;
    line-height: 1.4;
    color: #71717a;
}

#dcasim-asset-modal .dcasim-div-note.is-error {
    color: #dc2626;
}

/* Under the dividend % box: Add asset and the row Dividend popup. */
#dcasim-asset-modal .dcasim-div-disclaimer {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #71717a;
    text-align: center;
}

/* Loading: a spinner in each of the four number cells. */
#dcasim-asset-modal .dcasim-div-choice-value .dcasim-spin {
    display: block;
    width: 16px;
    height: 16px;
}

/* Dividend mode (an asset row's Div button): the same window without
   Invest / m and Change, and only as tall as its content. */
#dcasim-asset-modal.is-div-mode .dcasim-add-only,
#dcasim-asset-modal.is-div-mode .dcasim-locked-change {
    display: none !important;
}

#dcasim-asset-modal.is-div-mode .dcasim-modal-panel {
    height: auto;
}

#dcasim-asset-modal.is-div-mode .dcasim-div-panel {
    flex: none;
}

/* Add: same colours as Run Simulation. */
#dcasim-asset-modal .dcasim-modal-add {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 44px !important;
    min-width: 140px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 22px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-transform: none !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
    border: 0 !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25) !important;
    cursor: pointer;
}

#dcasim-asset-modal .dcasim-modal-add:hover:not(:disabled) {
    filter: brightness(1.06);
}

/* Not ready yet (no ticker locked, dividend still loading): same look as a
   locked Run Simulation button. */
#dcasim-asset-modal .dcasim-modal-add:disabled {
    opacity: 0.6;
    box-shadow: none !important;
    filter: none;
    cursor: default;
}

/* Narrow phones: a little less padding inside the choices. */
@media (max-width: 400px) {
    #dcasim-asset-modal .dcasim-div-choice{
        padding: 0 10px !important;
    }
}

#dcasim-asset-modal button:focus-visible {
    outline: 2px solid #4f46e5 !important;
    outline-offset: 2px;
}

/* Short screens (laptops, zoomed browsers): smaller gap above the window
   instead of a shorter window. */
@media (max-height: 760px) and (min-width: 601px) {
    #dcasim-asset-modal {
        padding-top: 16px;
    }

    #dcasim-asset-modal .dcasim-modal-panel {
        max-height: calc(100vh - 32px);
        max-height: calc(100dvh - 32px);
    }
}

/* Phones: same 620px height as desktop (shorter only if the screen is),
   full width, anchored near the top so the keyboard covers less of it. */
@media (max-width: 600px) {
    #dcasim-asset-modal {
        padding: 5vh 8px 8px;
    }

    #dcasim-asset-modal .dcasim-modal-panel {
        max-width: none;
        max-height: calc(95vh - 8px);
        max-height: calc(95dvh - 8px);
        padding: 14px 14px 12px;
        border-radius: 14px;
    }
}

@keyframes dcasimModalIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    #dcasim-asset-modal .dcasim-modal-panel {
        animation: none;
    }
}


/* =======================================================
   🌟 Column headings (one-line asset layout only)
   ======================================================= */
#dca-sim-wrapper .asset-colhead {
    align-items: end;
    padding: 0 0 5px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--text-muted);
    white-space: nowrap;
}

#dca-sim-wrapper .asset-colhead .ch-month { grid-column: 2; padding-left: 2px; }
#dca-sim-wrapper .asset-colhead .ch-div   { grid-column: 3; padding-left: 2px; }
#dca-sim-wrapper .asset-colhead .ch-tw    { grid-column: 4; padding-left: 2px; overflow: hidden; text-overflow: ellipsis; }

/* =======================================================
   🌟 Asset settings: ✖ (remove asset) on the last row before S.T.
   The two checkboxes and ✖ share one row that uses the same columns as
   the rest of the settings. ✖ always sits in the last column, at the
   right: alone in the empty third column on 3 columns, beside "Dividend
   reinvest" on 2 columns. The head line keeps only ▼, at the right.
   ======================================================= */
#dca-sim-wrapper .asset-check-row {
    grid-column: 1 / -1;
}

#dca-sim-wrapper .asset-check-row > .asset-check {
    justify-self: start;
    grid-row: 1;
}

/* Placed explicitly, so ✖ (also explicit) can share column 2 on phones
   instead of pushing "Dividend reinvest" to a row of its own. */
#dca-sim-wrapper .asset-check-row > .asset-check:nth-of-type(1) { grid-column: 1; }
#dca-sim-wrapper .asset-check-row > .asset-check:nth-of-type(2) { grid-column: 2; }

#dca-sim-wrapper .asset-check-row > .btn-remove-icon {
    grid-column: -2 / -1;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    padding: 6px 8px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    min-width: auto !important;
    height: auto !important;
    color: #991b1b !important;
}

@media (hover: hover) {
    #dca-sim-wrapper .asset-check-row > .btn-remove-icon:hover {
        background: #fef2f2 !important;
        border-color: #fca5a5 !important;
        color: #7f1d1d !important;
    }
}

#dca-sim-wrapper .asset-check-row > .btn-remove-icon:focus {
    outline: none !important;
    box-shadow: none !important;
}

#dca-sim-wrapper .asset-check-row > .btn-remove-icon:focus-visible {
    outline: 2px solid #fca5a5 !important;
    outline-offset: 1px;
}

/* 2 columns: ✖ shares the second column with "Dividend reinvest". */
#dca-sim-wrapper .asset-check-row > .asset-check:nth-of-type(2) {
    max-width: calc(100% - 34px);
}

/* list min-width: 470px (class .cq-470) */
#dca-sim-wrapper .dcasim-assets-wrap.cq-470 .asset-check-row > .asset-check:nth-of-type(2) {
        max-width: none;
    }


/* Guests see no fees or checkboxes, so that row would be empty: ✖ moves
   up into the Existing row instead (last column, level with the box).
   Guests never have Rebalance, so the hidden Dividend slot is free. */
#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .asset-check-row,
#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .asset-details-grid .cell-div-alt {
    display: contents;
}

#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .asset-details-grid .cell-div-alt > * {
    display: none;
}

#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .asset-check-row > .btn-remove-icon {
    grid-row: 1;
    align-self: end;
    margin-bottom: 7px;
}

/* Guests on a narrow list: the Dividend box takes the slot beside
   Existing, so ✖ goes to the row below it, at the right. */
/* list max-width: 427px (class :not(.cq-428)) */
#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .dcasim-assets-wrap:not(.cq-428) .asset-details-grid .cell-div-alt {
        display: block;
    }

#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .dcasim-assets-wrap:not(.cq-428) .asset-details-grid .cell-div-alt > .ad-label {
        display: block;
    }

#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .dcasim-assets-wrap:not(.cq-428) .asset-details-grid .cell-div-alt > .cell-div-line {
        display: flex;
    }

#dca-sim-wrapper:not(.dsfm):not(.debug-ignore-css) .dcasim-assets-wrap:not(.cq-428) .asset-check-row > .btn-remove-icon {
        grid-row: 2;
        align-self: center;
        margin-bottom: 0;
    }


/* ▼ alone at the right of the head line, at every width. */
#dca-sim-wrapper .asset-head .asset-actions {
    justify-self: end;
    justify-content: flex-end;
}


/* =======================================================
   🌟 Hold lock: a small checkbox after "Hold N yrs" under the bar.
   Ticked, Sell − Hold stays fixed (see the JS age rules).
   ======================================================= */
#dca-sim-wrapper .us-hold-lock {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    vertical-align: -2px;
    cursor: pointer;
}

/* Quiet: small, grey when ticked (not the browser's blue), a little
   faded until the pointer is over it. */
#dca-sim-wrapper .us-hold-lock input[type="checkbox"] {
    width: 12px;
    height: 12px;
    margin: 0 !important;
    accent-color: #a1a1aa;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.15s;
}

#dca-sim-wrapper .us-hold-lock:hover input[type="checkbox"],
#dca-sim-wrapper .us-hold-lock input[type="checkbox"]:focus-visible {
    opacity: 1;
}

/* Hidden while the ages are out of order (the message takes the line). */
#dca-sim-wrapper .us-lab-error .us-hold-lock {
    display: none;
}

#dca-sim-wrapper .us-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Hold box when Hold = Sell and the lock is ticked: hidden in place, so
   nothing else moves. */
#dca-sim-wrapper .us-bar .us-age-box.us-age-hidden {
    visibility: hidden;
    pointer-events: none;
}


/* =======================================================
   🌟 Number box up / down buttons (.dcasim-nudge)
   Ages, Withdraw and every number box in an asset row, in place of the
   browser's own arrows, right after the number (where those arrows were).
   Shown with a mouse; hidden on phones and tablets (see the end of this
   block). !important only where themes restyle buttons.
   ======================================================= */
#dca-sim-wrapper .dcasim-nudge {
    flex: none;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    width: 14px;
    margin: 3px 0 3px -2px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#dca-sim-wrapper .dcasim-nudge button {
    flex: 1 1 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 5px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #a1a1aa !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-transform: none !important;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#dca-sim-wrapper .dcasim-nudge svg {
    display: block;
    width: 10px;
    height: 6px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (hover: hover) {
    #dca-sim-wrapper .dcasim-nudge button:hover {
        background: #eef2ff !important;
        color: #4f46e5 !important;
    }
}

#dca-sim-wrapper .dcasim-nudge button:active {
    background: #e0e7ff !important;
    color: #4f46e5 !important;
}

/* Age pill: a narrow column inside the white box. */
#dca-sim-wrapper .us-age-box .dcasim-nudge {
    width: 16px;
    margin: 2px 2px 2px 0;
}

#dca-sim-wrapper .us-age-box .dcasim-nudge button {
    border-radius: 4px !important;
}

#dca-sim-wrapper .us-age-box .dcasim-nudge svg {
    width: 9px;
    height: 5px;
}

/* Phones and tablets only — a device whose main input is a finger (no
   hover, coarse pointer): no up / down buttons on any number box (too small
   to hit reliably; typing is quicker). The boxes keep ↑ / ↓ keys. The age
   pills shrink back to the width of two digits; the JS reads their width.
   A computer with a mouse always keeps the buttons, even in a narrow or
   zoomed window and on a touchscreen laptop. (The old rule also hid them
   at 600px or less, which a zoomed desktop window can reach.) */
@media (hover: none) and (pointer: coarse) {
    #dca-sim-wrapper .dcasim-nudge {
        display: none;
    }

    #dca-sim-wrapper .us-bar .us-age-box {
        width: 46px;
    }

    #dca-sim-wrapper .us-bar input.us-age {
        padding: 0 !important;
        border-radius: 7px !important;
    }
}


/* =======================================================
   🌟 Sections past the theme's column (DCASim Options → Layout)
   Assets at every width; Advanced Features and Stress Tests on phones
   only (600px and less). The JS sets the width and side margins.
   Touching both edge margins: no side border, corners or side padding,
   so the content uses the width. The legend and the top / bottom lines
   stay.
   ======================================================= */
#dca-sim-wrapper fieldset.is-edge {
    border-left-width: 0;
    border-right-width: 0;
    border-radius: 0;
    padding-left: 12px;
    padding-right: 12px;
    box-shadow: none;
}

/* Phones (600px and less): the same full width in CSS alone, for Assets,
   Advanced Features and Stress Tests (each fieldset with data-full-width,
   which the PHP prints only while "Assets full width" is on). The section
   reaches the screen minus --dcasim-edge on each side; min() keeps it from
   ever getting narrower than the theme's column. 50% is half the parent's
   width, so this assumes the form is centred on the screen, as themes do on
   phones. No JavaScript measures or resizes anything here. */
@media (max-width: 600px) {
    #dca-sim-wrapper fieldset[data-full-width="1"] {
        margin-left: min(0px, calc(50% - 50vw + var(--dcasim-edge, 8px))) !important;
        margin-right: min(0px, calc(50% - 50vw + var(--dcasim-edge, 8px))) !important;
        width: auto !important;
        max-width: none !important;
        border-left-width: 0;
        border-right-width: 0;
        border-radius: 0;
        padding-left: 12px;
        padding-right: 12px;
        box-shadow: none;
    }

    #dca-sim-wrapper fieldset[data-full-width="1"] > legend {
        margin-left: 0;
        padding-left: 0;
    }

    #dca-sim-wrapper fieldset[data-full-width="1"] .asset-color-dot {
        position: static;
        flex: 0 0 auto;
        margin-top: 0;
    }
}

/* Edge mode has no side border, so the colour square does not hang in the
   padding (it would touch the screen edge): it sits in line, before the
   ticker, starting at the content edge like the boxes below it. */
#dca-sim-wrapper fieldset.dcasim-assets-section.is-edge .asset-color-dot {
    position: static;
    flex: 0 0 auto;
    margin-top: 0;
}

#dca-sim-wrapper fieldset.is-edge > legend {
    margin-left: 0;
    padding-left: 0;
}

/* =======================================================
   🌟 Stress Test Presets (Mild / Moderate / Severe / Extreme)
   Four equal-width outline buttons; the selected one is indigo.
   A locked button (no capability) uses the shared .is-locked look.
   ======================================================= */
#dca-sim-wrapper .dcasim-preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

/* "Not sure which to pick? Moderate is recommended ..." under the buttons.
   Same look as the note under Withdraw Dynamic. */
#dca-sim-wrapper .dcasim-preset-note {
    margin: 8px 0 0;
    color: #777;
    font-size: 0.82em;
    line-height: 1.4;
    font-style: italic;
}

#dca-sim-wrapper .dcasim-preset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 8px 6px;
    border: 1px solid var(--border-subtle, #e4e4e7);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-main, #09090b);
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 400 !important;   /* themes bold buttons; only the selected preset is bold */
    line-height: 1.3;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: none;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

#dca-sim-wrapper .dcasim-preset-btn:hover:not(:disabled) {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #ffffff;
}

#dca-sim-wrapper .dcasim-preset-btn.is-selected {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600 !important;
}

#dca-sim-wrapper .dcasim-preset-btn:disabled { cursor: default; }

/* Outline star before the recommended preset's label (Moderate). It sits
   inside the label, so it hides with the label on phones while loading,
   and follows the button's text colour (hover / selected). */
#dca-sim-wrapper .dcasim-preset-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
#dca-sim-wrapper .dcasim-preset-star {
    flex: 0 0 auto;
    width: 0.95em;
    height: 0.95em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
}

/* Spinner after the label, shown for 1 s after a click. */
#dca-sim-wrapper .dcasim-preset-spinner {
    display: none;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 12px;
    height: 12px;
    border: 2px solid #c7d2fe;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: dcasimSpin 0.7s linear infinite;
}

#dca-sim-wrapper .dcasim-preset-btn.is-loading .dcasim-preset-spinner { display: inline-block; }
#dca-sim-wrapper .dcasim-preset-btn.is-loading { border-color: #4f46e5; color: #4f46e5; }

@media (max-width: 420px) {
    #dca-sim-wrapper .dcasim-preset-buttons { gap: 6px; }
    #dca-sim-wrapper .dcasim-preset-btn { gap: 3px; padding: 8px 2px; font-size: 0.8em; }
    #dca-sim-wrapper .dcasim-preset-spinner { width: 10px; height: 10px; }
    #dca-sim-wrapper .dcasim-preset-label { gap: 2px; }
}

/* Very narrow phones: no room for the star beside "Moderate". */
@media (max-width: 340px) {
    #dca-sim-wrapper .dcasim-preset-star { display: none; }
}

/* Phones: "Moderate" plus a spinner no longer fits a quarter of the width,
   so the spinner shows in place of the label while it runs. The label keeps
   its space, so the button does not change size. */
@media (max-width: 400px) {
    #dca-sim-wrapper .dcasim-preset-btn { position: relative; }
    #dca-sim-wrapper .dcasim-preset-btn.is-loading .dcasim-preset-label { visibility: hidden; }
    #dca-sim-wrapper .dcasim-preset-btn.is-loading .dcasim-preset-spinner {
        position: absolute;
        left: 50%;
        top: 50%;
        margin: -5px 0 0 -5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #dca-sim-wrapper .dcasim-preset-spinner { animation-duration: 2s; }
}

/* "subscribe" link inside the upgrade prompts. */
#dca-sim-wrapper .dcasim-subscribe-link {
    color: #4f46e5;
    text-decoration: underline;
    text-underline-offset: 2px;
}
#dca-sim-wrapper .dcasim-subscribe-link:hover { color: #4338ca; }

/* Glow on the fields a preset just filled (preset clicks only). */
@keyframes dcasimPresetFlash {
    0%   { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
    25%  { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35); border-color: #4f46e5; background-color: #eef2ff; }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
#dca-sim-wrapper .dcasim-preset-flash {
    animation: dcasimPresetFlash 0.7s ease-out both;
}
@media (prefers-reduced-motion: reduce) {
    #dca-sim-wrapper .dcasim-preset-flash { animation-duration: 0.01s; }
}

/* Auto-Sync checkbox (left) and Reset (right), two columns. */
#dca-sim-wrapper .dcasim-stress-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}
#dca-sim-wrapper .dcasim-stress-footer .field-label {
    margin: 0;
    min-width: 0;
    white-space: normal; /* wrap on phones instead of running under Reset */
    line-height: 1.4;
}
#dca-sim-wrapper .dcasim-stress-footer .field-label input { flex: 0 0 auto; }

/* Same height as the preset buttons (same padding, border, font and line
   height), in muted grey. */
/* Same look as the Back / Reset buttons under the Assets section
   (.btn-reset): transparent, light grey border and text, not bold. */
#dca-sim-wrapper .dcasim-stress-reset-btn {
    margin: 0;
    padding: 8px 18px;
    border: 1px solid #e4e4e7 !important;
    border-radius: 8px;
    background: transparent !important;
    color: #a1a1aa !important;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 500 !important;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: none;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease;
}
#dca-sim-wrapper .dcasim-stress-reset-btn:hover { border-color: #a1a1aa !important; color: #71717a !important; background: #fafafa !important; }
@media (max-width: 420px) {
    #dca-sim-wrapper .dcasim-stress-reset-btn { font-size: 0.8em; padding: 8px 12px; }
}

/* No thick theme focus ring after a mouse click on the preset or Reset
   buttons (the theme styles button:focus). Same approach as the asset
   ▼ / ✖ buttons: keyboard users still get a light indigo ring. */
#dca-sim-wrapper .dcasim-preset-btn:focus,
#dca-sim-wrapper .dcasim-stress-reset-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}
#dca-sim-wrapper .dcasim-stress-reset-btn:focus:not(:hover) {
    border-color: #e4e4e7 !important;
}
#dca-sim-wrapper .dcasim-preset-btn:focus-visible,
#dca-sim-wrapper .dcasim-stress-reset-btn:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 1px;
}

/* Same fix for the bottom row: Back, RUN SIMULATION and Reset kept the
   theme's thick focus border after a click. Back and Reset return to their
   thin grey border (the hover look still applies while the mouse is on
   them); RUN keeps its own shadow. Keyboard focus shows a light indigo ring. */
#dca-sim-wrapper .btn-reset:focus {
    outline: none !important;
    border: 1px solid #e4e4e7 !important;
    box-shadow: none !important;
}
#dca-sim-wrapper .btn-reset:focus:hover {
    border-color: #a1a1aa !important;
}
#dca-sim-wrapper #run-sim-btn:focus {
    outline: none !important;
}
#dca-sim-wrapper .btn-reset:focus-visible,
#dca-sim-wrapper #run-sim-btn:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 2px;
}


/* =======================================================
   🌟 Sub-sections of Advanced Features and Stress Tests
   (see the JS of the same name). The sub-heading is the toggle; its body
   slides like the main sections (.animated-content-wrapper).
   ======================================================= */
#dca-sim-wrapper .feature-section h4.dcasim-sub-head {
    display: flex;
    align-items: center;
    column-gap: 10px;            /* title, "i" and chevron never touch, even on two lines */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#dca-sim-wrapper .dcasim-sub-chev {
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
}

#dca-sim-wrapper .dcasim-sub-head details.info-tip summary {
    margin-left: 0;              /* the heading's gap spaces it */
}

#dca-sim-wrapper .dcasim-sub-head details.info-tip {
    flex: none;
}

#dca-sim-wrapper .dcasim-sub-head.is-open .dcasim-sub-chev {
    transform: rotate(180deg);
}

#dca-sim-wrapper .dcasim-sub-head:focus { outline: none; }
#dca-sim-wrapper .dcasim-sub-head:focus-visible {
    outline: 2px solid #c7d2fe;
    outline-offset: 3px;
    border-radius: 4px;
}

/* A closed sub-section keeps only its heading. */
#dca-sim-wrapper .dcasim-sub-body:not(.is-open) .dcasim-sub-pad { visibility: hidden; }
#dca-sim-wrapper .dcasim-sub-body .dcasim-sub-pad { transition: visibility 0s linear 0.4s; }
#dca-sim-wrapper .dcasim-sub-body.is-open .dcasim-sub-pad { transition-delay: 0s; }

/* A sub-section locked for this tier cannot be opened: no chevron, and the
   section's pointer-events: none keeps its heading from taking the click
   (the "i" tip still opens). The JS keeps it closed and skips it. */
#dca-sim-wrapper .is-locked > h4.dcasim-sub-head .dcasim-sub-chev { display: none; }

/* In the chevron's place: a lock, same size and line style, so the row
   says why it does not open. Drawn in currentColor (greyed with the row). */
#dca-sim-wrapper .is-locked > h4.dcasim-sub-head::after {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: auto;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* The two icons, left of ▲, with a clear 24px gap before it. */
#dca-sim-wrapper .feature-header .dcasim-sub-modes {
    display: inline-flex;
    gap: 6px;
    margin-left: auto;
    margin-right: 24px;
}

#dca-sim-wrapper .dcasim-sub-mode-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 7px !important;
    background: #ffffff !important;
    box-shadow: none !important;
    color: #a1a1aa !important;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

#dca-sim-wrapper .dcasim-sub-mode-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#dca-sim-wrapper .dcasim-sub-mode-btn svg circle {
    fill: currentColor;
    stroke: none;
}

#dca-sim-wrapper .dcasim-sub-mode-btn.is-on {
    border-color: #c7d2fe !important;
    background: #eef2ff !important;
    color: #4f46e5 !important;
}

@media (hover: hover) {
    #dca-sim-wrapper .dcasim-sub-mode-btn:hover:not(.is-on) {
        border-color: #a1a1aa !important;
        color: #71717a !important;
    }
}

#dca-sim-wrapper .dcasim-sub-mode-btn:focus { outline: none; }
#dca-sim-wrapper .dcasim-sub-mode-btn:focus-visible {
    outline: 2px solid #c7d2fe !important;
    outline-offset: 1px;
}
