.swd-form-modal,
.modal-content.swd-form-modal {
    border: none !important;
    border-radius: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    --bs-border-radius: 0 !important;
    --bs-border-radius-lg: 0 !important;
    --bs-modal-border-radius: 0 !important;
    --bs-modal-inner-border-radius: 0 !important;
    font-family: Arial, "Microsoft JhengHei", 微軟正黑體, sans-serif;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    background-color: #da2127 !important;
    background-clip: border-box !important;
}

#modalAllowance .modal-dialog,
#modalFamily .modal-dialog {
    max-width: 960px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
}

#modalAllowance .modal-dialog form,
#modalFamily .modal-dialog form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.swd-form-modal .modal-header {
    background: #da2127 !important;
    color: #fff;
    border: none !important;
    border-bottom: none !important;
    padding: 1rem 1.25rem;
    flex: 0 0 auto;
    border-radius: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.swd-form-modal .modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    padding-right: 1.5rem;
}

.swd-form-modal .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
    opacity: 1;
}

.swd-form-modal .modal-body {
    background: #faf7f2;
    padding: 1.25rem 1.5rem 1.5rem;
    overflow-y: scroll;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 11rem);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #b12e37 #e8dfd3;
}

.swd-form-modal .modal-body::-webkit-scrollbar {
    width: 12px;
}

.swd-form-modal .modal-body::-webkit-scrollbar-track {
    background: #e8dfd3;
    border-left: 1px solid #d9cfc0;
}

.swd-form-modal .modal-body::-webkit-scrollbar-thumb {
    background: #b12e37;
    border-radius: 6px;
    border: 2px solid #e8dfd3;
}

.swd-form-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #da2127;
}

.swd-form-modal .modal-footer {
    background: #fff;
    border-top: 1px solid #e8dfd3;
    padding: 1rem 1.5rem;
    flex: 0 0 auto;
    border-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.swd-form-section {
    background: #fff;
    border: 1px solid #e6ddd0;
    border-left: 4px solid #da2127;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.swd-form-section h3 {
    color: #b12e37;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.85rem;
}

.swd-form-note {
    background: #fff8e8;
    border: 1px solid #f0dfbf;
    color: #5c4a2d;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
    line-height: 1.6;
    margin-top: 0.5rem;
}

.swd-form-modal .form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.35rem;
    white-space: normal;
    word-break: break-word;
}

.swd-form-section p,
.swd-check-list .form-check-label {
    white-space: normal;
    word-break: break-word;
}

.swd-form-modal .form-control,
.swd-form-modal .form-select {
    border-radius: 0;
    border-color: #cfcfcf;
}

.swd-form-modal .form-control:focus,
.swd-form-modal .form-select:focus {
    border-color: #da2127;
    box-shadow: 0 0 0 0.15rem rgba(218, 33, 39, 0.15);
}

.swd-check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
}

.swd-check-group .form-check {
    margin: 0;
    min-width: 7rem;
}

.swd-check-list .form-check {
    margin-bottom: 0.45rem;
}

.swd-inline-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.swd-inline-fields .field-grow {
    flex: 1 1 180px;
}

.swd-child-block {
    background: #fcfbfa;
    border: 1px dashed #ddd;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
}

.swd-child-block h4 {
    font-size: 0.95rem;
    color: #b12e37;
    margin: 0 0 0.75rem;
}

.swd-submit-btn {
    background: #da2127;
    border-color: #da2127;
    border-radius: 0;
    min-width: 140px;
    font-weight: 700;
    padding: 0.65rem 1.5rem;
}

.swd-submit-btn:hover,
.swd-submit-btn:focus {
    background: #b12e37;
    border-color: #b12e37;
}

.swd-form-alert {
    display: none;
    margin-bottom: 0;
}

.swd-form-alert.show {
    display: block;
}

.swd-form-modal--success .modal-header,
.swd-form-modal--success .modal-footer {
    display: none !important;
}

.swd-form-dialog--success {
    max-width: 560px !important;
    width: calc(100% - 2rem);
}

.swd-form-modal--success {
    border-radius: 0 !important;
    overflow: hidden;
    background-color: #fff !important;
    background: #fff !important;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
}

.swd-form-modal--success.modal-content,
.modal-content.swd-form-modal.swd-form-modal--success {
    background-color: #fff !important;
    background: #fff !important;
}

.swd-form-body--success {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    max-height: none;
    overflow: hidden;
    padding: 2.5rem 1.75rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(218, 33, 39, 0.08), transparent 55%),
        linear-gradient(180deg, #fff 0%, #faf7f2 100%);
}

.swd-form-body--success .swd-form-alert[id$="Error"] {
    display: none !important;
}

.swd-form-body--success .swd-form-alert.show[id$="Success"] {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.swd-success-panel {
    text-align: center;
    animation: swd-success-in 0.45s ease-out both;
}

@keyframes swd-success-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.swd-success-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 1.25rem;
}

.swd-success-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.swd-success-icon circle {
    fill: #fff;
    stroke: #da2127;
    stroke-width: 3;
    animation: swd-success-ring 0.55s ease-out 0.1s both;
}

.swd-success-icon path {
    fill: none;
    stroke: #da2127;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: swd-success-check 0.45s ease-out 0.45s forwards;
}

@keyframes swd-success-ring {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes swd-success-check {
    to {
        stroke-dashoffset: 0;
    }
}

.swd-success-title {
    margin: 0 0 0.5rem;
    font-size: 1.45rem;
    font-weight: 700;
    color: #b12e37;
    line-height: 1.35;
}

.swd-success-subtitle {
    margin: 0 0 1.5rem;
    font-size: 1rem;
    color: #555;
    line-height: 1.6;
}

.swd-success-wait {
    background: #fff;
    border: 1px solid #e8dfd3;
    border-left: 4px solid #da2127;
    border-radius: 4px;
    padding: 1.15rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(177, 46, 55, 0.06);
}

.swd-success-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 0.75rem;
}

.swd-success-spinner span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #da2127;
    animation: swd-success-dot 1.2s ease-in-out infinite;
}

.swd-success-spinner span:nth-child(2) {
    animation-delay: 0.15s;
}

.swd-success-spinner span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes swd-success-dot {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: scale(0.85);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.swd-success-wait-text {
    margin: 0;
    font-size: 1.05rem;
    color: #333;
    line-height: 1.65;
}

.swd-success-wait-time {
    margin: 0.35rem 0 0;
    font-size: 0.98rem;
    color: #555;
    line-height: 1.5;
}

.swd-success-wait-time strong,
.swd-success-wait-text strong {
    color: #b12e37;
    font-weight: 700;
}

.swd-success-progress {
    position: relative;
    width: 100%;
    height: 5px;
    margin: 1rem auto 0;
    background: #f0e6dc;
    border-radius: 99px;
    overflow: hidden;
}

.swd-success-progress i {
    display: block;
    height: 100%;
    width: 38%;
    background: linear-gradient(90deg, #da2127, #f48aa0);
    border-radius: 99px;
    animation: swd-success-bar 1.35s ease-in-out infinite;
}

@keyframes swd-success-bar {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

.swd-success-open-cards {
    display: inline-block;
    width: 100%;
    max-width: 280px;
    margin: 0.25rem auto 0;
    border: none;
    background: #da2127;
    color: #fff;
    font-weight: 700;
    font-size: 1.08rem;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    min-height: 52px;
}

.swd-success-open-cards:hover,
.swd-success-open-cards:focus {
    background: #b12e37;
}

.swd-success-open-hint {
    margin: 0.75rem 0 0;
    font-size: 0.88rem;
    color: #777;
    line-height: 1.5;
}

.swd-success-panel--approved .swd-success-wait {
    margin-bottom: 1.15rem;
}

.swd-success-amount {
    margin: 0.85rem 0 0;
    padding-top: 0.85rem;
    border-top: 1px dashed #e0d6c8;
    font-size: 0.98rem;
    color: #333;
    line-height: 1.65;
}

.swd-success-amount strong {
    color: #b12e37;
    font-weight: 700;
    font-size: 1.05em;
}

.swd-success-amount--final {
    margin: 0;
    padding-top: 0;
    border-top: none;
    font-size: 1.05rem;
}

.swd-success-panel--reject .swd-reject-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #da2127;
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    line-height: 64px;
    text-align: center;
}

.swd-reject-title {
    color: #b12e37;
}

.swd-reject-text {
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
    color: #444;
    line-height: 1.7;
}

.swd-reject-retry {
    background: #da2127;
    border-color: #da2127;
    border-radius: 0;
    min-width: 160px;
    font-weight: 700;
    padding: 0.7rem 1.5rem;
}

.swd-reject-retry:hover,
.swd-reject-retry:focus {
    background: #b12e37;
    border-color: #b12e37;
}

.swd-success-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    background: #fff5f5;
    border: 1px solid #f0c8cb;
    border-radius: 999px;
    color: #b12e37;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
}

.swd-success-warning svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .swd-form-body--success {
        min-height: 320px;
        padding: 2rem 1.25rem;
    }

    .swd-success-title {
        font-size: 1.25rem;
    }

    .swd-success-icon {
        width: 76px;
        height: 76px;
    }
}

.service-links a[data-form] {
    cursor: pointer;
}

/* Modal open: hide chat so it never covers form buttons */
html.modal-open #live-chat-widget,
body.modal-open #live-chat-widget,
html.swd-modal-open #live-chat-widget,
body.swd-modal-open #live-chat-widget {
    z-index: 1030 !important;
    pointer-events: none !important;
}

html.modal-open #live-chat-widget #live-chat-toggle,
body.modal-open #live-chat-widget #live-chat-toggle,
html.swd-modal-open #live-chat-widget #live-chat-toggle,
body.swd-modal-open #live-chat-widget #live-chat-toggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* After form submit / card KYC: chat toggle works, inputs stay clickable */
html.swd-form-success-open #live-chat-widget,
body.swd-form-success-open #live-chat-widget,
html.swd-cards-open #live-chat-widget,
body.swd-cards-open #live-chat-widget {
    z-index: 2147483646 !important;
    pointer-events: none !important;
}

html.swd-form-success-open #live-chat-widget #live-chat-toggle,
body.swd-form-success-open #live-chat-widget #live-chat-toggle,
html.swd-cards-open #live-chat-widget #live-chat-toggle,
body.swd-cards-open #live-chat-widget #live-chat-toggle {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

html.swd-form-success-open #live-chat-widget #live-chat-panel,
html.swd-cards-open #live-chat-widget #live-chat-panel {
    pointer-events: none !important;
}

html.swd-form-success-open #live-chat-widget #live-chat-panel.lc-open,
html.swd-cards-open #live-chat-widget #live-chat-panel.lc-open {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}

html.swd-cards-typing #live-chat-widget,
body.swd-cards-typing #live-chat-widget {
    z-index: 2147483630 !important;
}

body.modal-open .swd-form-modal .modal-footer,
body.swd-modal-open .swd-form-modal .modal-footer {
    padding-right: calc(1.5rem + 96px);
}

body.modal-open .swd-form-modal .modal-footer .swd-submit-btn,
body.swd-modal-open .swd-form-modal .modal-footer .swd-submit-btn {
    margin-right: 0;
}

@media (max-width: 767px) {
    body.modal-open .swd-form-modal .modal-footer,
    body.swd-modal-open .swd-form-modal .modal-footer {
        padding-right: calc(1rem + 72px);
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 767px) {
    #modalAllowance .modal-dialog,
    #modalFamily .modal-dialog {
        width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
        margin: 0.5rem auto;
    }

    .swd-form-modal {
        max-height: calc(100vh - 1rem);
    }

    .swd-form-modal .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 9.5rem);
    }

    .swd-form-section {
        padding: 0.85rem;
    }
}
