/*
 * A1005 申請表的版面與元件樣式
 *
 * 顏色與尺寸一律引用 tokens.css 的 --a1005-* 變數。本頁同時載入 Bootstrap 5
 * （給 dc.MessageDialog 的 modal 用），class 名稱刻意避開 Bootstrap 已有的
 * .nav-tabs／.btn-*／.btn-group／.tab-content／.grid 等，避免兩邊樣式互相覆蓋。
 *
 * 狀態 class／屬性由 assets/js/A1005/applyLayout.js 切換：
 *   [data-a1005-step] 的 hidden 屬性      目前沒顯示的步驟
 *   .step-tab.active／.done               步驟導覽的目前步驟／已完成步驟
 *   .is-invisible                         條件區塊隱藏但保留版位
 *   .field.has-error／.has-warning        欄位容器內有錯誤／提示
 *   [data-a1005-field-state]              被標記錯誤或提示的欄位本身
 */

/* ---------- 頁面底色與背景雲朵 ---------- */

body.a1005-page {
    margin: 0;
    min-height: 100vh;
    padding: 16px 8px 32px;
    position: relative;
    overflow-x: hidden;
    background: linear-gradient(180deg, #38BDF8 0%, #7DD3FC 35%, #BAE6FD 70%, #F0F9FF 100%) fixed;
    font-family: var(--a1005-font-family), serif;
    font-size: var(--a1005-font-md);
    color: var(--a1005-text);
    /* 關掉瀏覽器的 scroll anchoring：按「下一步」驗證失敗時，錯誤摘要插在視窗上方、同時
       smooth 捲上去，瀏覽器為了固定畫面內容會自己把捲動位置往下拉，看起來像捲到一半又往下跳。
       這頁的捲動位置全部由 applyLayout.js 明確控制，不需要瀏覽器自動修正 */
    overflow-anchor: none;
}

body.a1005-page.is-embedded {
    padding: 0;
    background: #FFFFFF;
}

/*
 * 背景雲朵：三種積雲輪廓（inline SVG data URI，不另外載入檔案），
 * 由多個圓疊在一條圓角底座上組成，底部帶一點淡藍模擬雲腹的陰影。
 *
 * 遠近層次：近的雲大、不透明、飄得快；遠的雲小、淡、飄得慢，最遠一朵略微模糊。
 * animation-delay 用負值，讓頁面一載入雲就已經散布在畫面上，不用等它們從左邊飄進來。
 * --a1005-cloud-flip 為 -1 時左右翻轉，同一種輪廓看起來不會一模一樣。
 */
.cloud-deco {
    --a1005-cloud-flip: 1;
    position: fixed;
    z-index: 0;
    pointer-events: none;
    background: var(--a1005-cloud-shape) center / 100% 100% no-repeat;
    filter: drop-shadow(0 10px 14px rgba(3, 105, 161, 0.12));
    animation: a1005-cloud-drift linear infinite;
    will-change: transform;
}

/* 輪廓 A：中央高聳的標準積雲（寬高比 2:1） */
.cloud-1,
.cloud-4 {
    --a1005-cloud-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100'%3E%3Cdefs%3E%3ClinearGradient id='g' gradientUnits='userSpaceOnUse' x1='0' y1='8' x2='0' y2='94'%3E%3Cstop offset='0.55' stop-color='%23FFFFFF'/%3E%3Cstop offset='1' stop-color='%23DCEFFB'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Ccircle cx='34' cy='76' r='18'/%3E%3Ccircle cx='62' cy='62' r='30'/%3E%3Ccircle cx='100' cy='45' r='38'/%3E%3Ccircle cx='140' cy='60' r='28'/%3E%3Ccircle cx='168' cy='74' r='18'/%3E%3Crect x='16' y='62' width='170' height='32' rx='16'/%3E%3C/g%3E%3C/svg%3E");
}

/* 輪廓 B：扁長、起伏平緩的層積雲（寬高比 2.1:1） */
.cloud-2,
.cloud-5 {
    --a1005-cloud-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 210 100'%3E%3Cdefs%3E%3ClinearGradient id='g' gradientUnits='userSpaceOnUse' x1='0' y1='18' x2='0' y2='90'%3E%3Cstop offset='0.5' stop-color='%23FFFFFF'/%3E%3Cstop offset='1' stop-color='%23DCEFFB'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Ccircle cx='40' cy='70' r='20'/%3E%3Ccircle cx='75' cy='56' r='28'/%3E%3Ccircle cx='112' cy='50' r='32'/%3E%3Ccircle cx='150' cy='58' r='26'/%3E%3Ccircle cx='180' cy='70' r='18'/%3E%3Crect x='20' y='60' width='178' height='30' rx='15'/%3E%3C/g%3E%3C/svg%3E");
}

/* 輪廓 C：矮胖蓬鬆、頂端偏一側的積雲（寬高比約 1.45:1） */
.cloud-3,
.cloud-6 {
    --a1005-cloud-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 110'%3E%3Cdefs%3E%3ClinearGradient id='g' gradientUnits='userSpaceOnUse' x1='0' y1='12' x2='0' y2='100'%3E%3Cstop offset='0.55' stop-color='%23FFFFFF'/%3E%3Cstop offset='1' stop-color='%23DCEFFB'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Ccircle cx='30' cy='84' r='16'/%3E%3Ccircle cx='50' cy='70' r='26'/%3E%3Ccircle cx='82' cy='48' r='36'/%3E%3Ccircle cx='118' cy='66' r='26'/%3E%3Ccircle cx='135' cy='84' r='16'/%3E%3Crect x='14' y='72' width='137' height='28' rx='14'/%3E%3C/g%3E%3C/svg%3E");
}

.cloud-1 { width: 220px; height: 110px; top: 8%;  left: -240px; opacity: 0.9;  animation-duration: 70s;  animation-delay: -10s; }
.cloud-2 { width: 300px; height: 143px; top: 26%; left: -320px; opacity: 0.55; animation-duration: 95s;  animation-delay: -60s; --a1005-cloud-flip: -1; }
.cloud-3 { width: 170px; height: 117px; top: 46%; left: -190px; opacity: 0.8;  animation-duration: 55s;  animation-delay: -30s; }
.cloud-4 { width: 260px; height: 130px; top: 64%; left: -280px; opacity: 0.45; animation-duration: 110s; animation-delay: -80s; --a1005-cloud-flip: -1; }
.cloud-5 { width: 140px; height: 67px;  top: 16%; left: -160px; opacity: 0.5;  animation-duration: 120s; animation-delay: -20s; filter: blur(1px); }
.cloud-6 { width: 200px; height: 138px; top: 80%; left: -220px; opacity: 0.35; animation-duration: 85s;  animation-delay: -45s; --a1005-cloud-flip: -1; }

@keyframes a1005-cloud-drift {
    from { transform: translateX(0) scaleX(var(--a1005-cloud-flip)); }
    to   { transform: translateX(calc(100vw + 400px)) scaleX(var(--a1005-cloud-flip)); }
}

/*
 * 使用者在系統設定裡要求減少動態效果時，雲朵停在原位
 * 用暫停而不是 animation: none：配合負的 animation-delay，雲會停在畫面中各自的位置；
 * 改成 none 的話會退回 left 的初始值，全部停在畫面左邊外面看不到
 */
@media (prefers-reduced-motion: reduce) {
    .cloud-deco { animation-play-state: paused; }
}

/*
 * 寬度在 .app-container 的 max-width（1000px）以內時，表單幾乎佔滿整個畫面，雲朵只會從
 * 半透明的表單底下透出來，看不出效果；而且表單有 backdrop-filter，底下有東西在動就得
 * 每一格重算模糊，手機上耗電又容易延遲。直接不顯示，動畫也跟著停掉
 */
@media (max-width: 1000px) {
    .cloud-deco { display: none; }
}

/* 已改為上方的 SVG 積雲輪廓，以下為改寫前以圓角矩形加兩個圓（::before／::after）拼出的原版，保留備查：
.cloud-deco {
    position: fixed;
    z-index: 0;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 50px;
    animation: a1005-cloud-drift linear infinite;
}

.cloud-deco::before,
.cloud-deco::after {
    content: "";
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.cloud-1 { width: 180px; height: 55px; top: 6%;  left: -200px; opacity: 0.5;  animation-duration: 22s; }
.cloud-1::before { width: 70px; height: 70px; top: -30px; left: 25px; }
.cloud-1::after  { width: 55px; height: 55px; top: -22px; right: 25px; }

.cloud-2 { width: 240px; height: 70px; top: 28%; left: -280px; opacity: 0.35; animation-duration: 32s; animation-delay: 5s; }
.cloud-2::before { width: 90px; height: 90px; top: -40px; left: 35px; }
.cloud-2::after  { width: 70px; height: 70px; top: -28px; right: 35px; }

.cloud-3 { width: 150px; height: 48px; top: 52%; left: -180px; opacity: 0.6;  animation-duration: 18s; animation-delay: 2s; }
.cloud-3::before { width: 60px; height: 60px; top: -25px; left: 20px; }
.cloud-3::after  { width: 45px; height: 45px; top: -18px; right: 20px; }

.cloud-4 { width: 210px; height: 62px; top: 72%; left: -240px; opacity: 0.25; animation-duration: 27s; animation-delay: 10s; }
.cloud-4::before { width: 80px; height: 80px; top: -35px; left: 30px; }
.cloud-4::after  { width: 60px; height: 60px; top: -24px; right: 30px; }

.cloud-5 { width: 130px; height: 40px; top: 18%; left: -150px; opacity: 0.4;  animation-duration: 15s; animation-delay: 8s; }
.cloud-5::before { width: 50px; height: 50px; top: -20px; left: 15px; }
.cloud-5::after  { width: 38px; height: 38px; top: -14px; right: 15px; }

.cloud-6 { width: 260px; height: 75px; top: 86%; left: -300px; opacity: 0.3;  animation-duration: 38s; animation-delay: 3s; }
.cloud-6::before { width: 100px; height: 100px; top: -45px; left: 40px; }
.cloud-6::after  { width: 75px; height: 75px; top: -30px; right: 40px; }

@keyframes a1005-cloud-drift {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(100vw + 400px)); }
}

@media (prefers-reduced-motion: reduce) {
    .cloud-deco { animation: none; }
}
*/

/* ---------- 頁首與外框 ---------- */

.app-brand {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #FFFFFF;
}

.app-brand img {
    height: 40px;
    width: auto;
}

.app-brand h1 {
    margin: 0;
    font-size: var(--a1005-font-xl);
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 2px 6px rgba(0, 64, 133, 0.35);
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.91);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--a1005-radius-2xl);
    box-shadow: var(--a1005-shadow-card);
}

@media (max-width: 640px) {
    .app-brand { gap: 8px; }
    .app-brand img { height: 30px; }
    .app-container { padding: 14px 12px; border-radius: var(--a1005-radius-xl); }
    .cloud-box { padding: 14px 12px; }
}

.is-embedded .app-container {
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.token-expired-notice {
    margin: 0 0 16px;
    padding: 12px 16px;
    background: var(--a1005-danger-soft);
    color: #611A15;
    border: 1px solid #F5C2C0;
    border-radius: var(--a1005-radius-md);
    text-align: center;
    font-size: var(--a1005-font-md);
}

/* ---------- 步驟導覽 ---------- */

/* 六格等寬，標題太長時在格內換行（例如「公司基本資料及字軌申請」），不橫向捲動也不互相重疊；
   窄螢幕改成一列三格 */
.step-nav {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

@media (max-width: 640px) {
    .step-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.step-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    /* 原為 padding: 6px 8px;，內距改由 .step-tab-link 負責，整格範圍都點得到 */
    padding: 0;
    border: 1.5px solid var(--a1005-border);
    border-radius: 16px;
    background: rgba(240, 249, 255, 0.8);
    color: var(--a1005-primary);
    font-size: var(--a1005-font-step);
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* 格內的換頁按鈕：撐滿整格、外觀完全沿用 .step-tab，本身不畫任何框或底色 */
.step-tab-link {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    margin: 0;
    border: 0;
    border-radius: inherit;
    background: none;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: inherit;
    overflow-wrap: inherit;
    cursor: pointer;
}

/* 目前與之後的步驟不可點；瀏覽器預設會把 disabled 按鈕的文字變灰，這裡維持原本的顏色 */
.step-tab-link:disabled {
    color: inherit;
    cursor: default;
}

.step-tab-link:focus-visible {
    outline: none;
    box-shadow: var(--a1005-focus-ring);
}

.step-tab.done {
    background: var(--a1005-sky-soft);
}

/* 進去過的步驟（不含目前這一步）可點；在前面步驟時，後面進去過的格子也用同樣底色標示 */
.step-tab.is-visited {
    background: var(--a1005-sky-soft);
}

/* 滑過時提示可以點過去 */
.step-tab.is-visited:hover {
    /*border-color: var(--a1005-primary);*/
    box-shadow: var(--a1005-focus-ring);
}

.step-tab.active {
    background: linear-gradient(135deg, var(--a1005-sky) 0%, var(--a1005-primary) 100%);
    /*border-color: transparent;*/
    color: #FFFFFF;
    box-shadow: var(--a1005-shadow-active);
}

/* ---------- 區塊卡與版面格線 ---------- */

.cloud-box {
    margin-bottom: 16px;
    padding: 18px;
    background: rgba(240, 249, 255, 0.85);
    border: 2px solid var(--a1005-border);
    border-radius: var(--a1005-radius-xl);
}

.box-title {
    margin: 0 0 14px;
    font-size: var(--a1005-font-title);
    font-weight: 700;
    color: var(--a1005-primary);
    text-align: center;
}

.box-subtitle {
    margin: -6px 0 14px;
    font-size: var(--a1005-font-subtitle);
    color: var(--a1005-text-muted);
    text-align: center;
}

.box-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.box-title-row .box-title {
    margin: 0;
}

.section-heading {
    margin: 18px 0 8px;
    font-size: var(--a1005-font-lg);
    font-weight: 700;
    color: var(--a1005-primary);
}

.form-grid {
    display: grid;
    gap: 12px;
}

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

.span-full {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .form-grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 欄位 ---------- */

/* position:relative：dc.Autocomplete 的建議清單以欄位的父層為定位基準 */
.field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.field > label,
.field-label {
    margin: 0;
    font-size: var(--a1005-font-md);
    font-weight: 600;
    color: var(--a1005-text-body);
}

.req {
    color: var(--a1005-danger);
    margin-left: 2px;
}

.field-hint {
    font-size: var(--a1005-font-sm);
    color: var(--a1005-text-muted);
    line-height: 1.5;
}

.field-hint a {
    color: var(--a1005-sky-strong);
}

/* dc.Autocomplete 的建議清單樣式寫死 13px，且與 PSPurchase 共用，只在本頁放大 */
.a1005-page .dc-ac-item,
.a1005-page .dc-ac-loading {
    font-size: var(--a1005-font-sm);
}

.input-ctrl {
    width: 100%;
    min-width: 0;
    height: var(--a1005-control-height);
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid var(--a1005-border);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-input);
    color: var(--a1005-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-ctrl:focus {
    border-color: var(--a1005-primary);
    box-shadow: var(--a1005-focus-ring);
}

.input-ctrl[readonly] {
    background: var(--a1005-surface-soft);
    color: var(--a1005-text-muted);
}

select.input-ctrl {
    padding-right: 28px;
}

/* 多個控制項並排（國稅局＋分局＋聯絡窗口、區碼＋電話＋分機），窄螢幕自動換行 */
.combo-input {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
}

.combo-input > .input-ctrl {
    flex: 1 1 120px;
}

.combo-input > .code-in {
    flex: 0 0 90px;
}

.combo-input > .ext-in {
    flex: 0 0 72px;
}

/* 基準寬度要放得下「選擇鄉鎮市區」加上 select 本身的下拉箭頭 */
.combo-input > .address-select {
    flex: 0 1 160px;
}

/* 手機版兩個下拉擺不下同一列，直接各佔一整列，不留半截寬度靠左 */
@media (max-width: 640px) {
    .combo-input > .address-select { flex-basis: 100%; }
}

.combo-input > .address-street {
    flex: 1 1 240px;
}

/* token 鎖定的地址／市話改成純文字顯示 */
.locked-value {
    display: flex;
    align-items: center;
    min-height: var(--a1005-control-height);
    padding: 0 10px;
    background: var(--a1005-surface-soft);
    border: 1.5px dashed var(--a1005-border);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-input);
    color: var(--a1005-text-body);
}

/* 錯誤與提示：容器只負責訊息顏色，紅框只畫在真的出錯的那一個控制項上 */
.field-error {
    font-size: var(--a1005-font-xs);
    color: var(--a1005-danger);
    line-height: 1.5;
}

.field-error.is-warning {
    color: var(--a1005-warning);
}

[data-a1005-field-state="error"] {
    border-color: var(--a1005-danger) !important;
    background-color: var(--a1005-danger-soft);
}

[data-a1005-field-state="warning"] {
    border-color: #F59E0B !important;
    background-color: var(--a1005-warning-soft);
}

.step-summary {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--a1005-danger-soft);
    border: 1.5px solid #FCA5A5;
    border-radius: var(--a1005-radius-md);
    color: #991B1B;
    font-size: var(--a1005-font-md);
}

.step-summary ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.is-invisible {
    visibility: hidden;
}

/* ---------- 申請流程（第 1 頁與完成頁共用） ---------- */

.process-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 768px) {
    .process-grid { grid-template-columns: minmax(0, 1fr); }
}

.process-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 12px;
    background: var(--a1005-surface);
    border: 2px solid var(--a1005-border);
    border-radius: 18px;
    text-align: center;
}

/* 圖示為 A1005Questions::PROCESS_STEPS 的 emoji，字型依序指定各平台的彩色 emoji 字型 */
.process-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border: 2px solid var(--a1005-sky);
    border-radius: 50%;
    background-color: var(--a1005-sky-soft);
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 28px;
    line-height: 1;
}

/* 圖示改為 emoji 後不再使用，以下為原本依 icon 代號掛 SVG 的樣式，保留備查：
.process-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border: 2px solid var(--a1005-sky);
    border-radius: 50%;
    background-color: var(--a1005-sky-soft);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 28px 28px;
}

.process-icon[data-icon="apply"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284C7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6'/%3E%3Cpath d='M8 13h8M8 17h5'/%3E%3C/svg%3E");
}

.process-icon[data-icon="review"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284C7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18'/%3E%3Cpath d='M5 21V10M9.5 21V10M14.5 21V10M19 21V10'/%3E%3Cpath d='M2 10l10-6 10 6z'/%3E%3C/svg%3E");
}

.process-icon[data-icon="track"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284C7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='4.5'/%3E%3Cpath d='M10.7 12.3L20 3'/%3E%3Cpath d='M16 7l3 3M13.5 9.5l2 2'/%3E%3C/svg%3E");
}

.process-icon[data-icon="online"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284C7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.5l2.5 2.5L16 9.5'/%3E%3C/svg%3E");
}
*/

.process-badge {
    margin-bottom: 8px;
    padding: 4px 10px;
    background: var(--a1005-sky-strong);
    border-radius: var(--a1005-radius-md);
    color: #FFFFFF;
    font-size: var(--a1005-font-xs);
    font-weight: 700;
}

.process-desc {
    flex-grow: 1;
    margin: 0;
    font-size: var(--a1005-font-md);
    font-weight: 500;
    line-height: 1.55;
    color: var(--a1005-text-body);
}

.process-step-name {
    width: 100%;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 2px dashed var(--a1005-border);
    font-size: var(--a1005-font-lg);
    font-weight: 800;
    color: var(--a1005-primary);
}

.support-line {
    margin: 16px 0 0;
    font-size: var(--a1005-font-lg);
    font-weight: 600;
    color: var(--a1005-neutral-text);
    text-align: center;
    line-height: 1.7;
}

.copy-url-row {
    margin-top: 12px;
    text-align: center;
}

/* ---------- 電子發票資格八題 ---------- */

.q-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.q-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid var(--a1005-border);
    border-radius: 14px;
}

@media (max-width: 600px) {
    .q-item { flex-direction: column; align-items: flex-start; }
}

.toggle-group {
    position: relative;
    display: flex;
    flex-shrink: 0;
    min-width: 96px;
    padding: 2px;
    background: var(--a1005-neutral);
    border-radius: 14px;
}

/* radio 本身視覺隱藏但保留鍵盤操作與 focus，選中狀態由相鄰的 label 呈現 */
.toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.toggle-btn {
    flex: 1;
    margin: 0;
    padding: 5px 10px;
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-md);
    font-weight: 700;
    color: var(--a1005-text-muted);
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.toggle-input:checked + .toggle-yes {
    background: var(--a1005-sky-strong);
    color: #FFFFFF;
}

.toggle-input:checked + .toggle-no {
    background: var(--a1005-primary);
    color: #FFFFFF;
}

.toggle-input:focus-visible + .toggle-btn {
    box-shadow: var(--a1005-focus-ring);
}

.q-title {
    font-size: var(--a1005-font-md);
    font-weight: 700;
    color: var(--a1005-primary);
}

.q-sub {
    font-size: var(--a1005-font-sm);
    color: var(--a1005-text-muted);
}

/* ---------- 聯絡人卡、登入帳號卡 ---------- */

.contact-card-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.contact-card {
    position: relative;
    padding: 14px;
    background: rgba(255, 255, 255, 0.92);
    border: 1.5px solid var(--a1005-border);
    border-radius: var(--a1005-radius-lg);
}

.contact-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1.5px dashed var(--a1005-border);
}

.contact-title {
    font-size: var(--a1005-font-lg);
    font-weight: 700;
    color: var(--a1005-primary);
}

.contact-title small {
    font-weight: 500;
    color: var(--a1005-text-muted);
}

.same-btn,
.add-btn,
.del-btn,
.copy-url-btn {
    border: none;
    color: #FFFFFF;
    font-weight: 700;
    cursor: pointer;
}

/* 標題太長時讓標題換行，按鈕文字不被擠成兩行 */
.same-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 4px 12px;
    background: var(--a1005-sky-strong);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-xs);
}

.add-btn {
    padding: 6px 14px;
    background: var(--a1005-success);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-xs);
}

.del-btn {
    padding: 3px 10px;
    background: var(--a1005-danger);
    border-radius: var(--a1005-radius-sm);
    font-size: var(--a1005-font-xs);
}

.copy-url-btn {
    padding: 6px 16px;
    background: var(--a1005-sky-strong);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-sm);
}

.usage-note {
    margin: 0 0 12px;
    font-size: var(--a1005-font-md);
    font-weight: 600;
    color: var(--a1005-sky-strong);
}

/* ---------- 權限說明表 ---------- */

.role-table-container {
    margin-top: 16px;
    /* 只負責把標題列背景裁成圓角；橫向捲動交給 .role-table-scroll */
    overflow: hidden;
    background: var(--a1005-surface);
    border: 1.5px solid var(--a1005-border);
    border-radius: 14px;
}

/*
 * 右緣捲動陰影：右邊還有內容時出現，捲到最右邊自動消失，表格沒超出寬度時也不會出現。
 * 第一層白色遮罩用 local 跟著內容捲動、停在表格最右端；第二層陰影用 scroll 固定在可視範圍右緣，
 * 捲到底時遮罩剛好蓋住陰影。表頭列本身有底色會蓋掉大部分陰影，主要顯示在內容列。
 */
.role-table-scroll {
    overflow-x: auto;
    background:
        linear-gradient(to left, #FFFFFF 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 64, 133, 0.25), rgba(0, 64, 133, 0)) right center / 18px 100% no-repeat scroll;
}

.role-table-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--a1005-sky-soft);
    color: var(--a1005-primary);
    font-size: var(--a1005-font-md);
    font-weight: 700;
}

.role-table-title small {
    font-size: var(--a1005-font-xs);
    font-weight: 400;
    color: var(--a1005-neutral-text);
}

/* 表格超出寬度時才顯示（applyLayout.js 在外框加上 data-a1005-overflowing），靠右對齊在表格右上方 */
.role-table-scroll-hint {
    display: none;
    margin-left: auto;
    font-size: var(--a1005-font-xs);
    color: var(--a1005-sky-strong);
    white-space: nowrap;
}

.role-table-container[data-a1005-overflowing] .role-table-scroll-hint {
    display: inline;
}

.role-table {
    width: 100%;
    /* 首欄 sticky 時，collapse 模式的框線由表格統一繪製、不會跟著儲存格固定（捲動時首欄底線會斷掉），
       改用 separate 加 0 間距；本表只有 border-bottom，兩種模式外觀相同 */
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--a1005-font-md);
    text-align: center;
}

.role-table th {
    padding: 8px;
    background: rgba(240, 249, 255, 0.9);
    border-bottom: 1.5px solid var(--a1005-border);
    color: var(--a1005-primary);
    font-weight: 700;
    white-space: nowrap;
}

/* 首欄（身份別）固定：手機寬度表格會橫向捲動，身份別要留在左側才對照得到是哪一列 */
.role-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 1.5px solid var(--a1005-border);
}

/* sticky 儲存格背景必須不透明，否則捲過去的欄位內容會從底下透出來 */
.role-table thead th:first-child {
    background: var(--a1005-cloud-light);
}

.role-table tbody th {
    background: #FFFFFF;
    border-bottom: 1px solid var(--a1005-neutral);
}

.role-table tr:last-child th {
    border-bottom: none;
}

.role-table td {
    padding: 8px;
    border-bottom: 1px solid var(--a1005-neutral);
    color: var(--a1005-text-body);
}

.role-table tr:last-child td {
    border-bottom: none;
}

.check-mark {
    color: var(--a1005-sky-strong);
    font-size: var(--a1005-font-lg);
    font-weight: 700;
}

/* ---------- 服務條款 ---------- */

.party-table {
    width: 100%;
    margin-bottom: 12px;
    border-collapse: collapse;
    font-size: var(--a1005-font-md);
    color: var(--a1005-text-body);
}

.party-table th,
.party-table td {
    padding: 8px 10px;
    border-bottom: 1px dashed var(--a1005-border);
    text-align: left;
}

.party-table th {
    width: 80px;
    color: var(--a1005-primary);
    white-space: nowrap;
}

.party-table .party-role {
    width: 120px;
    color: var(--a1005-text-muted);
    text-align: right;
    white-space: nowrap;
}

/* 手機版收緊欄寬，否則公司名稱欄會被擠到一行只剩兩三個字 */
@media (max-width: 640px) {
    .party-table th,
    .party-table td { padding: 8px 6px; }
    .party-table th,
    .party-table .party-role { width: auto; }
    .party-table .party-role { font-size: var(--a1005-font-xs); }
}

.terms-box {
    max-height: 360px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 14px 18px;
    background: var(--a1005-surface);
    border: 1.5px solid var(--a1005-border);
    border-radius: var(--a1005-radius-md);
    font-size: var(--a1005-font-sm);
    line-height: 1.7;
    color: var(--a1005-text-body);
}

.terms-box h3 {
    margin: 14px 0 6px;
    font-size: var(--a1005-font-lg);
    font-weight: 700;
    color: var(--a1005-primary);
}

.terms-box ul,
.terms-box ol {
    margin: 0 0 6px;
    padding-left: 18px;
    list-style: none;
}

.terms-box p {
    margin: 2px 0 6px;
}

.agree-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: var(--a1005-font-md);
    color: var(--a1005-primary);
}

.agree-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 600;
    cursor: pointer;
}

.agree-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--a1005-sky-strong);
}

.agree-row a {
    color: var(--a1005-sky-strong);
}

.support-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1.5px dashed var(--a1005-border);
    font-size: var(--a1005-font-sm);
    color: var(--a1005-text-body);
}

.support-box p {
    margin: 2px 0;
}

.support-box img {
    width: 110px;
    height: auto;
}

/* ---------- 填寫總預覽 ---------- */

.pv-section {
    margin-bottom: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.92);
    border: 1.5px solid var(--a1005-border);
    border-radius: var(--a1005-radius-lg);
}

.pv-title {
    margin: 0 0 10px;
    padding-left: 8px;
    border-left: 4px solid var(--a1005-sky);
    font-size: var(--a1005-font-lg);
    font-weight: 700;
    color: var(--a1005-primary);
}

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

@media (max-width: 600px) {
    .pv-grid { grid-template-columns: minmax(0, 1fr); }
}

.pv-item {
    padding: 8px 12px;
    background: var(--a1005-surface-soft);
    border: 1px solid var(--a1005-neutral);
    border-radius: 10px;
    font-size: var(--a1005-font-md);
    line-height: 1.6;
    color: var(--a1005-text-body);
    overflow-wrap: anywhere;
}

.pv-label {
    display: inline-block;
    min-width: 96px;
    margin-right: 4px;
    font-weight: 700;
    color: var(--a1005-primary);
}

.pv-item-title {
    margin-bottom: 4px;
    font-weight: 700;
    color: var(--a1005-primary);
}

.pv-lines {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 2px 10px;
    margin: 0;
}

.pv-lines dt {
    font-weight: 600;
    color: var(--a1005-text-muted);
}

.pv-lines dd {
    margin: 0;
}

.pv-question {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.pv-badge {
    flex-shrink: 0;
    min-width: 28px;
    padding: 1px 6px;
    background: var(--a1005-sky-strong);
    border-radius: 6px;
    color: #FFFFFF;
    font-size: var(--a1005-font-xs);
    font-weight: 700;
    text-align: center;
}

.pv-empty-row {
    color: var(--a1005-text-subtle);
    text-align: center;
}

/* 預覽頁沒有填寫的項目：applyReview.js 填入「未填寫」並加上這個 class */
.a1005-review-empty {
    color: var(--a1005-text-subtle);
}

.pv-badge.a1005-review-empty {
    background: var(--a1005-neutral);
}

/* ---------- 驗證碼 ---------- */

.captcha-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: var(--a1005-surface);
    border: 1.5px solid var(--a1005-border);
    border-radius: var(--a1005-radius-md);
}

.captcha-field {
    position: relative;
    display: flex;
    align-items: center;
}

.captcha-input {
    width: 180px;
    padding-left: 36px;
    text-align: center;
    letter-spacing: 2px;
}

.captcha-refresh {
    position: absolute;
    left: 6px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--a1005-text-muted);
    cursor: pointer;
}

.captcha-refresh svg {
    width: 16px;
    height: 16px;
}

.captcha-img {
    height: 42px;
    border-radius: 6px;
}

/* 獨佔一行，排在輸入框與圖片下方 */
.captcha-load-error {
    flex-basis: 100%;
    margin: 0;
    text-align: center;
}

/* ---------- 上一步／下一步 ---------- */

.action-bar {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* 用 min-height 不用 height：窄螢幕放不下「🚀 確認無誤並送出申請」時按鈕跟著折行長高，文字不會超出按鈕 */
.action-btn {
    flex: 1;
    min-height: 44px;
    padding: 8px 10px;
    border: none;
    border-radius: 22px;
    font-size: var(--a1005-font-button);
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    transition: filter 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
    filter: brightness(1.05);
}

.action-btn:focus-visible {
    outline: none;
    box-shadow: var(--a1005-focus-ring);
}

.action-btn-primary {
    background: linear-gradient(135deg, var(--a1005-sky) 0%, var(--a1005-primary) 100%);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
    color: #FFFFFF;
}

.action-btn-secondary {
    background: var(--a1005-neutral);
    color: var(--a1005-neutral-text);
}

/* 手機版「上一步」只佔文字寬度，其餘空間讓給主按鈕，長文字的主按鈕才放得進同一行 */
@media (max-width: 640px) {
    .action-btn-secondary { flex: 0 0 auto; }
}
