* {
    box-sizing: border-box;
}

:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #17181a;
    --muted: #777b84;
    --line: #e8e9ed;
    --primary: #111214;
    --primary-hover: #2a2c30;
    --danger: #c92a2a;
    --success: #178344;
    --soft: #f1f2f4;
    --radius: 18px;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans TC",
        Arial,
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.brand {
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 20px;
}

.muted {
    color: var(--muted);
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 36px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
    margin: 30px 0 8px;
    font-size: 30px;
}

label {
    display: block;
    margin: 22px 0 8px;
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    height: 48px;
    border: 1px solid #dcdde2;
    border-radius: 12px;
    padding: 0 14px;
    outline: none;
    background: white;
}

input:focus {
    border-color: #777b84;
    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.04);
}

.primary-button,
.ghost-button,
.count-button,
.upload-button,
.remove-reference-button {
    border: 0;
    border-radius: 12px;
    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

.primary-button {
    height: 48px;
    padding: 0 20px;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.full {
    width: 100%;
    margin-top: 24px;
}

.ghost-button {
    height: 40px;
    padding: 0 16px;
    background: var(--soft);
    color: var(--text);
    font-weight: 700;
}

.message {
    margin-top: 16px;
    min-height: 20px;
    font-size: 14px;
    line-height: 1.6;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--success);
}

.dashboard {
    min-height: 100vh;
}

.topbar {
    min-height: 74px;
    padding: 0 32px;
    background: white;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar-email {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wallet-pill {
    height: 44px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--soft);
    border-radius: 999px;
    font-size: 13px;
}

.wallet-pill strong {
    font-size: 17px;
}

.tabs {
    padding: 18px 32px 0;
    display: flex;
    gap: 8px;
    max-width: 1280px;
    margin: 0 auto;
}

.tab {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 800;
}

.tab.active {
    background: white;
    color: var(--text);
}

.content {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 32px 60px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-heading h2 {
    margin: 0 0 6px;
}

.panel-heading p {
    margin: 0;
}

.generator-grid {
    display: grid;
    grid-template-columns:
        minmax(340px, 430px)
        minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
}

.result-card {
    min-height: 460px;
}

.upload-description {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 12px;
}

.file-input {
    display: none;
}

.upload-button {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    background: white;
    border: 1px dashed #b9bcc4;
    color: var(--text);
    font-weight: 800;
}

.upload-button:hover {
    background: var(--soft);
}

.reference-preview {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.reference-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--soft);
    aspect-ratio: 1 / 1;
}

.reference-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.reference-priority {
    position: absolute;
    top: 7px;
    left: 7px;
    padding: 5px 7px;
    border-radius: 999px;
    background: rgba(17, 18, 20, 0.88);
    color: white;
    font-size: 10px;
    font-weight: 800;
}

.remove-reference-button {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.94);
    color: var(--danger);
    font-weight: 900;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.10);
}

.reference-counter {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.count-selector {
    display: grid;
    grid-template-columns:
        repeat(3, 1fr);
    gap: 10px;
}

.count-button {
    height: 44px;
    background: var(--soft);
    color: var(--text);
    font-weight: 800;
}

.count-button.active {
    background: var(--primary);
    color: white;
}

.cost-box {
    margin-top: 24px;
    background: var(--soft);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cost-box strong {
    font-size: 22px;
}

.empty-state {
    min-height: 410px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    color: var(--muted);
}

.empty-state h3 {
    margin: 14px 0 6px;
    color: var(--text);
}

.empty-state p {
    max-width: 300px;
    line-height: 1.7;
}

.empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--soft);
    display: grid;
    place-items: center;
    font-size: 30px;
    color: var(--text);
}

#taskProgress {
    min-height: 410px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #e6e7ea;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation:
        spin 0.9s linear infinite;
    margin-bottom: 18px;
}

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

.result-header {
    margin-bottom: 18px;
}

.result-header h3 {
    margin: 0 0 4px;
}

.image-grid {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(220px, 1fr)
        );
    gap: 16px;
}

.image-item {
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--soft);
}

.image-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    object-fit: cover;
}

.image-actions {
    padding: 10px;
}

.download-link {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    background: white;
    color: var(--text);
    border-radius: 9px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
}

.list {
    display: grid;
    gap: 12px;
}

.list-item {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 17px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.list-main {
    min-width: 0;
}

.list-title {
    font-weight: 800;
}

.list-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.list-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.amount-negative {
    color: var(--danger);
    font-weight: 800;
}

.amount-positive {
    color: var(--success);
    font-weight: 800;
}

.status {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

.status-completed {
    color: var(--success);
}

.status-failed {
    color: var(--danger);
}

.empty-list {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 36px;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 820px) {
    .topbar {
        padding: 14px 18px;
        align-items: flex-start;
    }

    .topbar-actions {
        flex-direction: column;
        align-items: flex-end;
    }

    .tabs {
        padding: 14px 18px 0;
        overflow-x: auto;
    }

    .content {
        padding: 18px 18px 50px;
    }

    .generator-grid {
        grid-template-columns: 1fr;
    }

    .result-card {
        min-height: 360px;
    }

    .reference-preview {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .list-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .list-actions {
        width: 100%;
        justify-content: space-between;
    }
}


/*
============================================================
PARTIAL RESULTS DELIVERY V1
============================================================
*/

.message.warning {
    display: block;
    background: rgba(245, 158, 11, 0.10);
    border: 1px solid rgba(245, 158, 11, 0.28);
    color: #b45309;
}


.partial-result-summary {
    margin-bottom: 20px;
}


.partial-result-banner {
    padding: 16px 18px;
    margin-bottom: 14px;
    border-radius: 14px;
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.08);
}


.partial-result-banner-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 5px;
}


.partial-result-banner-text {
    font-size: 14px;
    line-height: 1.6;
    opacity: 0.82;
}


.partial-result-stats {
    display: grid;
    grid-template-columns:
        repeat(
            4,
            minmax(0, 1fr)
        );
    gap: 10px;
    margin-bottom: 18px;
}


.partial-result-stat {
    padding: 13px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(148, 163, 184, 0.06);
}


.partial-result-stat-label {
    font-size: 12px;
    opacity: 0.65;
    margin-bottom: 5px;
}


.partial-result-stat-value {
    font-size: 17px;
    font-weight: 700;
}


.refund-value {
    color: #16a34a;
}


.status-partial {
    color: #b45309;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.25);
}


.image-result-index {
    font-size: 12px;
    opacity: 0.65;
}


@media (
    max-width: 760px
) {

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

}


/*
============================================================
END PARTIAL RESULTS DELIVERY V1
============================================================
*/
