:root {
    --apma-blue: #1a397b;
    --apma-blue-deep: #122a5d;
    --apma-red: #d9232e;
    --apma-ink: #23262f;
    --apma-muted: #697386;
    --apma-surface: #ffffff;
    --apma-page: #f6f8fa;
    --apma-line: #dce3ed;
}

body {
    font-family: "Noto Sans TC", "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--apma-ink);
    background: var(--apma-page);
}

.apma-navbar {
    min-height: 72px;
    background: var(--apma-surface);
    border-bottom: 3px solid var(--apma-blue);
    box-shadow: 0 1px 10px rgb(26 57 123 / 8%);
}

.apma-navbar-logo {
    display: block;
    width: min(210px, 56vw);
    height: auto;
}

.apma-navbar .nav-link {
    color: var(--apma-blue);
    font-weight: 600;
}

.apma-navbar .nav-link:hover,
.apma-navbar .nav-link:focus {
    color: var(--apma-red);
}

.apma-shell {
    background: var(--apma-page);
}

.apma-footer {
    padding: 1rem 0;
    color: #fff;
    background: var(--apma-blue);
    font-size: .8125rem;
    letter-spacing: .02em;
}

.apma-auth-shell {
    background:
        linear-gradient(135deg, rgb(26 57 123 / 5%), transparent 45%),
        var(--apma-page);
}

.apma-auth-main {
    display: grid;
    place-items: center;
    padding: 3rem 1.25rem;
}

.apma-login-section {
    width: min(100%, 470px);
}

.apma-login-brand {
    margin-bottom: 1.5rem;
}

.apma-login-logo {
    width: min(100%, 360px);
    height: auto;
}

.apma-login-brand p {
    margin: .75rem 0 0;
    color: var(--apma-blue);
    font-size: .9375rem;
    font-weight: 700;
    letter-spacing: .18em;
}

.apma-login-card {
    overflow: hidden;
    padding: 2rem;
    background: var(--apma-surface);
    border: 1px solid var(--apma-line);
    border-top: 5px solid var(--apma-blue);
    border-radius: 4px;
    box-shadow: 0 14px 34px rgb(35 38 47 / 11%);
}

.apma-login-card-header {
    margin-bottom: 1.75rem;
    text-align: center;
}

.apma-login-card-header h1 {
    margin: 0;
    color: var(--apma-blue);
    font-size: 1.55rem;
    font-weight: 700;
}

.apma-login-card-header p {
    margin: .6rem 0 0;
    color: var(--apma-muted);
    font-size: .9375rem;
}

.apma-login-card .form-label {
    color: var(--apma-ink);
    font-weight: 700;
}

.apma-login-card .form-control {
    min-height: 46px;
    border-color: #cbd5e1;
    border-radius: 3px;
}

.apma-login-card .form-control:focus {
    border-color: var(--apma-blue);
    box-shadow: 0 0 0 .2rem rgb(26 57 123 / 14%);
}

.apma-login-submit {
    min-height: 46px;
    color: #fff;
    background: var(--apma-red);
    border: 1px solid var(--apma-red);
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: .08em;
}

.apma-login-submit:hover,
.apma-login-submit:focus {
    color: #fff;
    background: var(--apma-blue);
    border-color: var(--apma-blue);
}

.apma-login-help {
    margin-top: 1.25rem;
    font-size: .875rem;
}

.apma-login-help a {
    color: var(--apma-blue);
    text-decoration: none;
}

.apma-login-help a:hover {
    color: var(--apma-red);
    text-decoration: underline;
}

.badge {
    font-size: 0.85rem;
}

.apma-member-hero {
    color: #fff;
    background: linear-gradient(120deg, var(--apma-blue-deep), var(--apma-blue));
}

.apma-member-hero .text-secondary {
    color: rgb(255 255 255 / 78%) !important;
}

.apma-section-kicker {
    color: #f3abb0;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .14em;
}

.apma-btn-primary {
    color: #fff;
    background: var(--apma-red);
    border-color: var(--apma-red);
    font-weight: 700;
}

.apma-btn-primary:hover,
.apma-btn-primary:focus {
    color: #fff;
    background: #b81721;
    border-color: #b81721;
}

.apma-member-card {
    border-top: 3px solid var(--apma-blue) !important;
}

.apma-member-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
}

.apma-member-details div {
    min-width: 0;
}

.apma-member-details dt {
    margin-bottom: .2rem;
    color: var(--apma-muted);
    font-size: .8rem;
    font-weight: 600;
}

.apma-member-details dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--apma-ink);
    font-weight: 600;
}

.apma-member-exam-table thead th {
    color: #fff;
    background: var(--apma-blue);
    border-color: var(--apma-blue);
    white-space: nowrap;
}

.apma-member-exam-table td {
    min-width: 7.25rem;
}

.apma-member-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    min-width: 8.5rem !important;
}

.apma-print-document,
.apma-certificate {
    width: min(100% - 2rem, 900px);
    border-top: 5px solid var(--apma-blue);
}

.apma-certificate {
    min-height: 680px;
    border: 12px double var(--apma-blue);
}

.apma-print-logo {
    width: min(100%, 330px);
    height: auto;
}

.apma-legacy-receipt {
    position: relative;
    width: min(100% - 2rem, 1120px);
    aspect-ratio: 2340 / 1654;
    background: #fff url("../documents/payissue02.jpg") center / contain no-repeat;
    font-family: Georgia, "Times New Roman", serif;
    color: #111;
    container-type: inline-size;
}

.apma-legacy-receipt > div {
    position: absolute;
    font-size: clamp(1rem, 2.1cqw, 1.35rem);
    font-weight: 500;
    line-height: 1.15;
}

.apma-receipt-number { top: 12.5%; left: 7%; font-size: clamp(.8rem, 1.55cqw, 1rem) !important; font-weight: 700; }
.apma-receipt-to { top: 33.25%; left: 18%; width: 48%; font-size: clamp(.9rem, 1.8cqw, 1.15rem) !important; }
.apma-receipt-re { top: 40.35%; left: 35.25%; width: 34%; font-size: clamp(.7rem, 1.25cqw, .9rem) !important; line-height: 1.08 !important; }
.apma-receipt-amount { top: 41%; left: 73%; font-size: clamp(.9rem, 1.75cqw, 1.15rem) !important; font-weight: 700; }
.apma-receipt-date { top: 55%; left: 20%; font-size: clamp(.8rem, 1.5cqw, 1rem) !important; }

.apma-taiwan-receipt {
    position: relative;
    width: min(100% - 2rem, 1122px);
    aspect-ratio: 297 / 210;
    background: #fff url("../documents/reciept_taiwan.jpg") center / 100% 100% no-repeat;
    color: #111;
    container-type: inline-size;
    font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.apma-taiwan-receipt > div {
    position: absolute;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

.apma-taiwan-receipt-recipient { top: 25.4%; left: 18%; width: 29%; font-size: clamp(1rem, 2.2cqw, 1.55rem); }
.apma-taiwan-receipt-year { top: 18.1%; left: 65.5%; width: 7%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-taiwan-receipt-month { top: 18.1%; left: 76.5%; width: 5%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-taiwan-receipt-day { top: 18.1%; left: 85.5%; width: 5%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-taiwan-receipt-unit { top: 38.6%; left: 39.3%; width: 14%; font-size: clamp(.85rem, 1.8cqw, 1.25rem); }
.apma-taiwan-receipt-total { top: 38.6%; left: 54%; width: 14%; font-size: clamp(.85rem, 1.8cqw, 1.25rem); }
.apma-taiwan-receipt-amount-words { top: 85.4%; left: 5%; width: 57%; padding: .35% 0; background: #fff; font-family: "Noto Serif TC", "PMingLiU", serif; font-size: clamp(.75rem, 1.58cqw, 1.08rem); letter-spacing: .08em; }

.apma-corporate-receipt {
    position: relative;
    width: min(100% - 2rem, 1122px);
    aspect-ratio: 297 / 210;
    background: #fff url("../documents/reciept_corp_tex.jpg") center / 100% 100% no-repeat;
    color: #111;
    container-type: inline-size;
    font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.apma-corporate-receipt > div {
    position: absolute;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

.apma-corporate-receipt-recipient { top: 24.2%; left: 36%; width: 28%; font-size: clamp(1rem, 2.2cqw, 1.55rem); }
.apma-corporate-receipt-year { top: 18.2%; left: 66%; width: 7%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-corporate-receipt-month { top: 18.2%; left: 76.5%; width: 5%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-corporate-receipt-day { top: 18.2%; left: 85.5%; width: 5%; font-size: clamp(.75rem, 1.65cqw, 1.15rem); }
.apma-corporate-receipt-quantity { top: 38.8%; left: 25.6%; width: 10%; font-size: clamp(.85rem, 1.8cqw, 1.25rem); }
.apma-corporate-receipt-unit { top: 38.8%; left: 42.5%; width: 11%; font-size: clamp(.85rem, 1.8cqw, 1.25rem); }
.apma-corporate-receipt-total { top: 38.8%; left: 56.5%; width: 12%; font-size: clamp(.85rem, 1.8cqw, 1.25rem); }
.apma-corporate-receipt-amount-words { top: 85.2%; left: 5%; width: 57%; padding: .35% 0; background: #fff; font-family: "Noto Serif TC", "PMingLiU", serif; font-size: clamp(.75rem, 1.58cqw, 1.08rem); letter-spacing: .08em; }

.apma-legacy-ticket {
    position: relative;
    width: min(100% - 2rem, 1120px);
    aspect-ratio: 1992 / 2819;
    background: #fff url("../documents/examticket.png") center / 100% 100% no-repeat;
    color: #111827;
    font-family: "Noto Sans TC", Arial, sans-serif;
}

.apma-legacy-ticket > div {
    position: absolute;
    left: 16.25%;
    width: 31.7%;
    overflow-wrap: anywhere;
    font-size: clamp(.42rem, 1.12vw, .92rem);
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
}

.apma-ticket-account { top: 9.2%; }
.apma-ticket-chinese-name { top: 13.75%; }
.apma-ticket-english-name { top: 17.8%; }
.apma-ticket-identity { top: 21.9%; }
.apma-ticket-login-account { top: 25.95%; font-size: clamp(.38rem, .9vw, .75rem) !important; }
.apma-ticket-password { top: 30.05%; }
.apma-ticket-date { top: 34.1%; font-size: clamp(.38rem, .87vw, .72rem) !important; }
.apma-ticket-site { top: 38.15%; }
.apma-ticket-classroom { top: 42.25%; }

.apma-legacy-certificate {
    position: relative;
    isolation: isolate;
    width: min(100% - 2rem, 1122px);
    aspect-ratio: 297 / 210;
    background: #fff url("../documents/license_back.jpg") center / 100% 100% no-repeat;
    container-type: inline-size;
}

.apma-legacy-certificate-inner {
    position: absolute;
    z-index: 1;
    inset: 10.2% 4%;
    overflow: hidden;
    background: #fff url("../documents/positive_01.jpg") center / 100% 100% no-repeat;
    color: #09275f;
    font-family: Georgia, "Times New Roman", serif;
    text-align: center;
}

.apma-certificate-name,
.apma-certificate-program,
.apma-certificate-date,
.apma-certificate-serial {
    position: absolute;
    left: 10%;
    width: 80%;
}

.apma-certificate-name { top: 30%; font-size: clamp(1.4rem, 3.55cqw, 2.45rem); font-weight: 700; line-height: 1.08; }
.apma-certificate-program { top: 54%; font-size: clamp(.9rem, 1.85cqw, 1.35rem); font-style: italic; line-height: 1.15; }
.apma-certificate-date { top: 68%; font-size: clamp(.85rem, 1.65cqw, 1.12rem); }
.apma-certificate-serial { top: 76%; left: 9%; width: 44%; font-family: "Noto Sans TC", sans-serif; font-size: clamp(.68rem, 1.3cqw, .92rem); line-height: 1.1; text-align: left; }

.apma-coaching-certificate {
    position: relative;
    width: min(100% - 2rem, 794px);
    aspect-ratio: 1654 / 2340;
    background: #fff url("../documents/teach_issue2.png") center / 100% 100% no-repeat;
    color: #111827;
    font-family: "Noto Serif TC", "PMingLiU", Georgia, serif;
    container-type: inline-size;
}

.apma-coaching-serial {
    position: absolute;
    top: 39.5%;
    right: 17%;
    font-family: "Noto Sans TC", Arial, sans-serif;
    font-size: clamp(.8rem, 2.1cqw, 1.25rem);
    font-weight: 700;
}

.apma-coaching-school-class {
    position: absolute;
    top: 42.5%;
    left: 14%;
    width: 72%;
    font-size: clamp(.9rem, 2.5cqw, 1.45rem);
    font-weight: 700;
    text-align: center;
}

.apma-coaching-teacher {
    position: absolute;
    top: 48.8%;
    left: 14%;
    width: 38%;
    font-size: clamp(1rem, 2.8cqw, 1.6rem);
    font-weight: 700;
    text-align: center;
}

.apma-coaching-project {
    position: absolute;
    top: 53.6%;
    left: 14%;
    width: 72%;
    font-size: clamp(.85rem, 2.4cqw, 1.35rem);
    font-weight: 700;
    text-align: center;
}

.apma-coaching-total {
    position: absolute;
    top: 57.8%;
    left: 48%;
    width: 18%;
    font-family: "Noto Sans TC", Arial, sans-serif;
    font-size: clamp(1.1rem, 3.2cqw, 1.85rem);
    font-weight: 700;
    text-align: center;
}

.apma-coaching-date {
    position: absolute;
    top: 76.5%;
    right: 16%;
    font-size: clamp(.85rem, 2.3cqw, 1.3rem);
    font-weight: 700;
}

@media print {
    .apma-navbar,
    .apma-footer,
    .apma-no-print {
        display: none !important;
    }

    body,
    .apma-shell {
        background: #fff !important;
    }

    .apma-print-document,
    .apma-certificate,
    .apma-legacy-receipt,
    .apma-taiwan-receipt,
    .apma-corporate-receipt,
    .apma-legacy-ticket,
    .apma-legacy-certificate,
    .apma-coaching-certificate {
        width: 100%;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .apma-legacy-certificate {
        width: 297mm !important;
        height: 210mm;
        aspect-ratio: auto;
    }

    .apma-coaching-certificate {
        width: 210mm !important;
        height: 297mm;
        aspect-ratio: auto;
    }

    .apma-taiwan-receipt {
        width: 297mm !important;
        height: 210mm;
        aspect-ratio: auto;
    }

    .apma-corporate-receipt {
        width: 297mm !important;
        height: 210mm;
        aspect-ratio: auto;
    }

    body.apma-shell:has(.apma-taiwan-receipt) {
        display: block !important;
        min-height: 0 !important;
    }

    body.apma-shell:has(.apma-taiwan-receipt) > main.container {
        width: 297mm !important;
        min-width: 297mm !important;
        max-width: 297mm !important;
        height: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.apma-shell:has(.apma-corporate-receipt) {
        display: block !important;
        min-height: 0 !important;
    }

    body.apma-shell:has(.apma-corporate-receipt) > main.container {
        width: 297mm !important;
        min-width: 297mm !important;
        max-width: 297mm !important;
        height: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .apma-auth-main {
        padding: 2rem 1rem;
    }

    .apma-login-card {
        padding: 1.5rem;
    }

    .apma-member-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .apma-member-exam-table-wrapper {
        overflow-x: visible;
    }

    .apma-member-exam-table,
    .apma-member-exam-table tbody,
    .apma-member-exam-table tr,
    .apma-member-exam-table td {
        display: block;
        width: 100%;
    }

    .apma-member-exam-table thead {
        display: none;
    }

    .apma-member-exam-table tbody {
        display: grid;
        gap: 1rem;
    }

    .apma-member-exam-table tr {
        overflow: hidden;
        border: 1px solid rgba(26, 57, 123, .18);
        border-radius: .75rem;
        background: #fff;
        box-shadow: 0 .25rem .75rem rgba(28, 45, 79, .06);
    }

    .apma-member-exam-table td {
        min-width: 0;
        padding: .8rem 1rem;
        border: 0;
        border-bottom: 1px solid #e8edf5;
        overflow-wrap: anywhere;
    }

    .apma-member-exam-table td::before {
        display: block;
        margin-bottom: .3rem;
        color: var(--apma-muted);
        font-size: .75rem;
        font-weight: 700;
        content: attr(data-label);
    }

    .apma-member-exam-table td:last-child {
        border-bottom: 0;
    }

    .apma-member-exam-table td.apma-member-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: .5rem;
    }

    .apma-member-actions::before {
        grid-column: 1 / -1;
    }

    .apma-member-actions .btn {
        min-width: 0;
        padding: .45rem .35rem;
        font-size: .8rem;
        line-height: 1.25;
        white-space: normal;
    }

    .apma-member-actions .btn:first-of-type {
        grid-column: 1 / -1;
    }
}
