:root {
    --bg-top: #f7f7f8;
    --bg-bottom: #ececee;
    --panel: rgba(255, 255, 255, 0.94);
    --text: #111111;
    --muted: #6b7280;
    --accent: #222222;
    --accent-strong: #000000;
    --accent-soft: #f3f4f6;
    --secondary: #3a3a3a;
    --line: rgba(0, 0, 0, 0.08);
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: 'Trebuchet MS', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
        linear-gradient(135deg, var(--bg-top), var(--bg-bottom));
}

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.page-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f6f6;
    z-index: 9999;
    font-size: 20px;
    font-weight: 600;
    color: #111;
}

.brand-landing-shell,
.container.gallery-shell {
    width: min(1280px, calc(100vw - 40px));
    margin: 24px auto;
}

.login-page-shell {
    width: 100%;
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: min(420px, calc(100vw - 32px));
    padding: 32px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.9));
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.10);
    backdrop-filter: blur(18px);
}

.login-badge {
    margin: 0 0 14px;
    font-size: 0.78rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--muted);
}

.login-title {
    margin: 0;
    font-size: clamp(2rem, 5vw, 2.4rem);
    line-height: 1.1;
    color: #111111;
}

.login-subtitle {
    margin: 14px 0 24px;
    color: var(--muted);
    line-height: 1.7;
}

.login-form-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    width: 100%;
}

.login-form-card input {
    width: 100%;
    height: 52px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 14px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.96);
    font-size: 1rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-form-card input:focus {
    border-color: rgba(0, 0, 0, 0.28);
    box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.06);
    background: #ffffff;
}

.login-submit-btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #1f1f1f, #000000);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.login-submit-btn:hover {
    background: linear-gradient(135deg, #303030, #111111);
    transform: translateY(-1px);
}

.login-submit-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.brand-landing-shell {
    padding: 32px 0 48px;
}

.brand-hero,
.brands-panel,
.container.gallery-shell {
    backdrop-filter: blur(16px);
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--shadow);
}

.brand-hero {
    border-radius: 28px;
    padding: 36px;
    background: linear-gradient(135deg, #111111, #3a3a3a);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.brand-hero::after {
    content: '';
    position: absolute;
    width: 280px;
    height: 280px;
    right: -80px;
    top: -120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.86rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    opacity: 0.78;
}

.brand-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.05;
}

.brand-hero-copy {
    max-width: 720px;
    margin: 16px 0 0;
    font-size: 1rem;
    line-height: 1.7;
    opacity: 0.92;
}

.brands-panel {
    margin-top: 22px;
    border-radius: 28px;
    padding: 28px;
}

.brands-panel-head,
.gallery-header,
.attribute-header,
.image-actions,
.modal-buttons,
.header-tools,
.search-section,
.upload-section,
.brand-summary,
.attribute-counts,
.pagination,
.login-form,
.user-info {
    display: flex;
    align-items: center;
}

.brands-panel-head,
.gallery-header,
.attribute-header {
    justify-content: space-between;
}

.brands-panel-head h2,
.attribute-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.ghost-btn,
.lang-btn,
.add-attr-btn,
.search-btn,
.clear-btn,
#loginBtn,
#logoutBtn,
.pagination button,
.confirm-btn,
.cancel-btn,
.edit-images-btn,
.delete-btn,
.carousel-btn,
.preview-nav,
.close-preview-btn,
.attr-tab,
.enter-brand-btn {
    transition: 0.2s ease;
}

.ghost-btn,
.lang-btn,
#loginBtn,
#logoutBtn,
.add-attr-btn,
.search-btn,
.clear-btn,
.edit-images-btn,
.delete-btn,
.confirm-btn,
.cancel-btn,
.pagination button,
.attr-tab,
.upload-btn,
.brand-card {
    border: none;
    cursor: pointer;
}

.ghost-btn,
.lang-btn,
.attr-tab,
.clear-btn,
.cancel-btn,
.pagination button {
    background: #f3f4f6;
    color: var(--text);
}

.ghost-btn,
.lang-btn,
.upload-btn,
.search-btn,
.clear-btn,
#loginBtn,
#logoutBtn,
.add-attr-btn,
.edit-images-btn,
.delete-btn,
.confirm-btn,
.cancel-btn,
.pagination button,
.attr-tab {
    border-radius: 14px;
    padding: 11px 16px;
    font-size: 0.95rem;
}

.ghost-btn:hover,
.lang-btn:hover,
.clear-btn:hover,
.cancel-btn:hover,
.pagination button:hover,
.attr-tab:hover {
    transform: translateY(-1px);
    background: #e5e7eb;
}

.brands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.brand-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #ffffff;
    border-radius: 24px;
    min-height: 160px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
}

.brand-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.10);
}

.brand-card-body {
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 160px;
}

.brand-name {
    margin: 0;
    font-size: 1.28rem;
    font-weight: 700;
    text-align: center;
}

.enter-brand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 12px;
    background: #111111;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.92rem;
}

.brand-card:hover .enter-brand-btn {
    background: #2b2b2b;
}

.brands-empty {
    margin-top: 20px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(243, 244, 246, 0.9);
    color: var(--muted);
}

.container.gallery-shell {
    border-radius: 32px;
    padding: 28px;
}

.gallery-header {
    gap: 16px;
    margin-bottom: 22px;
}

.gallery-header-main {
    flex: 1;
}

.back-link {
    display: inline-flex;
    margin-bottom: 14px;
    color: #111111;
    text-decoration: none;
    font-weight: 700;
}

.gallery-header h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3rem);
}

.brand-summary {
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.brand-summary-label {
    color: var(--muted);
}

.brand-summary-name {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #111111;
}

.brand-summary-description {
    margin: 12px 0 0;
    color: var(--muted);
    max-width: 700px;
    line-height: 1.7;
}

.header-tools {
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.lang-switcher {
    display: flex;
    gap: 10px;
}

.lang-btn.active {
    background: #111111;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.login-form,
.user-info {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.login-form input,
#newAttributeName,
.search-input,
.image-name-input,
.image-remark-input,
.attr-selector select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    padding: 12px 14px;
    font-size: 0.95rem;
    color: var(--text);
}

.login-form input {
    width: 160px;
}

.search-section,
.upload-section,
.attribute-tabs,
.attribute-counts,
.image-actions,
.pagination {
    flex-wrap: wrap;
    gap: 12px;
}

.pagination {
    flex-wrap: nowrap;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    gap: 8px;
    scrollbar-width: thin;
}

.pagination-btn {
    flex: 0 0 auto;
}

.pagination-btn:disabled,
.pagination-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.pagination-ellipsis {
    flex: 0 0 auto;
    align-self: center;
    color: var(--muted);
    font-size: 0.95rem;
    padding: 0 4px;
    user-select: none;
    pointer-events: none;
}

.pagination-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    flex: 0 0 auto;
}

.pagination-page-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 14px;
    flex: 0 0 auto;
}

#pageSizeSelect {
    min-width: 74px;
    height: 36px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    cursor: pointer;
}

#pageJumpInput {
    width: 60px;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    text-align: center;
}

#pageJumpBtn {
    padding: 6px 10px;
}

.upload-section {
    justify-content: center;
    margin-bottom: 18px;
}

.upload-btn,
#loginBtn,
#logoutBtn,
.confirm-btn,
.edit-images-btn {
    background: linear-gradient(135deg, #222222, #000000);
    color: #fff;
}

.upload-btn.export,
.add-attr-btn,
.search-btn {
    background: linear-gradient(135deg, #222222, #000000);
    color: #fff;
}

.delete-btn {
    background: linear-gradient(135deg, #7f1d1d, #991b1b);
    color: #fff;
}

.search-section {
    justify-content: center;
    margin-bottom: 18px;
}

.search-input {
    width: min(420px, 92vw);
}

.attribute-section {
    margin-bottom: 20px;
}

.attribute-tabs {
    display: flex;
    margin: 14px 0 10px;
}

.attr-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.attr-tab.active {
    background: #111111;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.delete-attr {
    border: none;
    background: transparent;
    color: #dc2626;
    font-size: 1.1rem;
    cursor: pointer;
}

.attribute-counts {
    display: flex;
}

.count-item {
    display: inline-flex;
    gap: 6px;
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

.image-card {
    padding: 16px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 249, 0.9));
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.06);
}

.carousel {
    position: relative;
}

.carousel-img,
.carousel.empty {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 20px;
}

.carousel-img {
    object-fit: cover;
    background: #e2e8f0;
    cursor: pointer;
}

.carousel.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    color: #94a3b8;
    font-size: 3rem;
}

.carousel-btn,
.preview-nav,
.close-preview-btn {
    position: absolute;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.5);
    color: #fff;
}

.carousel-btn {
    width: 36px;
    height: 36px;
    top: calc(50% - 18px);
}

.carousel-btn.left {
    left: 10px;
}

.carousel-btn.right {
    right: 10px;
}

.carousel-btn:hover,
.preview-nav:hover,
.close-preview-btn:hover {
    background: rgba(15, 23, 42, 0.72);
}

.carousel-indicators-inline {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 2px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
}

.carousel-dot.active {
    background: #111111;
}

.image-name-input,
.image-remark-input,
.readonly-field {
    margin-top: 12px;
}

.image-remark-input {
    min-height: 92px;
    resize: vertical;
}

.readonly-field {
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8f8f8;
    color: #111111;
    line-height: 1.6;
    min-height: 48px;
}

.readonly-field.attr {
    background: #efefef;
    font-weight: 700;
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    width: 100%;
}

.attr-selector-row,
.image-buttons-row {
    display: flex;
    width: 100%;
}

.image-buttons-row {
    gap: 10px;
}

.image-buttons-row .edit-images-btn,
.image-buttons-row .delete-btn {
    flex: 1;
    justify-content: center;
    text-align: center;
}

.attr-selector {
    flex: 1;
    min-width: 0;
}

.permission-notice {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.hidden-by-permission {
    display: none !important;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 44px 20px;
    border-radius: 24px;
    text-align: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.78);
}

.pagination {
    justify-content: center;
    margin-top: 22px;
}

/* ====== 批量选择删除 ====== */
.batch-action-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 18px;
}

.selected-count-display {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0 4px;
    min-width: 64px;
    text-align: center;
}

.batch-delete-btn {
    background: linear-gradient(135deg, #7f1d1d, #991b1b) !important;
}

.batch-delete-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.image-select-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
    accent-color: #111111;
    border-radius: 4px;
}

.image-card.selected {
    outline: 2px solid #111111;
    box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.10), 0 16px 30px rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
}

.image-card.persist-selected {
    outline: 2px solid #16a34a;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15), 0 18px 32px rgba(0, 0, 0, 0.06);
}

.selected-status-badge {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 10;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.92);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    max-width: calc(100% - 56px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .batch-action-section {
        flex-direction: row;
        justify-content: center;
    }
}

.pagination button.active {
    background: #111111;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.pagination-btn.active {
    background: #111111;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    width: min(460px, 92vw);
    border-radius: 24px;
    background: #fff;
    padding: 24px;
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin: 0 0 16px;
}

.modal-buttons {
    justify-content: flex-end;
    margin-top: 16px;
}

.export-modal-content {
    width: min(880px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.export-modal-header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.export-selected-count {
    color: var(--muted);
    font-size: 0.95rem;
}

.export-modal-search-row {
    display: flex;
}

.export-search-input {
    width: 100%;
}

.export-modal-actions-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.export-list {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfbfb;
    min-height: 280px;
    max-height: 42vh;
    overflow-y: auto;
    padding: 8px;
}

.export-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
}

.export-row:hover {
    background: #f3f4f6;
}

.export-row input[type='checkbox'] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: #111111;
    cursor: pointer;
}

.export-row-content {
    flex: 1;
    min-width: 0;
}

.export-row-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-row-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.87rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-empty {
    color: var(--muted);
    text-align: center;
    padding: 30px 12px;
}

.export-pagination {
    margin-top: 0;
}

.export-modal-footer {
    margin-top: 0;
}

.export-sheet-btn {
    background: linear-gradient(135deg, #2f2f2f, #111111);
}

.image-preview-modal {
    background: rgba(2, 6, 23, 0.82);
}

.image-preview-content {
    position: relative;
    width: min(1000px, 94vw);
    height: min(760px, 88vh);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #020617;
}

#previewImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 16px;
}

.close-preview-btn {
    top: 22px;
    right: 22px;
    width: 52px;
    height: 52px;
}

.preview-nav {
    top: calc(50% - 27px);
    width: 54px;
    height: 54px;
}

.preview-nav.prev {
    left: 22px;
}

.preview-nav.next {
    right: 22px;
}

.lightbox-close-btn,
.lightbox-nav-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(3px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-close-btn {
    font-size: 28px;
    font-weight: 500;
}

.lightbox-nav-btn {
    font-size: 30px;
    font-weight: 500;
}

.lightbox-close-btn:hover,
.lightbox-nav-btn:hover {
    background: rgba(15, 23, 42, 0.74);
    border-color: rgba(255, 255, 255, 0.34);
    transform: scale(1.04);
}

@media (max-width: 640px) {
    .close-preview-btn {
        top: 14px;
        right: 14px;
        width: 46px;
        height: 46px;
    }

    .preview-nav {
        width: 48px;
        height: 48px;
        top: calc(50% - 24px);
    }

    .preview-nav.prev {
        left: 12px;
    }

    .preview-nav.next {
        right: 12px;
    }

    .lightbox-close-btn {
        font-size: 24px;
    }

    .lightbox-nav-btn {
        font-size: 26px;
    }
}

@media (max-width: 900px) {
    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-tools {
        width: 100%;
        justify-content: flex-start;
    }

    .login-form input {
        width: 100%;
    }

    .brand-landing-shell,
    .container.gallery-shell {
        width: min(100vw - 20px, 1280px);
        margin: 10px auto;
    }
}

@media (max-width: 640px) {
    .brand-hero,
    .brands-panel,
    .container.gallery-shell {
        border-radius: 22px;
        padding: 18px;
    }

    .login-card {
        padding: 24px;
        border-radius: 24px;
    }

    .gallery {
        grid-template-columns: 1fr;
    }

    .upload-btn,
    .search-btn,
    .clear-btn,
    .add-attr-btn,
    .edit-images-btn,
    .delete-btn,
    .attr-selector,
    .attr-selector select,
    .search-input {
        width: 100%;
    }

    .export-modal-content {
        padding: 18px;
        width: min(100vw - 16px, 880px);
    }

    .export-modal-footer {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .pagination {
        gap: 6px;
    }

    .pagination-page-size,
    .pagination-jump {
        margin-left: 8px;
    }
}