body.huiai-enhanced {
    padding-top: 0;
}

body.huiai-enhanced .main-layout {
    padding-top: 24px;
}

.management-topbar {
    position: relative;
    z-index: 1000;
    width: min(1200px, calc(100% - 32px));
    margin: 28px auto 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    justify-content: flex-end;
}

.management-brand {
    min-width: 0;
}

.management-brand strong {
    display: block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.management-kicker {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #6e6e73;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.management-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
}

.toolbar-order-badge {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: #f4f6fb;
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-order-badge.is-dirty {
    background: #fff2df;
    color: #a15b00;
}

.toolbar-order-badge.is-empty {
    background: #f0f0f3;
    color: #6e6e73;
}

.toolbar-user {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    height: 42px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.toolbar-btn:active {
    transform: scale(0.98);
}

.toolbar-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.toolbar-btn-primary {
    background: linear-gradient(135deg, #007aff 0%, #0059c9 100%);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 122, 255, 0.22);
}

.toolbar-btn-secondary {
    background: #eef2f7;
    color: #1d1d1f;
}

.toolbar-btn-danger {
    background: #fff1f1;
    color: #d93025;
}

.management-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(10, 15, 25, 0.36);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.management-modal-backdrop.open {
    display: flex;
}

.management-modal {
    width: min(720px, 100%);
    max-height: min(82vh, 960px);
    overflow: hidden;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
}

.management-modal.is-narrow {
    width: min(420px, 100%);
}

.management-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 28px 0;
}

.management-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.management-modal-header p {
    margin: 6px 0 0;
    color: #6e6e73;
    font-size: 14px;
}

.management-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f1f3f6;
    font-size: 18px;
    cursor: pointer;
}

.management-modal-body {
    padding: 24px 28px 28px;
    overflow: auto;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label {
    margin-bottom: 6px;
    font-size: 14px;
    color: #1d1d1f;
}

.auth-form input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    margin-bottom: 0;
    border: none;
    background-color: #F5F5F7;
    border-radius: 12px;
    font-size: 17px;
    color: #1D1D1F;
    appearance: none;
    -webkit-appearance: none;
}

.auth-form input:focus {
    outline: none;
    background-color: #fff;
    box-shadow: 0 0 0 2px #007AFF;
}

.auth-form .toolbar-btn {
    width: 100%;
    height: 50px;
    border-radius: 14px;
}

.auth-error {
    min-height: 20px;
    color: #d93025;
    font-size: 13px;
}

.history-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 18px;
}

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

.history-empty {
    padding: 26px 18px;
    border-radius: 18px;
    background: #f7f8fb;
    color: #6e6e73;
    text-align: center;
    font-size: 14px;
}

.history-item {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    padding: 16px 18px;
    background: #fff;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 122, 255, 0.2);
}

.history-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
}

.history-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.history-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #6e6e73;
    font-size: 13px;
}

.history-item-amount {
    color: #007aff;
    white-space: nowrap;
}

.history-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 32px;
    padding: 0 12px;
    border: none;
    border-radius: 999px;
    background: #fff1f1;
    color: #d93025;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.history-delete-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.management-toast-layer {
    position: fixed;
    top: 24px;
    right: 20px;
    z-index: 3600;
    display: grid;
    gap: 10px;
}

.management-toast {
    min-width: 220px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.12);
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    animation: toastIn 0.25s ease;
}

.management-toast.info {
    background: rgba(17, 24, 39, 0.94);
}

.management-toast.success {
    background: rgba(28, 131, 73, 0.95);
}

.management-toast.error {
    background: rgba(217, 48, 37, 0.95);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-upload-block {
    margin-top: 16px;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(0, 122, 255, 0.06) 0%, rgba(255, 255, 255, 0.98) 100%);
    border: 1px solid rgba(0, 122, 255, 0.12);
}

.image-upload-block.compact {
    margin: 10px 0 0 34px;
}

.image-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.image-upload-title {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
}

.image-upload-count {
    font-size: 12px;
    color: #6e6e73;
}

.image-upload-note {
    margin: 0 0 14px;
    color: #6e6e73;
    font-size: 13px;
}

.image-upload-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.image-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 999px;
    background: #007aff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.image-upload-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.image-empty {
    grid-column: 1 / -1;
    padding: 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    color: #8c8c92;
    font-size: 13px;
    text-align: center;
}

.image-card {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    cursor: zoom-in;
}

.image-card img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: #f3f4f6;
}

.image-preview-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(8, 12, 18, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.image-preview-backdrop.open {
    display: flex;
}

.image-preview-dialog {
    position: relative;
    width: min(980px, 100%);
    max-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.image-preview-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
}

.image-preview-figure {
    margin: 0;
    width: 100%;
}

.image-preview-figure img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 150px);
    margin: 0 auto;
    border-radius: 22px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
    background: rgba(255, 255, 255, 0.08);
}

.image-preview-caption {
    margin-top: 14px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    word-break: break-all;
}

.image-card-footer {
    padding: 10px 10px 12px;
}

.image-card-name {
    display: block;
    color: #1d1d1f;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-all;
    min-height: 34px;
}

.image-card-tag {
    display: inline-flex;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #6e6e73;
    font-size: 11px;
}

.image-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.84);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.qrcode-placeholder {
    width: 180px;
    min-height: 180px;
    margin: 0 auto;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: #f5f6fa;
    color: #6e6e73;
    font-size: 14px;
}

@media (max-width: 1023px) {
    body.huiai-enhanced {
        padding-top: 0;
    }

    body.huiai-enhanced .main-layout {
        padding-top: 0;
    }

    .management-topbar {
        width: auto;
        margin: 20px 16px 0;
        align-items: flex-start;
        justify-content: flex-end;
    }

    .management-toolbar-right {
        width: 100%;
        justify-content: flex-end;
    }

    .toolbar-btn {
        min-width: 0;
        flex: 1 1 calc(50% - 6px);
    }

    .toolbar-user,
    .toolbar-order-badge {
        flex: 1 1 100%;
        justify-content: center;
    }

    .management-toast-layer {
        left: 16px;
        right: 16px;
        top: 20px;
    }

    .management-toast {
        max-width: none;
    }

    .management-modal-backdrop {
        padding: 16px;
    }

    .management-modal-header,
    .management-modal-body {
        padding-left: 20px;
        padding-right: 20px;
    }

    .history-toolbar {
        grid-template-columns: 1fr;
    }

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

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

    .image-upload-block.compact {
        margin-left: 0;
    }

    .image-preview-backdrop {
        padding: 16px;
    }

    .image-preview-close {
        top: -6px;
        right: -2px;
    }
}

@media (max-width: 767px) {
    .management-toolbar-right {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
        align-items: stretch;
    }

    .toolbar-order-badge {
        grid-column: 1 / -1;
        min-height: 44px;
        padding: 10px 14px;
        justify-content: center;
        white-space: normal;
        line-height: 1.35;
        text-align: center;
    }

    .toolbar-btn,
    .toolbar-user {
        min-width: 0;
        width: 100%;
        height: 40px;
        padding: 0 8px;
        font-size: 12px;
    }

    .toolbar-user {
        overflow: hidden;
        text-overflow: ellipsis;
        justify-content: center;
    }
}
